c# - 在 Azure Function 中使用新的 SaaS 表适配器

标签 c# azure azure-functions

Azure 最近发布了适用于 Azure 功能的 SaaS 表适配器。我知道这个功能是实验性的,没有文档,但我正在尝试看看是否有人可以使用此功能。

我的绑定(bind)(function.json):

{
  "bindings": [
    {
      "name": "data",
      "type": "blobTrigger",
      "direction": "in",
      "path": "somePathToBlob",
      "connection": "connectionName_STORAGE"
    },
    {
      "type": "apiHubTable",
      "name": "output",
      "connection": "sql_SQL",
      "direction": "out",
      "tableName": "tblEventStage"
    }
  ],
  "disabled": false
}

然后在 run.csx 中我有:

public static void Run(string data, ITable<EventRecord> output, TraceWriter log)
{
    // add some records to the table
}

函数编译成功,然后弹出警告消息:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessAppInsights'. Microsoft.Azure.WebJobs.Extensions.ApiHub: The attribute ApiHubTableAttribute indicates a table binding. The parameter type must be one of the following: Microsoft.Azure.ApiHub.ITable, Microsoft.Azure.WebJobs.IAsyncCollector. To bind to a table client do not specify a table name. To bind to an entity specify the entity identifier.

我做错了什么?

最佳答案

找到了解决方案 - 我使用 System.Data.Linq ITable 而不是 Microsoft.Azure.ApiHub 中的 ITable。我删除了 System.Data.Linq 并添加了 nuget 包 Microsoft Azure ApiHub SDK。这需要添加一个文件package.json:

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "Microsoft.Azure.ApiHub.Sdk": "0.6.10-alpha"
      }
    }
   }
}

可以使用以下方法将记录插入到表中:

output.CreateEntityAsync(record);

关于c# - 在 Azure Function 中使用新的 SaaS 表适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40074839/

相关文章:

azure - WebApi 自定义日志和 Azure 存储

azure-functions - 如何使用功能应用程序托管身份更新 Key Vault 中的 secret

azure - 如何在请求/响应模式下使用 Azure 存储队列?

c# - 使用 SmtpClient 时为 "The operations timed out"

c# - 我需要有关使用 linq 的帮助

c# - 'CompanyName.Foo' 是一个 'namespace' 但像 'type' 一样使用

c# - Azure Durable Function 中的 IoC 发生在哪里?

c# - asp.net core 2.1模型绑定(bind)(提交后)

asp.net-mvc - 部署 Azure 云服务的奇怪行为

azure - Microsoft Lync 能否在 Windows Azure 虚拟机角色上运行?