2017-09-26 39 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预览版使用最新版本,我们打算公开一种机制来缓解这一限制。 –