You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: Instructions/Labs/AZ400_M04_L10_Integrate_Azure_Key_Vault_with_Azure_DevOps.md
+17-81Lines changed: 17 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,22 +20,24 @@ Azure Key Vault provides secure storage and management of sensitive data, such a
20
20
In this lab, you will see how you can integrate Azure Key Vault with an Azure Pipelines by using the following steps:
21
21
22
22
- Create an Azure Key Vault to store a ACR password as a secret.
23
-
-Create an Azure Service Principal to provide access to secrets in the Azure Key Vault.
24
-
- Configure permissions to allow the Service Principal to read the secret.
23
+
-Provide access to secrets in the Azure Key Vault.
24
+
- Configure permissions to read the secret.
25
25
- Configure pipeline to retrieve the password from the Azure Key Vault and pass it on to subsequent tasks.
26
26
27
27
## Objectives
28
28
29
29
After you complete this lab, you will be able to:
30
30
31
-
- Create a Microsoft Entra service principal.
32
31
- Create an Azure Key Vault.
32
+
- Retrieve a secret from Azure Key Vault in an Azure DevOps pipeline.
33
+
- Use the secret in a subsequent task in the pipeline.
34
+
- Deploy a container image to Azure Container Instance (ACI) using the secret.
33
35
34
36
## Estimated timing: 40 minutes
35
37
36
38
## Instructions
37
39
38
-
### Exercise 0: Configure the lab prerequisites
40
+
### Exercise 0: (skip if done) Configure the lab prerequisites
39
41
40
42
In this exercise, you will set up the prerequisites for the lab, which consist of a new Azure DevOps project with a repository based on the [eShopOnWeb](https://github.com/MicrosoftLearning/eShopOnWeb).
41
43
@@ -70,69 +72,9 @@ In this task you will import the eShopOnWeb Git repository that will be used by
70
72
71
73
### Exercise 1: Setup CI pipeline to build eShopOnWeb container
72
74
73
-
Setup CI YAML pipeline for:
75
+
In this exercise, you will create a CI pipeline that builds and pushes the eShopOnWeb container images to an Azure Container Registry (ACR). The pipeline will use Docker Compose to build the images and push them to the ACR.
74
76
75
-
- Creating an Azure Container Registry to keep the container images
76
-
- Using Docker Compose to build and push **eshoppublicapi** and **eshopwebmvc** container images. Only **eshopwebmvc** container will be deployed.
77
-
78
-
#### Task 1: (skip if done) Create a Service Principal
79
-
80
-
In this task, you will create a Service Principal by using the Azure CLI, which will allow Azure DevOps to:
81
-
82
-
- Deploy resources on your Azure subscription.
83
-
- Have read access on the later created Key Vault secrets.
84
-
85
-
> **Note**: If you do already have a Service Principal, you can proceed directly to the next task.
86
-
87
-
You will need a Service Principal to deploy Azure resources from Azure Pipelines. Since we are going to retrieve secrets in a pipeline, we will need to grant permission to the service when we create the Azure Key Vault.
88
-
89
-
A Service Principal is automatically created by Azure Pipelines, when you connect to an Azure subscription from inside a pipeline definition or when you create a new Service Connection from the project settings page (automatic option). You can also manually create the Service Principal from the portal or using Azure CLI and re-use it across projects.
90
-
91
-
1. From the lab computer, start a web browser, navigate to the [**Azure Portal**](https://portal.azure.com), and sign in with the user account that has the Owner role in the Azure subscription you will be using in this lab and has the role of the Global Administrator in the Microsoft Entra tenant associated with this subscription.
92
-
1. In the Azure portal, click on the **Cloud Shell** icon, located directly to the right of the search textbox at the top of the page.
93
-
1. If prompted to select either **Bash** or **PowerShell**, select **Bash**.
94
-
95
-
> **Note**: If this is the first time you are starting **Cloud Shell** and you are presented with the **You have no storage mounted** message, select the subscription you are using in this lab, and select **Create storage**.
96
-
97
-
1. From the **Bash** prompt, in the **Cloud Shell** pane, run the following commands to retrieve the values of the Azure subscription ID and subscription name attributes:
98
-
99
-
```bash
100
-
az account show --query id --output tsv
101
-
az account show --query name --output tsv
102
-
```
103
-
104
-
>**Note**: Copy both values to a text file. You will need them later in this lab.
105
-
106
-
1. From the **Bash** prompt, in the **Cloud Shell** pane, run the following command to create a Service Principal (replace the **myServicePrincipalName** with any unique string of characters consisting of letters and digits) and **mySubscriptionID** with your Azure subscriptionId :
107
-
108
-
```bash
109
-
az ad sp create-for-rbac --name myServicePrincipalName \
110
-
--role contributor \
111
-
--scopes /subscriptions/mySubscriptionID
112
-
```
113
-
114
-
>**Note**: The command will generate a JSON output. Copy the output to text file. You will need it later in this lab.
115
-
116
-
1. Next, from the lab computer, start a web browser, navigate to the Azure DevOps **eShopOnWeb** project. Click on **Project Settings > Service Connections (under Pipelines)** and **New Service Connection**.
117
-
118
-

119
-
120
-
>**Note**: If there are no Service Connections previously created on the page, the service connection creation button is located in the center of the page and has the label **Create service connection**
121
-
122
-
1. On the **New service connection** blade, select**Azure Resource Manager** and **Next** (may need to scroll down).
123
-
124
-
1. Then choose **Service Principal (manual)** and click on **Next**.
125
-
126
-
1. Fill in the empty fields using the information gathered during previous steps:
127
-
- Subscription Id and Name.
128
-
- Service Principal Id (appId), Service principal key (password) and Tenant ID (tenant).
129
-
- In **Service connection name**type**`azure subs`**. This name will be referenced in YAML pipelines when needing an Azure DevOps Service Connection to communicate with your Azure subscription.
130
-
131
-

132
-
133
-
1. Click on **Verify and Save**.
134
-
135
-
#### Task 2: Setup and Run CI pipeline
77
+
#### Task 1: Setup and Run CI pipeline
136
78
137
79
In this task, you will import an existing CI YAML pipeline definition, modify and run it. It will create a new Azure Container Registry (ACR) and build/publish the eShopOnWeb container images.
138
80
@@ -210,7 +152,7 @@ For this lab scenario, we will have a Azure Container Instance (ACI) that pulls
210
152
211
153
#### Task 3: Create a Variable Group connected to Azure Key Vault
212
154
213
-
In this task, you will create a Variable Group in Azure DevOps that will retrieve the ACR password secret from Key Vault using the Service Connection (Service Principal).
155
+
In this task, you will create a Variable Group in Azure DevOps that will retrieve the ACR password secret from Key Vault using the Service Connection created previously.
214
156
215
157
1. On your lab computer, start a web browser and navigate to the Azure DevOps project **eShopOnWeb**.
216
158
@@ -259,22 +201,16 @@ In this task, you will import a CD pipeline, customize it, and run it for deploy
259
201
260
202
1. Your pipeline will take a name based on the project name. Lets **rename** it for identifying the pipeline better. Go to **Pipelines > Pipelines** and click on the recently created pipeline. Click on the ellipsis and **Rename/Remove** option. Name it **eshoponweb-cd-aci** and click on **Save**.
261
203
262
-
### Exercise 2: Remove the Azure lab resources
263
-
264
-
In this exercise, you will remove the Azure resources provisioned in this lab to eliminate unexpected charges.
265
-
266
-
>**Note**: Remember to remove any newly created Azure resources that you no longer use. Removing unused resources ensures you will not see unexpected charges.
267
-
268
-
#### Task 1: Remove the Azure lab resources
269
-
270
-
In this task, you will use Azure Cloud Shell to remove the Azure resources provisioned in this lab to eliminate unnecessary charges.
271
-
272
-
1. In the Azure portal, open the created Resource Group and click on **Delete resource group**.
204
+
> [!IMPORTANT]
205
+
> Remember to delete the resources created in the Azure portal to avoid unnecessary charges.
273
206
274
207
## Review
275
208
276
209
In this lab, you integrated Azure Key Vault with an Azure DevOps pipeline by using the following steps:
277
210
278
-
- Created an Azure service principal to provide access to an Azure Key Vault secret and authenticate deployment to Azure from Azure DevOps.
279
-
- Ran two YAML pipelines imported from a Git repository.
280
-
- Configured one pipeline to retrieve the password from Azure Key Vault using a Variable Group and use it on subsequent tasks.
211
+
- Created an Azure Key Vault to store an ACR password as a secret.
212
+
- Provided access to secrets in the Azure Key Vault.
213
+
- Configured permissions to read the secret.
214
+
- Configured a pipeline to retrieve the password from the Azure Key Vault and pass it on to subsequent tasks.
215
+
- Deployed a container image to Azure Container Instance (ACI) using the secret.
216
+
- Created a Variable Group connected to Azure Key Vault.
0 commit comments