延續 Day22 整合CI測試到 Azure Pipeline 服務章節,
專案完成CI之後,要部署到Azure的webapp服務,完成CD的步驟。
部署Azure Resource Manager Template Deployment
Azure Resource Group Deployment task 任務參數說明
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '免費試用版(8e1f4e59-3bf5-436c-9310-9edd39e3d593)'
subscriptionId: '8e1f4e59-3bf5-436c-9310-9edd39e3d593'
action: 'Create Or Update Resource Group'
resourceGroupName: 'PellokIThomePipelineRG'
location: 'East Asia'
templateLocation: 'Linked artifact'
csmFile: 'azuredeploy.json'
csmParametersFile: 'azuredeploy.parameters.prod.json'
deploymentMode: 'Incremental'
deploymentName: 'DeployPipelineTemplate'
displayName: 'Azure Resource Manager'
增加打包專案檔為zip 檔案
Archive Files task 任務參數說明
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/PellokITHome/bin/Release/netcoreapp3.1/'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(System.DefaultWorkingDirectory)/$(buildConfiguration).zip'
replaceExistingArchive: true
displayName: 'ArchiveFile $(buildConfiguration)'
將打包好的 zip 檔 部署到 Webapp
Azure Web App task 任務參數說明
- task: AzureWebApp@1
inputs:
azureSubscription: '免費試用版(8e1f4e59-3bf5-436c-9310-9edd39e3d593)'
appType: 'webAppLinux'
appName: 'contosowebapppjzohlzgqaho4'
package: '$(System.DefaultWorkingDirectory)/$(buildConfiguration).zip'
runtimeStack: 'DOTNETCORE|3.1'
startUpCommand: 'dotnet PellokITHome.dll'
displayName: 'Azure WebApp deploy $(buildConfiguration)'
檢查 Azure Pipeline 各步驟
檢查 Azure WebApp
上一篇 Day24 實作 Azure Resource Manager 範本與 Azure Pipelines 的持續整合
下一篇 Day26 Azure Container Registry (ACR)服務