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_M07_Integrating_Azure_Key_Vault_with_Azure_DevOps.md
+21-63Lines changed: 21 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ A service principal is automatically created by Azure Pipeline when you connect
147
147
148
148
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.
149
149
150
-
From the lab computer, start a web browser, navigate to the Azure DevOps **eShopOnWeb** project. Go to **Pipelines>Pipelines** and click on **Create Pipeline**.
150
+
1. From the lab computer, start a web browser, navigate to the Azure DevOps **eShopOnWeb** project. Go to **Pipelines>Pipelines** and click on **Create Pipeline**.
151
151
152
152
1. On the **Where is your code?** window, select **Azure Repos Git (YAML)** and select the **eShopOnWeb** repository.
153
153
@@ -242,58 +242,29 @@ In this task, you will create a Variable Group in Azure DevOps that will retriev
242
242
243
243

244
244
245
+
#### Task 4: Setup CD Pipeline to deploy container in ACI
245
246
247
+
In this task, you will import a CD pipeline, customize it and run it for deploying the container image created before in a Azure Container Instance.
246
248
249
+
1. From the lab computer, start a web browser, navigate to the Azure DevOps **eShopOnWeb** project. Go to **Pipelines>Pipelines** and click on **New Pipeline**.
247
250
251
+
1. On the **Where is your code?** window, select **Azure Repos Git (YAML)** and select the **eShopOnWeb** repository.
248
252
253
+
1. On the **Configure** section, choose **Existing Azure Pipelines YAML file**. Provide the following path **/.ado/main-cd-web-aci.yml** and click on **Continue**.
249
254
255
+
1. In the YAML pipeline definition, customize:
250
256
251
-
1. On the **Pipelines** pane, click on the entry representing the **SmartHotel-CouponManagement-CI** pipeline. Click on **Edit**.
252
-
2. On the pipeline definition, make sure the **Pipeline** > **Agent Specification** is **ubuntu 18.04**. Click **Save and Queue** > **Queue** > **Run** to trigger a build.
253
-
3. In the vertical navigational pane of the of the Azure DevOps portal, in the **Pipelines** section, select **Releases**.
254
-
4. On the **SmartHotel-CouponManagement-CD** pane, click **Edit** in the upper right corner.
255
-
5. On the **All pipelines > SmartHotel-CouponManagement-CD** pane, select the **Task** tab and, in the dropdown menu, select **Dev**.
256
-
257
-
> **Note**: The release definition for **Dev** stage has an **Azure Key Vault** task. This task downloads *Secrets* from an Azure Key Vault. You will need to point to the subscription and the Azure Key Vault resource created earlier in the lab.
258
-
259
-
> **Note**: You need to authorize the pipeline to deploy to Azure. Azure pipelines can automatically create a service connection with a new service principal, **but we want to use the one we created earlier**, as it has been authorized to read the secret.
260
-
261
-
1. Select **Run on agent** and modify **Agent pool** field to **Azure Pipelines** and agent specification **ubuntu 18.04**.
262
-
1. Select the **Azure Key Vault** task and, on the right side, in the **Azure Key Vault** task properties, next to the **Azure subscription** label, click **Manage**.
263
-
This will open another browser tab displaying the **Service connections** pane in the Azure DevOps portal.
264
-
1. On the **Service connections** pane, click **New Service connection**.
265
-
1. On the **New service connection** pane, select the **Azure Resource Manager** option, click **Next**, select **Service Principal (manual)**, and click **Next** again.
266
-
1. On the **New service connection** pane, specify the following settings, using the information you copied to a text file in the first task of this exercise following creation of the service principal by using Azure CLI:
267
-
268
-
- Subscription Id: the value you obtained by running `az account show --query id --output tsv`
269
-
- Subscription Name: the value you obtained by running `az account show --query name --output tsv`
270
-
- Service Principal Id: the value labeled **appId** in the output generated by running `az ad sp create-for-rbac --name <service-principal-name>`
271
-
- Service Principal key: the value labeled **password** in the output generated by running `az ad sp create-for-rbac --name <service-principal-name>`
272
-
- TenantId: the value labeled **tenant** in the output generated by running `az ad sp create-for-rbac --name <service-principal-name>`
273
-
274
-
1. On the **New service connection** pane, click **Verify** to determine whether the information you provided is valid.
275
-
1. Once you receive the **Verification Succeeded** response, in the **Service connection name** textbox, type **kv-service-connection** and click **Verify and Save**.
276
-
1. Switch back to the web browser tab displaying the pipeline definition and the **Azure Key Vault** task.
277
-
1. With the **Azure Key Vault** task selected, on the **Azure Key Vault** pane, click the **Refresh** button, in the **Azure subscription** dropdown list, select the **kv-service-connection** entry, in the **Key vault** dropdown list, select the entry representing the Azure Key vault you created in the first task, and, in the **Secrets filter** textbox, type **sqldbpassword**. Finally, expand the **Output Variables** section and, in the **Reference name** textbox, type **sqldbpassword**.
278
-
279
-
> **Note**: At runtime, Azure Pipelines will fetch the latest value of the secret and set it as the task variable **$(sqldbpassword)**. The tasks can consumed by the subsequent tasks by referencing that variable.
280
-
281
-
1. To verify this, select the next task, **Azure Deployment**, which deploys an ARM template and review the content of the **Override template parameters** textbox.
> **Note**: The **Override template parameters** content references the **sqldbpassword** variable to set the mySQL admin password. This will provision the MySQL database defined in the ARM template using the password that you have specified in the key vault.
288
-
289
-
1. You may complete the pipeline definition by specifying the subscription (if new subscription is used in the project, click on **Authorize** )and location for the task. **Repeat** the same for the last task in the pipeline **Azure App Service Deploy** (choose the subscription from the **Available Azure service connection** section in the dropdown).
290
-
291
-
> **Note**: In the Azure subscription dropdown list, you will see **Available Azure service connections** for those susbcriptions that have already been authorized to be connected to Azure. If you select the authorized subscription again (from **Available Azure subscriptions** list) and try to **Authorize**, the process will fail.
257
+
- **YOUR-SUBSCRIPTION-ID** with your Azure subscription id.
258
+
- **az400eshop-NAME** replace NAME to make it globally unique.
259
+
- **YOUR-ACR.azurecr.io** and **ACR-USERNAME** with your ACR login server (both need the ACR name, can be reviewed on the ACR>Access Keys).
260
+
- **AZ400-EWebShop-NAME** with the resource group name defined before in the lab.
292
261
293
-
1. On the **Variables** tab, change the **resourcegroup** variable to plain text (click on lock) and write **az400m07l01-RG** in the value field.
294
-
1. Finally, **Save** and click on **Create a new release** > **Create** (leave defaults) to start the deployment.
262
+
1. Click on **Save and Run** and wait for the pipeline to execute succesfully.
295
263
296
-
1. Make sure your pipeline runs successfully and once finished, review the created resources by opening the resource group **az400m07l01-RG** in the Azure Portal . Open the **App Service** and browse it **(Overview -> Browse)**, to see the published website.
264
+
> **Note**: The deployment may take a few minutes to complete. The CD definition consists of the following tasks:
265
+
- **Resources** : it is prepared to automatically trigger based on CI pipeline completion. It also download the repository for the bicep file.
266
+
- **Variables (for Deploy stage)** connecs to the variable gorup to consume the Azure Key Vault secret **acr-secret**
267
+
- **AzureResourceManagerTemplateDeployment** deploys the Azure Container Instance (ACI) using bicep template and provides the ACR login parameters to allow ACI to download the previously created container image from Azure Container Registry (ACR).
297
268
298
269
### Exercise 2: Remove the Azure lab resources
299
270
@@ -305,26 +276,13 @@ In this exercise, you will remove the Azure resources provisione in this lab to
305
276
306
277
In this task, you will use Azure Cloud Shell to remove the Azure resources provisioned in this lab to eliminate unnecessary charges.
307
278
308
-
1. In the Azure portal, open the **Bash** shell session within the **Cloud Shell** pane.
309
-
1. List all resource groups created throughout the labs of this module by running the following command:
310
-
311
-
```sh
312
-
az group list --query "[?starts_with(name,'az400m07l01-RG')].name" --output tsv
313
-
```
314
-
315
-
1. Delete all resource groups you created throughout the labs of this module by running the following command:
316
-
317
-
```sh
318
-
az group list --query "[?starts_with(name,'az400m07l01-RG')].[name]" --output tsv | xargs -L1 bash -c 'az group delete --name $0 --no-wait --yes'
319
-
```
320
-
321
-
>**Note**: The command executes asynchronously (as determined by the --nowait parameter), so while you will be able to run another Azure CLI command immediately afterwards within the same Bash session, it will take a few minutes before the resource groups are actually removed.
279
+
1. In the Azure portal, open the created Resource Group and click on **Delete resource group**.
322
280
323
281
#### Review
324
282
325
283
In this lab, you integrated Azure Key Vault with an Azure DevOps pipeline by using the following steps:
326
284
327
-
- created an Azure Key vault to store a MySQL server password as a secret.
328
-
- created an Azure service principal to provide access to secrets in the Azure Key vault.
329
-
- configured permissions to allow the service principal to read the secret.
330
-
- configured pipeline to retrieve the password from the Azure Key vault and pass it on to subsequent tasks.
285
+
286
+
- created an Azure service principal to provide access to secrets in the Azure Key vault and authenticate deployment to Azure from Azure DevOps.
287
+
- run 2 YAML pipelines imported from a Git repository.
288
+
- configured pipeline to retrieve the password from the Azure Key vault using ADO Variable Group and use it on subsequent tasks.
0 commit comments