Deploy packages to multiple webapp service by azure pipeline single stage

Viewed 216

I have more than 100 webapp service in azure. I want to deploy packages in 100 webapps by azure pipeline with one pipeline yml file. But I couldn't find any documentation like this. I got one microsoft documentation and they prefer to increase pipeline steps. If I have 100 webapps service, then have to add 100 steps for each deployment. This is not an efficient way and its time consuming. I want just like this step.

- 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'

This yaml file is showing error. I couldn't find any essential extensions to fix it. I also couldn't find any azure powershell deployment command regarding to this issue. How can I get the solution?

1 Answers

You will not be able to do this like this. However you can use 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'
      }

And here you have more details about deployment itself

Annother approach with multiple task bu continuation if one fail is:

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 was issue with space. Now is fine. Apart from that there is only one issue with connectedServiceName

Job Job: Step input azureSubscription references service connection $(Parameters.connectedServiceName) which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz. Job Job: Step input azureSubscription references service connection $(Parameters.connectedServiceName) which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz. Job Job: Step input azureSubscription references service connection $(Parameters.connectedServiceName) which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz.

Which I skipped here as you already have it on your solution.

Related