How to publish a compiled app from Azure DevOps to a non-Azure Global environment, such as Azure CN.

Publishing an app from Azure DevOps to Azure Global is very easy. With just a few clicks, you can locate your Azure subscription and publish it within a minute. As shown here:

However, in some cases, our customers may be using other Azure environments, such as Azure Arc, Azure for Government, or Azure CN. In these scenarios, it can be difficult to find our subscriptions easily through the pipeline configuration. How can we publish our app to our non-Global Azure environment?

First, we need to create a new app registration. Then, we must allow Azure DevOps to publish apps using this app registration as the identity.

Click your Azure Active Directory menu here:

Click here to add a new registration:

Next, name your new app Azure DevOps. Select the access accounts within this organization.

After creating your new app registration, remember to copy your application ID here:

Add a new secret, and copy the secret value here:

These steps created a new app in your directory. Anyone with the app ID and app secret can access your directory. However, the app is not yet authorized to access your Azure resources. We need to assign the app a subscription-level role that allows it to manage your resources under the subscription.

Click on Subscriptions and select the subscription you want to deploy to.

Add a new role assignment.

And add it as a contributor.

Now, the steps in the Azure portal are completed. We can add a new service connection in Azure DevOps now.

After signing in to your Azure DevOps, click the project settings. Then select service connections:

Click here to add a new service connection:

Select the Azure resources manager:

Select the manual config. If you select the automatic config, it only shows the subscriptions from Azure global.

Select your customized Azure environment name. For example, I am configuring a connection for Azure CN. Click Azure China Cloud here.

Now fill the subscription ID and subscription name. Those values you can find in your subscription details tab.

Find those values here:

To fill the service principal id and key, just paste your new registered app's application id and secret value.

And for the tenant id, this comes from your Azure AD details page.

Find tenant ID here:

After filling in all the values above, click the verify and save buttons.

Now you can work on your pipeline and publish your app to this service connection: