Kru*_*lur 3 c# azure azure-functions
我正在尝试在 Visual Studio 2019 中运行 HTTP 触发的 v2 函数。它应该将其输出写入名为“history”的 Azure 存储表中。
我装饰了一个我的功能
[return: Table("history")]
我让它返回TableEntity.
这会导致“无法将 Table 绑定到 CloudTable”的异常。异常的原因是CloudStorageAccount客户端代码中的检查:
bool bindsToEntireTable = tableAttribute.RowKey == null;
if (bindsToEntireTable)
{
// This should have been caught by the other rule-based binders.
// We never expect this to get thrown.
throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'.");
}
Run Code Online (Sandbox Code Playgroud)
另一个函数绑定到 aCloudTable作为输入参数并遭受相同的异常。
虽然绑定到CloudTable应该工作(https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#input---c-example---cloudtable)它显然没有.
这是 Azure 存储客户端 SDK 中的错误还是我做错了什么?我正在引用这些 Nuget 包:
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
Run Code Online (Sandbox Code Playgroud)
问题是两个 Nuget 包的版本不匹配。创建新解决方案时,我无法复制问题并绑定到CloudTable工作正常。与我的解决方案相比,我的函数项目引用了另一个依赖于
WindowsAzure.Storage (9.3.3)
因为我需要TableEntity那里的类型。
现在它变得棘手了。功能项目有参考
Microsoft.Azure.WebJobs.Extensions.Storage (3.0.6)
WindowsAzure.Storage (9.3.1)
9.3.3 和 9.3.1 的版本差异导致绑定问题。解决方案是在引用的项目中降级到 9.3.1
或者
或者(可能推荐):WindowsAzure.Storage从引用的项目中删除并将其替换为Microsoft.Azure.Cosmos.Table也包含TableEntity. 重要的是不要将其与Microsoft.Azure.CosmosDB.Table已弃用的(注意“DB”)混淆。不幸的是, 的评论WindowsAzure.Storage (9.3.3) 告诉我们更改为完全不正确的 package。
脑震荡:这是一团糟:-)
| 归档时间: |
|
| 查看次数: |
2211 次 |
| 最近记录: |