gpt4 book ai didi

.net - 如何从 Devops 管道将 azure 函数发布到 Active Directory 中的 Azure Linux 函数

转载 作者:行者123 更新时间:2023-12-03 02:11:32 25 4
gpt4 key购买 nike

我正在尝试创建 DevOps 管道以在 Linux Function App 中发布 Azure Function 项目。这是我迄今为止制作的管道:

pool:
vmImage: ubuntu-latest

steps:
- task: UseDotNet@2
inputs:
version: '6.0.x'

- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: |
**/*.csproj

- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: |
**/*.csproj
arguments: '--configuration Release'

- task: ArchiveFiles@2
displayName: 'Archive Test'
inputs:
archiveType: 'zip'
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/Test.Company.API/bin/Release/net6.0/'
archiveFile: '$(System.DefaultWorkingDirectory)/Test.Company.API/bin/Release/net6.0/$(Build.BuildId).zip'

- task: AzureFunctionApp@1
displayName: 'Azure Function App Deploy - Test Company'
inputs:
azureSubscription: 'Test_Sub'
appType: 'functionAppLinux'
appName: 'test-company'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
runtimeStack: 'DOTNET|6.0'

这是我在上一个任务中看到的:

Got service connection details for Azure App Service:'test-company'
Trying to update App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"https://test.blob.core.windows.net/azure-pipelines-deploy/package_1659618746343.zip?***"}
Updated App Service Application settings.
Updated WEBSITE_RUN_FROM_PACKAGE Application setting to https://test.blob.core.windows.net/azure-pipelines-deploy/package_1659618746623.zip?***
Syncing triggers for function app
Sync triggers for function app completed successfully
Successfully added release annotation to the Application Insight : test_insights
App Service Application URL: https://test-company.azurewebsites.net
Finishing: Azure Function App Deploy - Test Company

但是,当我访问 Azure 目录中的 Azure 函数时,即使 DevOps 管道成功,函数也不会部署。

最佳答案

好的,我发现了问题。

我必须在ArchiveFiles@2下添加这一行

includeRootFolder: false

问题在于它正在创建一个包含根文件夹的 zip 文件,因此 host.json 位于 net6.0 内部,而不是根文件夹内。

我能够通过查看存储内的 zip 文件来了解问题。

我所做的另一项更改是发布应用程序而不是构建应用程序

以下是最终任务:

- task: DotNetCoreCLI@2
displayName: Publish
inputs:
projects: '$(System.DefaultWorkingDirectory)/Test.API/Test.API.csproj'
command: 'publish'
arguments: '--configuration Release --output publish'
publishWebProjects: false
zipAfterPublish: false
modifyOutputPath: false

- task: ArchiveFiles@2
displayName: 'Archive Test'
inputs:
includeRootFolder: false
replaceExistingArchive: true
archiveType: 'zip'
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish'
archiveFile: '$(System.DefaultWorkingDirectory)/Test.API/bin/Release/net6.0/$(Build.BuildId).zip'

- task: AzureFunctionApp@1
displayName: 'Azure Function App Deploy - Test'
inputs:
azureSubscription: 'Test_Sub'
appType: 'functionAppLinux'
appName: 'test'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
runtimeStack: 'DOTNET|6.0'

关于.net - 如何从 Devops 管道将 azure 函数发布到 Active Directory 中的 Azure Linux 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73237736/

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