There is not need to generate the web.config using az bot. Azure App Service deploy task can generate the web.config automatic. You can check out below examples.
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install and build'
#generate zip package using archivefile task.
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: 'Build.SourcesDirectory'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
#publish artifacts to azure devops server to be used in Release pipeline.
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
Please check out the example Build, test, and deploy JavaScript and Node.js apps for more information.
Before creating Release pipeline. You need to create an azure Resource Manager service connection to connect your Azure subscription to Azure devops. See this thread for an example.
Then you can create release pipeline, Add the artifacts published by above build pipeline as the pipeline Artifacts resource. And add stages. Using Azure App Service deploy task in the release pipeline.
You can configure the Azure App Service deploy task to generate web.config. Also see here for more information.
You can also check out the example in this blog.
Actually you can directly use the Azure App Service deploy in the build pipeline without creating release pipeline.
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: 'samples/javascript_nodejs/49.qnamaker-all-features'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: leviwebApp'
inputs:
azureSubscription: 'azure Resource Manager service connection'
WebAppName: leviwebApp
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
WebConfigParameters: '-Handler iisnode -NodeStartFile index.js -appType node'
Above method using build/release pipeline and deployment task is the general way to deploy to azure app service.
However, you can also write az cli commnads in the azure cli task in the build pipeline to deploy to azure app service. See below example:
....
- script: |
cd samples/javascript_nodejs/49.qnamaker-all-features
npm install
displayName: 'npm install and build'
- task: AzureCLI@2
inputs:
azureSubscription: 'azure Resource Manager service connection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'az bot prepare-deploy --code-dir "." --lang Javascript'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: 'Build.SourcesDirectory'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: AzureCLI@2
inputs:
azureSubscription: 'azure Resource Manager service connection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'az webapp deployment source config-zip --resource-group "<resource-group-name>" --name "<name-of-web-app>" --src "<project-zip-path>"'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…