The best VPN 2024

The Best VPS 2024

The Best C# Book

How to use Azure DevOps to connect to Azure services across accounts

How to use Azure DevOps to connect to Azure services across accounts?

Azure DevOps to connect to Azure services across accounts

Since the private projects in the newly applied Azure DevOps account do not enjoy the 1800 minutes of free time provided by the hosting agent and do not want to spend money, we can only think of another version to solve the problem of no parallel operations.

Change in Azure Pipelines Grant for Private Projects

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

Therefore, we can only use the old Azure DevOps to connect to the subscription of the new Azure account. Through my investigation. The association between Azure DevOps and Azure is that you can manually manage Service connections on Azure DevOps. That being the case, we tried to manually manage the service connection of type “Azure Resource Manager”.

Second, the text

1. Create an available Service Principal and set its permissions

1.1, create a service principal

  The way to create Service Principal (service principal), I have talked about before, you can log in to Azure through Azure CLI, use  az sp create ……. to create, you can also create manually, today we manually demonstrate How to create a Service Principal.

First, we log in to Azure Portal, register the application on Azure Active Directory, and click “Azure Active Directory” on the left menu of the homepage

873178942
How to use Azure DevOps to connect to Azure services across accounts

Select “Manage=》App registrations” and click “+ New registration” pointed by the arrow

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

Enter the display name “Allen_ServiceConnection” and click “Register”

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

After the creation is complete, you can jump to the currently registered application page. Next, we need to create a password for the current application

Select “Manage=”Certificates & secrets”, click “+ New client secret”

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

In the add client key page, we need to enter the relevant parameters

Description: “Allen_ServiceConnection_Secret”

Expires: “24 months” (you can choose the expiration time according to your actual situation)

Click “Add”

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

After the creation is complete, we copy the value of the client key of the current application as soon as possible (remember). Once the page is refreshed and switched to the current page, we can no longer copy the value of the key.

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

1.2, set the permissions of the Service Principal

We all know that when using the Azure CLI to create an sp, the role given is ” Contributor ” and the scope is ” current subscription “. Similarly, we also need to manually add corresponding permissions for the current application

Find the current subscription, select “Access control”, switch to “Role assignments”, click “+Add”

How to use Azure DevOps to connect to Azure services across accounts

Click “Add role assignment”

How to use Azure DevOps to connect to Azure services across accounts
How to use Azure DevOps to connect to Azure services across accounts

Enter the relevant role assignment parameters

Role selection:’Contributor’

Assign access to: “User,group,or service principal”

Select input: “Allen_ServiceConnection”, and select the current member

Click “Save” to save

345720857
How to use Azure DevOps to connect to Azure services across accounts 25

At the same time, we can see the added information on the current role assignment page

476904908
How to use Azure DevOps to connect to Azure services across accounts 26

2. Create a Service connection in Azure DevOps

We try to create a new project “CnBateBlog_Test” and click on “Project Settings” in the lower left corner

1744019305
How to use Azure DevOps to connect to Azure services across accounts 27

Find “Pipeline=”Service connections” and click “Create service connection”

1358272608
How to use Azure DevOps to connect to Azure services across accounts 28

Select “Azure Resource Manager” and click “Next”

1883587929
How to use Azure DevOps to connect to Azure services across accounts 29

Authentication method (authentication method) Select “Service principal (manual)”, click “Next”

941474743
How to use Azure DevOps to connect to Azure services across accounts 30

What everyone needs to pay attention to is that if you choose your Azure environment, if you are the same as me, then you can choose the same “Azure Cloud” as me.

569760716
How to use Azure DevOps to connect to Azure services across accounts 31

Next, you need to enter the information of the Service Pricipal just created

Scop Level selection: “Subscription”

Subscription Id: ” xxxxxxxx ” (own subscription ID)

Subscription Name: ” Visual Studio Enterprise ” (enter your own subscription name)

Service Principal Id Enter the Id of the App just registered in Azure Active Directory

Credential selection: “Service principal key”

1663941061
How to use Azure DevOps to connect to Azure services across accounts 32

Service principal key is the Client Screct of the application just created

Tenant ID: “The tenant id of the current sp”

After entering the information of sp, we can first click “Verify” to verify it, and then enter other parameters if there is no problem

Service connection name: “Allen_ServiceConnection”

Click “Verify and save” ( before saving, we have to ensure that the information of sp manually entered is correct )

696074393
How to use Azure DevOps to connect to Azure services across accounts 33

After verifying and saving, we can see the manually created Service connection 

401746754
How to use Azure DevOps to connect to Azure services across accounts 34

3. Verify the availability of Service connection

The test item is still  CnBateBlogWeb

Create a Release Pipeline in Azure DevOps and set related parameters

1194835625
How to use Azure DevOps to connect to Azure services across accounts 35

Remember to configure App Settings information, and finally click “Create release”

1375374894
How to use Azure DevOps to connect to Azure services across accounts 36

After waiting for the deployment to complete, we first check the deployment status

700971912
How to use Azure DevOps to connect to Azure services across accounts 37

And copy the URL of “cnbateblogweb01” and try to access in the browser

1105502866
How to use Azure DevOps to connect to Azure services across accounts 38

The visit is successful! ! !

1424703013
How to use Azure DevOps to connect to Azure services across accounts 39

Three, the end

Reference material: Azure Pipeline , management service link

github: https://github.com/yunqian44/CnBateBlogWeb

Author: Allen.

Reference: https://www.cnblogs.com/AllenMaster/p/14639395.html

Leave a Comment