运行时 2 的 Azure Functions;绑定扩展未自动创建 [英] Azure Functions with runtime 2; binding extensions not automatically created

查看:10
本文介绍了运行时 2 的 Azure Functions;绑定扩展未自动创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我基于 v2 运行时将我的 Azure Function 项目部署到我的 Function App 时,我的项目所依赖的绑定扩展(在我的例子中是 Azure 存储)不会自动创建.

When I deploy my Azure Function project to my Function App based on the v2 runtime, the binding extensions my project depend on (Azure Storage in my case), are not automatically created.

我在根目录上使用 extensions.csproj 文件部署我的项目,但部署后我必须手动运行以下命令以在 wwwroot 上创建 bin 和 obj 文件夹.

I deploy my project with an extensions.csproj file on the root, but after deploying I have to manually run the following command to create a bin and obj folder at wwwroot.

dotnet build extensions.csproj -o bin --no-incremental --packages D:home.nuget

如果我理解正确,这应该会自动发生.

If I understand correctly, this should happen automatically.

推荐答案

用于 CLI 部署 func azure functionapp publish

函数核心工具使用zip部署来部署函数,这样kudu不会构建项目默认.要启用该功能,请在门户的应用程序设置中将 SCM_DO_BUILD_DURING_DEPLOYMENT 设置为 true.

Function core tools use zip deployment to deploy functions, in this way, kudu doesn't build project by default. To enable the feature, set SCM_DO_BUILD_DURING_DEPLOYMENT to true in Application settings on portal.

至于为什么默认设置为false,zip部署通常需要部署的内容包括所有相关文件,因此无需重新构建.

As for why the default setting is false, zip deployment usually requires the content to be deployed including all related files hence there's no need to build again.

对于 Azure 功能核心工具,我们通常使用命令 func extensions install注册扩展 用于输入/输出绑定,当扩展没有自动安装时,就像我们从模板创建触发器一样.这就是为什么命令 func startfunc azure functionapp publish 不构建 extensions.csproj,扩展应该在我们运行之前安装或发布函数.

For Azure function core tools, we usually use command func extensions install to register extensions for input/output binding when extensions are not installed automatically like we create trigger from template. This is why command func start and func azure functionapp publish doesn't build extensions.csproj, extensions are supposed to be installed before we run or publish functions.

DevOps 部署更新

使用 Azure 管道,我们需要在归档文件之前构建 extensions.csporj.添加 .NET Core 构建任务,参数为 -o bin.

With Azure pipeline, we need to build extensions.csporj before archive files. Add a .NET Core build task, arguments are -o bin.

如果你想让 kudu 构建项目,请转到 Platform features 下的 Deployment Center.选择 VSTS 作为 CI 存储库,kudu 将为您构建和部署项目.

If you want kudu to build project, go to Deployment Center under Platform features. Choose VSTS as a CI repository and kudu will build and deploy project for you.

这篇关于运行时 2 的 Azure Functions;绑定扩展未自动创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆