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/