我正在尝试拥有一个部署管道,该管道可以同时部署 3 个 Azure WebJobs(连续),它们都是同一解决方案的一部分。我可以通过右键单击部署在 Visual Studio 中执行此操作,并确保我没有清除现有文件。
在 Azure Pipelines 中,我有以下脚本可成功用于单个 WebJob 部署。
但是,如果我复制它并为我的第二个 WebJob 创建一个新管道,它将替换现有的 WebJob,只留下 1 个运行。
我应该在下面的管道中修改什么来构建/部署所有 3 个 WebJobs?
trigger: none
pool:
vmImage: ubuntu-latest
# Modify these variables
variables:
webJobName: 'My.WebJob.App'
azureAppServiceName: 'my-webjobs'
azureSPNName: 'MyRGConnection' #get it from your AzureDevOps portal
buildConfiguration: 'Release'
dotNetFramework: 'net6.0'
dotNetVersion: '6.0.x'
targetRuntime: 'win-x86'
# Build the app for .NET 6 framework https://www.tiffanychen.dev/Azure-WebJob-Deployments-YAML/
steps:
- task: UseDotNet@2
inputs:
version: $(dotNetVersion)
includePreviewVersions: true
displayName: 'Build .NET 6 Application'
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: false
arguments: '--configuration $(BuildConfiguration) --framework $(dotNetFramework) --runtime $(targetRuntime) --self-contained --output $(Build.ArtifactStagingDirectory)/WebJob/App_Data/jobs/continuous/$(webJobName)'
zipAfterPublish: false
modifyOutputPath: false
projects: '$(webJobName)/$(webJobName).csproj'
# Package the file and uploads them as an artifact of the build
- task: PowerShell@2
displayName: Generate run.cmd For WebJob
inputs:
targetType: 'inline'
script: '"dotnet $(WebJobName).dll" | Out-File run.cmd -Encoding ASCII; $LASTEXITCODE'
pwsh: true
workingDirectory: '$(Build.ArtifactStagingDirectory)/WebJob/App_Data/jobs/continuous/$(webJobName)'
- task: ArchiveFiles@2
displayName: Zip Desired Files
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/WebJob/'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(webJobName).zip'
replaceExistingArchive: true
- task: PublishPipelineArtifact@1
displayName: Publish All Artifacts
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
publishLocation: 'pipeline'
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifact'
inputs:
path: '$(System.ArtifactsDirectory)'
- task: AzureWebApp@1
inputs:
azureSubscription: $(azureSPNName) #this is the name of the SPN
appType: 'webApp'
appName: $(azureAppServiceName) #App Service's unique name
package: '$(System.ArtifactsDirectory)/$(webJobName).zip'
deploymentMethod: 'zipDeploy'