无法通过 CLI 命令部署 Azure Function ZIP 文件

问题描述 投票:0回答:1

我使用

HTTP Trigger
开发了带有私有端点(禁用公共访问)的azure功能。
由于函数的入站流量,存储通过互联网访问被切断,我通过构建(CI)管道将我的ZIP发布到存储帐户(链接到函数应用程序并启用公共的存储的新创建部分)并获取相同的ZIP文件在发布管道中进行部署。

ZIP_URL:我可以看到日志中附加有 SAS 令牌的 ZIP URL。

我尝试了以下在

.NET Core C#

中进行 ZIP 部署的命令,但没有一个对我有帮助。所以我尝试在我的机器上本地运行并遇到不同的问题,分别如下所示。

命令1:

Azure CLI Task

命令2:

az webapp deployment source config-zip --name demo-funcapp-test --resource-group osh-poc-rg --src $ZIP_URL

命令3:

az functionapp deployment source config-zip -g osh-poc-rg -n demo-funcapp-test --src $ZIP_URL

命令4:

az webapp deploy --name demo-funcapp-test --resource-group osh-poc-rg --type zip --src-url $ZIP_URL --async false

更新:

使用与功能应用程序相同的 VNET 创建 VM 并将代理修改为自主机后,我成功部署,但功能未在 Azure 门户中显示。

.net-core azure-functions azure-storage azure-cli azure-private-link
1个回答
0
投票

问题出在通过 CI 管道构建的 zip 文件中。 zip 文件夹结构不正确。

问题修复之前的 ZIP 文件和文件夹结构:

azure 函数应用程序代码文件位于从构建管道下载 build.zip 工件的 az rest --method PUT --uri https://management.azure.com/subscriptions/55555c7b-1f7a-43a1-a90f-dee45a2f6262/resourceGroups/osh-poc-rg/providers/Microsoft.Web/sites/demo-funcapp-test/extensions/onedeploy?api-version=2022-03-01 --body "{'properties': {'type': 'zip','packageUri': '${ZIP_URL}' }}" 文件夹中,如下面的屏幕截图所示。

Azure CLI 任务无法解析和部署 ZIP 文件,我在发布日志文件中看到以下日志信息。

build

对 CI 管道所做的更改:

使用

Bad Request({"error":{"code":"BadRequest","message":"System.ArgumentException: Invalid '/home/azureadminuser/myagent/_work/r1/a/_POCPrivateEndpoints-CI/drop/build.zip' packageUri in the JSON request\r\n at Kudu.Services.Deployment.PushDeploymentController.<PushDeployAsync>d__16.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Services\\Deployment\\PushDeploymentController.cs:line 474"}})

,确保其中没有

Pipeline Copy file task
文件夹。

下一步 在存档文件任务中我将

build

修改为

rootFolderOrFile
它的效果就像冠军一样:)

© www.soinside.com 2019 - 2024. All rights reserved.