通过 azure 管道单阶段将包部署到多个 webapp 服务

时间:2021-07-14 12:48:48

标签: azure azure-devops azure-web-app-service azure-pipelines

我在 azure 中有 100 多个 webapp 服务。我想通过带有一个管道 yml 文件的 azure 管道在 100 个 webapp 中部署包。但是我找不到任何这样的文档。我得到了一份微软文档,他们更喜欢增加管道步骤。如果我有 100 个 webapps 服务,则必须为每个部署添加 100 个步骤。这不是一种有效的方式,而且很耗时。我想要这一步。

- task: AzureWebApp@1
  displayName: 'Azure Web App Deploy'
  inputs:
    azureSubscription: '$(Parameters.connectedServiceName)'
    appType: webApp
    ResourceGroupName: $(group)
    appName: 'JustGoTestAgain, justgotesttwo, webapp123, webapp555, webapp777 and so on ........'
    package: '$(build.artifactstagingdirectory)/**/*.zip'

此 yaml 文件显示错误。我找不到任何必要的扩展来修复它。我也找不到任何有关此问题的 azure powershell 部署命令。我怎样才能得到解决方案?

1 个答案:

答案 0 :(得分:1)

您将无法像这样执行此操作。但是您可以使用 Azure Cli task:

- task: AzureCLI@2
  displayName: Azure CLI
  inputs:
    azureSubscription: '$(Parameters.connectedServiceName)'
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |

      $apps= @('JustGoTestAgain, justgotesttwo, webapp123, webapp555, webapp777 and so on ........')

      foreach ($app in $apps) {
         az webapp deployment source config-zip -g $(group) -n $app --src '$(build.artifactstagingdirectory)/SOME_FOLDER/Artifact.zip'
      }

这里有关于部署的更多详细信息itself

如果失败则多任务但继续的另一种方法是:

parameters:
- name: apps
  type: object
  default:
    - JustGoTestAgain
    - justgotesttwo
    - and so on

steps:
- ${{ each app in parameters.apps}}:
  - task: AzureWebApp@1
    displayName: 'Azure Web App Deploy ${{ app }}'
    continueOnError: true
    inputs:
      azureSubscription: '$(Parameters.connectedServiceName)'
      appType: webApp
      ResourceGroupName: $(group)
      appName: ${{ app }}
      package: '$(build.artifactstagingdirectory)/**/*.zip'



Thete 是空间问题。现在好了。除此之外,connectedServiceName

只有一个问题 <块引用>

作业作业:步骤输入 azureSubscription 引用了无法找到的服务连接 $(Parameters.connectedServiceName)。服务连接不存在或未被授权使用。有关授权详情,请参阅https://aka.ms/yamlauthz。作业:步骤输入 azureSubscription 引用了无法找到的服务连接 $(Parameters.connectedServiceName)。服务连接不存在或未被授权使用。有关授权详情,请参阅https://aka.ms/yamlauthz。作业:步骤输入 azureSubscription 引用了找不到的服务连接 $(Parameters.connectedServiceName)。服务连接不存在或未被授权使用。有关授权详情,请参阅https://aka.ms/yamlauthz

我在这里跳过了,因为您的解决方案中已经有了它。