[英]Build&release Azure function to include function.json file
I am trying to configure a CI/CD pipeline for our version 1.x Azure function.我正在尝试为我们的 1.x Azure 功能配置 CI/CD 管道。 Azure function is triggered by Azure Service Bus and those configurations (topic and subscription) are in function.json file.
Azure 函数由 Azure 服务总线触发,这些配置(主题和订阅)在 function.json 文件中。 We have few installations of this Azure function and want need to change function.json file somehow in Azure DevOps during build/release.
我们很少安装此 Azure 函数,并希望在构建/发布期间需要在 Azure DevOps 中以某种方式更改 function.json 文件。
This is a "legacy work" so we don't have former CI/CD pipeline in Azure DevOps.这是一项“遗留工作”,因此我们在 Azure DevOps 中没有以前的 CI/CD 管道。 Earlier this has been deployed manually from Visual Studio.
早些时候,这是从 Visual Studio 手动部署的。 I have now configured build and release configurations to Azure DevOps but they are not working as I expect: files are not deployed like before.
我现在已经为 Azure DevOps 配置了构建和发布配置,但它们没有像我预期的那样工作:文件没有像以前那样部署。
Working version is deployed like this:工作版本是这样部署的:
wwwroot
| - bin
| | - dlls
| | - de, es, fr, etc. folders
| - MyFunction
| | - function.json
| - appsettings.json
| - host.json
| - packages.config
| - Web.config
Now my attempt to deploy from Azure DevOps deploys it like this:现在,我尝试从 Azure DevOps 进行部署是这样部署的:
wwwroot
| - dlls
| - host.json
| - de, es, fr, etc. folders
It has only "bin folder" and function.json file is missing.它只有“bin 文件夹”并且缺少 function.json 文件。
How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder?我应该如何在 Azure DevOps 中构建/部署 Azure 函数以像之前一样使用 function.json 文件和 bin 文件夹部署它? I have tried several different dotnet build and dotnet publish commands in build pipeline.
我在构建管道中尝试了几种不同的 dotnet build 和 dotnet publish 命令。 In release pipeline I have used Azure App Service Deploy task to deploy.
在发布管道中,我使用 Azure 应用服务部署任务进行部署。
How should I build/deploy Azure function in Azure DevOps to deploy it like earlier with function.json file and bin folder?
我应该如何在 Azure DevOps 中构建/部署 Azure 函数以像之前一样使用 function.json 文件和 bin 文件夹部署它?
I could deploy the Azure function correctly with Azure Devops CI/CD, the following is the detail steps:我可以使用 Azure Devops CI/CD 正确部署 Azure 功能,以下是详细步骤:
1.The build task yaml file is as following: 1.构建任务yaml文件如下:
queue:
name: Hosted VS2017
demands:
- msbuild
- visualstudio
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.3.0'
- task: NuGetCommand@2
displayName: 'NuGet restore'
- task: VSBuild@1
displayName: 'Build solution **\*.sln'
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: 'FunctionApp2\bin\debug\net461'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
The UI designer and project structs please refer to the screenshot. UI 设计器和项目结构请参考截图。
2.Released task information: I use [Deploy Azure App Service] task and choose the App type: Function App. 2.发布任务信息:我使用【部署Azure应用服务】任务,选择App类型:Function App。 More information please refer to the screenshot
更多信息请参考截图
Accidentally I solved this by myself.不小心我自己解决了这个问题。 I run Visual Studio Build task with following parameters:
我使用以下参数运行 Visual Studio Build 任务:
/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:SkipInvalidConfigurations=true
/p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)/package/"
/p:DeployIisAppPath="Default Web Site"
/p:OutputPath="$(build.artifactstagingdirectory)/out/"
DesktopBuildPackageLocation
builds it as I want to $(Build.ArtifactStagingDirectory)/package/WantedOutputPackage.zip
. DesktopBuildPackageLocation
按照我想要的方式构建它$(Build.ArtifactStagingDirectory)/package/WantedOutputPackage.zip
。 Then I publish that package as an artifact.然后我将该包作为工件发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.