2017-09-26 45 views
0

我想一個Azure的功能應用程序轉換爲使用「發佈一個.NET類庫的功能應用blog post從唐娜Malayeri預編譯的版本。預編譯Azure的功能StorageTableInput約束力不工作

我使用的定時器觸發器具有使用類型化對象的StorageTable輸入綁定。該對象繼承自'TableEntity'。雖然在門戶網站中的版本沒有任何問題,我的預編譯的版本引發以下錯誤:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ScheduleTrigger'. Microsoft.Azure.WebJobs.Host: GenericArguments[0], 'MyScheduler.Schedule', on 'Microsoft.Azure.WebJobs.Host.Tables.TableExtension+TableToIQueryableConverter`1[TElement]' violates the constraint of type 'TElement'. mscorlib: GenericArguments[0], 'MyScheduler.Schedule', on 'Microsoft.Azure.WebJobs.Host.Tables.TableExtension+TableToIQueryableConverter`1[TElement]' violates the constraint of type parameter 'TElement'. 

Azure的功能代碼如下所示:

using System; 
using System.Linq; 
using Microsoft.Azure.WebJobs; 
using Microsoft.Azure.WebJobs.Host; 
using Microsoft.WindowsAzure.Storage.Table; 

namespace MyScheduler 
{ 
    public class ScheduleTrigger 
    { 

     public static void Run(TimerInfo scheduleTimer, Queryable<Schedule> schedulesTable, ICollector<Schedule> scheduleQueueItem, TraceWriter log) 
     { 
      log.Info($"Start processing at: {DateTime.Now}."); 

      // processing code here... 

      log.Info($"Finished processing at: {DateTime.Now}."); 
     } 
    } 

    public class Schedule : TableEntity 
    { 
     public string Name { get; set; } 
     public DateTime LastRunAt { get; set; } 
     public bool Active { get; set; } 
     public string Endpoint { get; set; } 
    } 
} 

的「function.json」文件看起來像這樣:

{ 
    "scriptFile": "..\\bin\\MyScheduler.dll", 
    "entryPoint": "MyScheduler.ScheduleTrigger.Run", 
    "bindings": [ 
    { 
     "name": "scheduleTimer", 
     "type": "timerTrigger", 
     "direction": "in", 
     "schedule": "0 * * * * *" 
    }, 
    { 
     "type": "table", 
     "name": "schedulesTable", 
     "tableName": "schedules", 
     "partitionKey": "Schedules", 
     "connection": "AzureWebJobsStorage", 
     "direction": "in" 
    }, 
    { 
     "type": "queue", 
     "name": "scheduleQueueItem", 
     "queueName": "schedulesqueue", 
     "connection": "AzureWebJobsStorage", 
     "direction": "out" 
    } 
    ], 
    "disabled": true 
} 
+0

你引用了什麼版本的Storage SDK? –

回答

1

幾件事情:

  1. 確保您引用Azure存儲SDK 7.2.1或更低(理想情況下,7.2.1)
  2. 預編譯功能的最新型號,以飽滿的工具/ Visual Studio的集成,是記錄here。請考慮切換到。
+0

我沒有看到你的其他答案爲https://stackoverflow.com/questions/42284705/precompiled-azure-function-and-cloudtable-binding-output-doesnt-work但由於這不是'完全相同的問題,我沒有實際上嘗試一下。 –

+0

另外...答案是從一年多以前...你會期望這樣的事情現在可以解決 –

+0

很高興這有助於。移植到新版本並不是在一個小版本版本中完成的,所以在1.x版本中不會改變。 2.0預覽版使用最新版本,我們打算公開一種機制來緩解這一限制。 –