Reputation: 637
Hello Experts, I have been trying to find an answer to this, can Azure DevOps support deployment to multiple Azure Subscription that have different Azure AD tenants?
Upvotes: 1
Views: 10780
Reputation: 329
I tried the tutorials Levi Lu-MSFT posted but there is still a lot of disconnect between the steps and terminology on the Azure AD side and the fields Azure DevOps wants. I found the steps in the following link to work with minimal headache. The lab tells you which Azure Service Principal fields are the fields DevOps wants.
https://azuredevopslabs.com/labs/devopsserver/azureserviceprincipal/
Upvotes: 0
Reputation: 3050
Just add an additional task (or any number of tasks for any number of subscriptions).
For example, say, you have two Service Connections (which have the necessary subscription level or app level or resource level permissions already set in your project settings).
Also, I am assuming you already know how to create Service Connection and use it in your project, and deploying a simple web app.
Your YAML (again, assuming you are using YAML) would look something like this
- task: AzureWebApp@1
inputs:
displayName: 'deploying to first subscription'
azureSubscription: 'ServiceConnectionForFirstSubscription1'
appName: 'ReactJSRecipeAppSep232020'
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
- task: AzureWebApp@1
inputs:
displayName: 'deploying to second subscription'
azureSubscription: 'ServiceConnectionForFirstSubscription2'
appName: 'ReactJSRecipeAppSep232020'
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
note - check Levi Lu-MSFT answer, for the links, which show how to create service connection, if you dont know how to do that.
Upvotes: 0
Reputation: 30373
The answer is Yes. you can deploy to multiple Azure Subscription in Azure devops. You just need to create multiple Azure Resource Manager service connections for these Azure subscriptions in Azure devops.
See the document to Create an Azure Resource Manager service connection with an existing service principal
You first need to create a service principle in each of these azure subscription. See below tutorial.
Or Create an Azure service principal with Azure PowerShell
Then Go to Azure devops Project settings-->Service Connections-->New service connection-->Select Azure resource Manager-->Choose Service principal (manual) as Authentication method--> Enter the Subscription Id, Service Principal Id(client id), Service principal key(client secret) and tenant id of the Service Principal created above.
Then you can select which azure subscription you want to deploy to in the azure deployment tasks in the pipeline.
Upvotes: 8