Les*_*zek 2 c# azure azure-table-storage azure-functions
我正在从Azure功能中读取表存储中的数据.我在表存储绑定中创建了HttpTrigger函数.项目正在使用存储包:
"WindowsAzure.Storage": "8.0.0"
Run Code Online (Sandbox Code Playgroud)
和绑定:
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in"
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "metadataTable",
"type": "table",
"direction": "in",
"tableName": "metadata",
"connection": "StorageConnectionString",
"partitionkey": "some_partition_key"
}
],
"disabled": false
}
Run Code Online (Sandbox Code Playgroud)
拥有模板生成的代码我添加了新参数:
#r "Microsoft.WindowsAzure.Storage"
using System;
using System.Net;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req,
IQueryable<MetadataTable> metadataTable, TraceWriter log)
{
.....
}
public class MetadataTable: TableEntity
{
public MetadataTable():base() { }
public MetadataTable(string partitionkey, string rowkey):base(partitionkey,rowkey) {}
public string Data { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在保存和运行过程中,我收到编译错误:
Microsoft.Azure.WebJobs.Host:错误索引方法'Functions.HttpTriggerCSharp1'.Microsoft.Azure.WebJobs.Host:GenericArguments [0],'Submission#0 + MetadataTable','Microsoft.Azure.WebJobs.Host.Tables.TableAttributeBindingProvider + TableToIQueryableConverter
1[TElement]' violates the constraint of type 'TElement'. mscorlib: GenericArguments[0], 'Submission#0+MetadataTable', on 'Microsoft.Azure.WebJobs.Host.Tables.TableAttributeBindingProvider+TableToIQueryableConverter1 [TElement]'违反了类型参数'TElement'的约束.
任何人都可以帮我这个或遇到同样的错误?
错误消息看起来有点奇怪,但尝试WindowsAzure.Storage从project.json文件中删除引用.此包由运行时自动引用,如果明确包含它,则会因版本不匹配而出现各种错误.
我从您的代码创建了一个干净的Azure函数,没有包引用,它编译和工作得很好.尝试相同.
| 归档时间: |
|
| 查看次数: |
1126 次 |
| 最近记录: |