gpt4 book ai didi

azure-functions - Dotnet Isolated Azure Function w/.Net 6 在 Linux 消费计划上提示 6.0 AspNetCore.App Runtime 不可用

转载 作者:行者123 更新时间:2023-12-05 04:39:09 36 4
gpt4 key购买 nike

我需要一些帮助来确定为什么部署到 Linux 消费计划的 Azure Functions 无法启动并提示 AspNetCore.App 运行时不可用:

Application Insights logs

我不太明白的是为什么这会引用 RC2。我们已将问题隔离到包依赖项 (StackExchange.Redis.Extensions.AspNetCore"Version="7.2.1") - 如果我们包含它,它会破坏 Azure 中部署的功能。

查看该依赖项的来源,似乎他们所做的只是引用 AspNetCore.App 框架引用,如下所示:

https://github.com/imperugo/StackExchange.Redis.Extensions/blob/master/src/aspnet/StackExchange.Redis.Extensions.AspNetCore/StackExchange.Redis.Extensions.AspNetCore.csproj

请注意,我们的 Azure Functions 能够使用相同的项目引用(相同库的 6.x 版本)运行 .Net 5 而不会出现任何问题。

我们正在使用 CLI 来创建和部署函数,如下所示:

构建:

        - task: UseDotNet@2
inputs:
version: $(dotNetVersion)
displayName: Set DotNet Version $(dotNetVersion)

- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/xyz.Function.OurFunction.csproj'
arguments: '--configuration $(buildConfiguration) --output $(System.DefaultWorkingDirectory)/func_api'
displayName: 'Build Function'

函数应用创建:

az functionapp create --name $(functionAppName)
--resource-group $(rg) --consumption-plan-location $(region)
--functions-version 4 --os-type Linux --runtime dotnet-isolated
--storage-account $(funstorageAccountName) --assign-identity '[system]'

部署:

          - task: AzureFunctionApp@1
inputs:
azureSubscription: '$(azureSubscription)'
appType: 'functionAppLinux'
appName: '$(functionAppName)'
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
deploymentMethod: 'zipDeploy'
runtimeStack: 'DOTNET-ISOLATED|6.0'
appSettings: >-
-FUNCTIONS_WORKER_RUNTIME dotnet-isolated

最佳答案

以下是我在特定案例中如何解决这个史诗般的问题。
在 .csproj 属性中有 <TargetFramework>net5.0</TargetFramework><AzureFunctionsVersion>v3</AzureFunctionsVersion> .
构建管道使用 Pool: Azure PipelinesImage: ubuntu-latest .

我遇到的第一个问题是 Azure Function App Deploy 发布管道任务试图部署 ZIP 工件。即使这是 Microsoft 的建议,这也会无限期挂起。因此之前有一个Extract files任务,解压$(System.DefaultWorkingDirectory)/func/drop/Functions.zip$(Agent.TempDirectory)/func . func在我的案例中是工件源别名。

恕我直言,Azure Function App Deploy任务已过时。
默认情况下,您可能选择的最新运行时堆栈是 DOTNET|3.1 (functionapp v3) .
然后,在任务日志中,有人注意到:
Trying to update App Service Application settings.
Data:{"FUNCTIONS_WORKER_RUNTIME":"dotnet","WEBSITES_ENABLE_APP_SERVICE_STORAGE":"true"} .
这是非常出乎意料的,因为我们使用的是进程外模型。
此外,启动命令为空
试过 func azure functionapp publish $(functions-app-name) --no-bundlerdotnet functions.dll无济于事。

msdocs 链接如下:
运行的功能和行为差异 on out-of-process compared to .NET class library functions running in-process
.NET 独立项目 guide
说明书 version updates on Linux

因此,在部署之后,有一个 Azure App Service Settings 任务设置 "FUNCTIONS_WORKER_RUNTIME":"dotnet-isolated" .

那么救星就是this guide .

[!NOTE] To be able to publish your isolated function project to either a Windows or a Linux function app in Azure, you must set a value of dotnet-isolated in the remote FUNCTIONS_WORKER_RUNTIME application setting. To support zip deployment and running from the deployment package on Linux, you also need to update the linuxFxVersion site config setting to DOTNET-ISOLATED|6.0.

报告部署成功,函数应用程序显示 Function host is not running.

当我运行 az functionapp config show --name $(functions-app) --resource-group $(rg) --query 'linuxFxVersion' -o tsv我得到了 DOTNET|3.1

我也是 az functionapp config set --name $(functions-app) --resource-group $(rg) --linux-fx-version 'DOTNET-ISOLATED|5.0'因为我的目标是 netcore5。这修复了所有问题,并在发布管道中部署后成为 Azure CLI 任务。

关于azure-functions - Dotnet Isolated Azure Function w/.Net 6 在 Linux 消费计划上提示 6.0 AspNetCore.App Runtime 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70466876/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com