Azure Functions Core Tools 无法安装绑定(bind)所需的扩展

标签 azure azure-functions azure-functions-core-tools

我尝试在本地运行 Azure Function (JavaScript),但在 func start 时失败,并出现以下错误。

AddConfig: The binding type(s) 'table' are not registered. Please ensure the type is correct and the binding extension is installed.

请注意,我已经成功安装了先决条件,在当时或撰写本文时,这些先决条件是.NET Core 2.1Node.JS核心工具 包。

从上面的错误可以明显看出,我已将表的输出绑定(bind)添加到名为“AddConfig”的函数的 function.json 中。我按照 documentation 添加了绑定(bind).

有人可以就我可能缺少的内容提出建议吗?

我尝试过的事情

遵循文档

我按照 documentation 在项目文件夹中运行了以下命令.

安装功能扩展

这产生了以下输出 -

Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\super-secret-path\WitchHunt\AddConfig\extensions.csproj...
  Generating MSBuild file C:\super-secret-path\WitchHunt\AddConfig\obj\extensions.csproj.nuget.g.props.
  Generating MSBuild file C:\super-secret-path\WitchHunt\AddConfig\obj\extensions.csproj.nuget.g.targets.
  Restore completed in 314.99 ms for C:\super-secret-path\WitchHunt\AddConfig\extensions.csproj.
  extensions -> C:\super-secret-path\WitchHunt\AddConfig\bin\extensions.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.66

该命令还导致将 extensions.csproj 添加到项目中,内容如下 -

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <WarningsAsErrors></WarningsAsErrors>
    <DefaultItemExcludes>**</DefaultItemExcludes>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.1" />
  </ItemGroup>
</Project>

定位所需的扩展

我尝试使用以下命令手动安装扩展。虽然此操作有效并导致包引用被添加到 extensions.csproj 中,但重新运行该函数会导致相同的错误。

func extensions install --package Microsoft.Azure.WebJobs.Extensions.Storage --version 3.0.3

在门户上创建绑定(bind)并复制“extensions.csproj”

标题确实说明了一切。我创建了一个函数应用程序,添加了一个函数,创建了一个绑定(bind),安装了扩展,然后复制/粘贴了extensions.csproj,但错误仍然存​​在。

我的function.json,以防有人感兴趣

httpTriggerhttp 绑定(bind)是我创建函数时生成的,而 table 绑定(bind)是从文档复制的(然后我更改了 tableNameconnection 属性,但我认为这不是问题)。

{
    "disabled": false,
    "bindings": [
        {
            "authLevel": "function",
            "type": "httpTrigger",
            "direction": "in",
            "name": "req",
            "methods": [
                "get",
                "post"
            ]
        },
        {
            "type": "http",
            "direction": "out",
            "name": "res"
        },
        {
            "tableName": "WitchHuntConfig",
            "connection": "AzureWebJobsStorage",
            "name": "tableBinding",
            "type": "table",
            "direction": "out"
        }
    ]
}

最佳答案

func extensions install --package Microsoft.Azure.WebJobs.Extensions.Storage --version 3.0.3 应该修复,尝试删除 bin obj 文件夹,然后运行此再次命令。

func extensions install 并不是没有用,关键是绑定(bind)类型 table 不在 BindingPackageMap 中。因此未安装扩展。已开通issue进行跟踪。

关于Azure Functions Core Tools 无法安装绑定(bind)所需的扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54811096/

相关文章:

c# - Azure C# 函数中的 Appsettings.json 等效项

c# - 在 Azure Functions 中加载证书时出现运行时错误

azure - 无法在 VSCode 中调试 Azure Functions Core Tools

azure - Azure 中 Redis 缓存的一致超时

azure - 尝试访问已部署的函数时,KUDU 给出禁止错误 - 403

azure - 了解 WebJobs 如何运行

node.js - 使用 Alpine 部署 Azure Function - 未处理的 'error' 事件

web-services - Azure 应用服务的可用性警报

javascript - 如何使用Azure函数返回documentDB文档?

node.js - 运行azure函数时找不到mssql Node js包