• <legend id='qXrDV'><style id='qXrDV'><dir id='qXrDV'><q id='qXrDV'></q></dir></style></legend>
    <tfoot id='qXrDV'></tfoot>

    1. <i id='qXrDV'><tr id='qXrDV'><dt id='qXrDV'><q id='qXrDV'><span id='qXrDV'><b id='qXrDV'><form id='qXrDV'><ins id='qXrDV'></ins><ul id='qXrDV'></ul><sub id='qXrDV'></sub></form><legend id='qXrDV'></legend><bdo id='qXrDV'><pre id='qXrDV'><center id='qXrDV'></center></pre></bdo></b><th id='qXrDV'></th></span></q></dt></tr></i><div id='qXrDV'><tfoot id='qXrDV'></tfoot><dl id='qXrDV'><fieldset id='qXrDV'></fieldset></dl></div>
    2. <small id='qXrDV'></small><noframes id='qXrDV'>

        • <bdo id='qXrDV'></bdo><ul id='qXrDV'></ul>

        为什么 Azure Function v2 无法绑定到 CloudTable?

        时间:2023-10-25
      1. <legend id='QGjy1'><style id='QGjy1'><dir id='QGjy1'><q id='QGjy1'></q></dir></style></legend>
        <i id='QGjy1'><tr id='QGjy1'><dt id='QGjy1'><q id='QGjy1'><span id='QGjy1'><b id='QGjy1'><form id='QGjy1'><ins id='QGjy1'></ins><ul id='QGjy1'></ul><sub id='QGjy1'></sub></form><legend id='QGjy1'></legend><bdo id='QGjy1'><pre id='QGjy1'><center id='QGjy1'></center></pre></bdo></b><th id='QGjy1'></th></span></q></dt></tr></i><div id='QGjy1'><tfoot id='QGjy1'></tfoot><dl id='QGjy1'><fieldset id='QGjy1'></fieldset></dl></div>

        <small id='QGjy1'></small><noframes id='QGjy1'>

          • <bdo id='QGjy1'></bdo><ul id='QGjy1'></ul>

            <tfoot id='QGjy1'></tfoot>

                <tbody id='QGjy1'></tbody>

                  本文介绍了为什么 Azure Function v2 无法绑定到 CloudTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 Visual Studio 2019 中运行 HTTP 触发的 v2 函数.它应该将其输出写入到名为历史"的 Azure 存储表中.

                  I'm trying to run an HTTP triggered v2 function in Visual Studio 2019. It's supposed to write its output into an Azure Storage Table called "history".

                  我已经用我的函数装饰了一个

                  I've decorated one my functions with

                  [return: Table("history")]

                  我让它返回 TableEntity 的子类.

                  and I make it return a subclass of TableEntity.

                  这会导致无法将表绑定到 CloudTable"的异常.异常的原因是 CloudStorageAccount 客户端代码中的检查:

                  This results in an exception about it being "unable to bind Table to CloudTable". The reason for the exception is a check within the CloudStorageAccount client's code:

                  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 + "'.");
                  }
                  

                  另一个函数作为输入参数绑定到 CloudTable 并遇到相同的异常.

                  Another function binds to a CloudTable as an input parameter and suffers from the same exception.

                  虽然绑定到 CloudTable 应该可以工作(https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#input---c-example---cloudtable)它显然没有.

                  Although binding to CloudTable should work (https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#input---c-example---cloudtable) it apparently does not.

                  这是 Azure 存储的客户端 SDK 中的错误还是我做错了什么?我引用了这些 Nuget 包:

                  Is this a bug in the client SDKs for Azure Storage or am I doing something wrong? I'm referencing these Nuget packages:

                   <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" />
                  

                  推荐答案

                  问题是两个 Nuget 包的版本不匹配.在创建新解决方案时,我无法复制问题并且绑定到 CloudTable 工作得很好.与我的解决方案相比,我发现我的函数项目引用了另一个依赖于

                  The problem is a version mismatch of two Nuget packages. When creating a new solution I was unable to replicate the issue and binding to CloudTable worked just fine. Comparing to my solution revealed that my function project referenced another project which had a dependency on

                  WindowsAzure.Storage (9.3.3)

                  因为我需要 TableEntity 类型.

                  现在变得棘手了.函数项目引用了

                  And now it's getting tricky. The functions project has a reference to

                  Microsoft.Azure.WebJobs.Extensions.Storage (3.0.6)

                  并且依赖于

                  WindowsAzure.Storage (9.3.1)

                  9.3.3 和 9.3.1 的版本差异导致绑定问题.解决方案是在引用的项目中降级到 9.3.1

                  The version difference of 9.3.3 and 9.3.1 leads to the binding problems. The solution is to either downgrade to 9.3.1 in the referenced project

                  或者(并且可能推荐):从引用的项目中删除 WindowsAzure.Storage 并将其替换为还包含 TableEntity 的 Microsoft.Azure.Cosmos.Table.重要不要将此与已弃用的 Microsoft.Azure.CosmosDB.Table(注意DB")混淆.不幸的是,WindowsAzure.Storage (9.3.3) 的评论告诉我们更改为完全不正确的包.

                  alternatively (and probably recommended): remove WindowsAzure.Storage from the referenced project and replace it with Microsoft.Azure.Cosmos.Table which also contains TableEntity. Important do NOT confuse this with Microsoft.Azure.CosmosDB.Table (notice the "DB") which is being deprecated. Unfortunately, the comments for WindowsAzure.Storage (9.3.3) tell us to change to exactly that incorrect package.

                  脑震荡:一团糟 :-)

                  Concusion: it's a hot mess :-)

                  这篇关于为什么 Azure Function v2 无法绑定到 CloudTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    • <bdo id='ThcM7'></bdo><ul id='ThcM7'></ul>
                    • <legend id='ThcM7'><style id='ThcM7'><dir id='ThcM7'><q id='ThcM7'></q></dir></style></legend>

                    • <tfoot id='ThcM7'></tfoot>
                        <tbody id='ThcM7'></tbody>
                      <i id='ThcM7'><tr id='ThcM7'><dt id='ThcM7'><q id='ThcM7'><span id='ThcM7'><b id='ThcM7'><form id='ThcM7'><ins id='ThcM7'></ins><ul id='ThcM7'></ul><sub id='ThcM7'></sub></form><legend id='ThcM7'></legend><bdo id='ThcM7'><pre id='ThcM7'><center id='ThcM7'></center></pre></bdo></b><th id='ThcM7'></th></span></q></dt></tr></i><div id='ThcM7'><tfoot id='ThcM7'></tfoot><dl id='ThcM7'><fieldset id='ThcM7'></fieldset></dl></div>

                      <small id='ThcM7'></small><noframes id='ThcM7'>