Skip to content

Commit f1ee2f0

Browse files
committed
Technical Review 1044093: Authenticate your Azure deployment pipeline by using service principals
1 parent f3647f5 commit f1ee2f0

9 files changed

+240
-240
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.introduction
3-
title: Introduction
4-
metadata:
5-
unitType: introduction
6-
title: Introduction
7-
description: Learn how to create, manage, and grant permissions to service principals, which enable your deployment pipelines to securely authenticate to Azure.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
durationInMinutes: 2
13-
content: |
14-
[!include[](includes/1-introduction.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.introduction
3+
title: Introduction
4+
metadata:
5+
unitType: introduction
6+
title: Introduction
7+
description: Learn how to create, manage, and grant permissions to service principals, which enable your deployment pipelines to securely authenticate to Azure.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
durationInMinutes: 2
13+
content: |
14+
[!include[](includes/1-introduction.md)]
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.understand-service-principals
3-
title: Understand service principals
4-
metadata:
5-
unitType: learning-content
6-
title: Understand service principals
7-
description: Learn what service principals are, how they're different from user accounts, and how they work.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
durationInMinutes: 8
13-
content: |
14-
[!include[](includes/2-understand-service-principals.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.understand-service-principals
3+
title: Understand service principals
4+
metadata:
5+
unitType: learning-content
6+
title: Understand Service Principals
7+
description: Learn what service principals are, how they're different from user accounts, and how they work.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
durationInMinutes: 8
13+
content: |
14+
[!include[](includes/2-understand-service-principals.md)]
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.create-service-principal-key
3-
title: Create a service principal and key
4-
metadata:
5-
unitType: learning-content
6-
title: Create a service principal and key
7-
description: Learn how to create service principals, and how to manage keys and other credentials for service principals.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
zone_pivot_groups: azure-shell-interface
13-
durationInMinutes: 6
14-
content: |
15-
[!include[](includes/3-create-service-principal-key.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.create-service-principal-key
3+
title: Create a service principal and key
4+
metadata:
5+
unitType: learning-content
6+
title: Create a Service Principal and Key
7+
description: Learn how to create service principals, and how to manage keys and other credentials for service principals.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
zone_pivot_groups: azure-shell-interface
13+
durationInMinutes: 6
14+
content: |
15+
[!include[](includes/3-create-service-principal-key.md)]
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.exercise-create-service-principal-key
3-
title: Exercise - Create a service principal and key
4-
metadata:
5-
unitType: exercise
6-
title: Exercise - Create a service principal and key
7-
description: Learn how to create service principals, and how to manage keys and other credentials for service principals.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-azurepowershell
14-
zone_pivot_groups: azure-shell-interface
15-
durationInMinutes: 3
16-
content: |
17-
[!include[](includes/4-exercise-create-service-principal-key.md)]
18-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.exercise-create-service-principal-key
3+
title: Exercise - Create a service principal and key
4+
metadata:
5+
unitType: exercise
6+
title: Exercise - Create a Service Principal and Key
7+
description: Learn how to create service principals, and how to manage keys and other credentials for service principals.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-azurepowershell
14+
zone_pivot_groups: azure-shell-interface
15+
durationInMinutes: 3
16+
content: |
17+
[!include[](includes/4-exercise-create-service-principal-key.md)]
18+
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.grant-service-principal-access-azure
3-
title: Grant a service principal access to Azure
4-
metadata:
5-
unitType: learning-content
6-
title: Grant a service principal access to Azure
7-
description: Learn how to create an Azure role assignment for a service principal.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
zone_pivot_groups: azure-shell-interface
15-
durationInMinutes: 6
16-
content: |
17-
[!include[](includes/5-grant-service-principal-access-azure.md)]
18-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.grant-service-principal-access-azure
3+
title: Grant a service principal access to Azure
4+
metadata:
5+
unitType: learning-content
6+
title: Grant a Service Principal Access to Azure
7+
description: Learn how to create an Azure role assignment for a service principal.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
zone_pivot_groups: azure-shell-interface
15+
durationInMinutes: 6
16+
content: |
17+
[!include[](includes/5-grant-service-principal-access-azure.md)]
18+
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.exercise-authorize-service-principal-deployments
3-
title: Exercise - Authorize your service principal for deployments
4-
metadata:
5-
unitType: exercise
6-
title: Exercise - Authorize your service principal for deployments
7-
description: Learn how to create an Azure role assignment for a service principal.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
zone_pivot_groups: azure-shell-interface
15-
durationInMinutes: 5
16-
content: |
17-
[!include[](includes/6-exercise-authorize-service-principal-deployments.md)]
18-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.exercise-authorize-service-principal-deployments
3+
title: Exercise - Authorize your service principal for deployments
4+
metadata:
5+
unitType: exercise
6+
title: Exercise - Authorize your Service Principal for Deployments
7+
description: Learn how to create an Azure role assignment for a service principal.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
zone_pivot_groups: azure-shell-interface
15+
durationInMinutes: 5
16+
content: |
17+
[!include[](includes/6-exercise-authorize-service-principal-deployments.md)]
18+
Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.knowledge-check
3-
title: Module assessment
4-
metadata:
5-
unitType: knowledge_check
6-
title: Module assessment
7-
description: Knowledge check
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
durationInMinutes: 3
13-
content: |
14-
quiz:
15-
questions:
16-
- content: You're building a custom deployment agent that runs on an Azure virtual machine that you control. Which of these authentication techniques should the agent use to authenticate and work with Azure resources?
17-
choices:
18-
- content: User account
19-
isCorrect: false
20-
explanation: Deployment agents run in an unattended mode, so you should never use a user account.
21-
- content: Service principal
22-
isCorrect: false
23-
explanation: A service principal can be used for this purpose, but using a service principal requires that you manage credentials. Because you're running a custom deployment agent on a virtual machine, you should use a managed identity so that you don't have to maintain credentials.
24-
- content: Managed identity
25-
isCorrect: true
26-
explanation: Managed identities are designed for unattended access, and they don't require you work with credentials. Because you're running a custom deployment agent on a virtual machine, you should use a managed identity so that you don't have to maintain credentials.
27-
- content: You need to create a service principal for a pipeline that deploys your infrastructure to three environments - development, test, and production. Each environment is in a dedicated resource group in three different subscriptions. What should you do?
28-
choices:
29-
- content: Create a single service principal and grant it access to the tenant root management group.
30-
isCorrect: false
31-
explanation: Although this will work, it's not a good practice to use a single service principal for all of your environments. Additionally, granting access to your tenant root management group will allow the service principal to modify resources anywhere in your Azure environment, which is unnecessarily permissive.
32-
- content: Create a single service principal and grant it access to each of the resource groups in the three subscriptions.
33-
isCorrect: false
34-
explanation: Although this will work, it's not good practice to use a single service principal for all of your environments. At the very least, you should separate production and non-production environments by using two service principals, but a dedicated service principal for each environment is preferred.
35-
- content: Create three service principals, one per environment, and grant each access to a single resource group in the relevant subscription.
36-
isCorrect: true
37-
explanation: When you work with multiple environments, it's best to use dedicated service principals for each environment so that your pipeline can't accidentally change anything in another environment.
38-
- content: You create a service principal with a key, and you set the key to expire 30 days in the future. What happens after that time?
39-
choices:
40-
- content: Nothing - the key will automatically renew.
41-
isCorrect: false
42-
explanation: Service principal keys don't automatically renew.
43-
- content: Your client can no longer authenticate.
44-
isCorrect: true
45-
explanation: After a service principal's key has expired, the key can't be used to authenticate. You'll need to issue a new key.
46-
- content: Your client can authenticate, but it receives a warning that the key has expired.
47-
isCorrect: false
48-
explanation: After a service principal's key has expired, the key can't be used to authenticate. You'll need to issue a new key.
49-
- content: You're creating a service principal to run a pipeline. The pipeline deploys a Bicep template that creates a single storage account. Which of the following options has the least privileged access that you need for your pipeline?
50-
choices:
51-
- content: |
52-
**Role definition:** Contributor<br />
53-
**Scope:** Subscription
54-
isCorrect: false
55-
explanation: The Contributor role is a good one to use. However, you should avoid granting it over the subscription scope unless you need to. In this case, you don't.
56-
- content: |
57-
**Role definition:** Contributor<br />
58-
**Scope:** Resource group
59-
isCorrect: true
60-
explanation: The Contributor role is a good one to use. Additionally, it's a good practice to grant it over the resource group, which is all that this pipeline needs.
61-
- content: |
62-
**Role definition:** Owner<br />
63-
**Scope:** Resource group
64-
isCorrect: false
65-
explanation: This role assignment is too permissive. You should avoid granting the Owner role unless it's required. In this example, it's not.
66-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.knowledge-check
3+
title: Module assessment
4+
metadata:
5+
unitType: knowledge_check
6+
title: Module Assessment
7+
description: Knowledge check
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
durationInMinutes: 3
13+
content: |
14+
quiz:
15+
questions:
16+
- content: You're building a custom deployment agent that runs on an Azure virtual machine that you control. Which of these authentication techniques should the agent use to authenticate and work with Azure resources?
17+
choices:
18+
- content: User account
19+
isCorrect: false
20+
explanation: Deployment agents run in an unattended mode, so you should never use a user account.
21+
- content: Service principal
22+
isCorrect: false
23+
explanation: A service principal can be used for this purpose, but using a service principal requires that you manage credentials. Because you're running a custom deployment agent on a virtual machine, you should use a managed identity so that you don't have to maintain credentials.
24+
- content: Managed identity
25+
isCorrect: true
26+
explanation: Managed identities are designed for unattended access, and they don't require you work with credentials. Because you're running a custom deployment agent on a virtual machine, you should use a managed identity so that you don't have to maintain credentials.
27+
- content: You need to create a service principal for a pipeline that deploys your infrastructure to three environments - development, test, and production. Each environment is in a dedicated resource group in three different subscriptions. What should you do?
28+
choices:
29+
- content: Create a single service principal and grant it access to the tenant root management group.
30+
isCorrect: false
31+
explanation: Although this will work, it's not a good practice to use a single service principal for all of your environments. Additionally, granting access to your tenant root management group will allow the service principal to modify resources anywhere in your Azure environment, which is unnecessarily permissive.
32+
- content: Create a single service principal and grant it access to each of the resource groups in the three subscriptions.
33+
isCorrect: false
34+
explanation: Although this will work, it's not good practice to use a single service principal for all of your environments. At the very least, you should separate production and non-production environments by using two service principals, but a dedicated service principal for each environment is preferred.
35+
- content: Create three service principals, one per environment, and grant each access to a single resource group in the relevant subscription.
36+
isCorrect: true
37+
explanation: When you work with multiple environments, it's best to use dedicated service principals for each environment so that your pipeline can't accidentally change anything in another environment.
38+
- content: You create a service principal with a key, and you set the key to expire 30 days in the future. What happens after that time?
39+
choices:
40+
- content: Nothing - the key will automatically renew.
41+
isCorrect: false
42+
explanation: Service principal keys don't automatically renew.
43+
- content: Your client can no longer authenticate.
44+
isCorrect: true
45+
explanation: After a service principal's key has expired, the key can't be used to authenticate. You'll need to issue a new key.
46+
- content: Your client can authenticate, but it receives a warning that the key has expired.
47+
isCorrect: false
48+
explanation: After a service principal's key has expired, the key can't be used to authenticate. You'll need to issue a new key.
49+
- content: You're creating a service principal to run a pipeline. The pipeline deploys a Bicep template that creates a single storage account. Which of the following options has the least privileged access that you need for your pipeline?
50+
choices:
51+
- content: |
52+
**Role definition:** Contributor<br />
53+
**Scope:** Subscription
54+
isCorrect: false
55+
explanation: The Contributor role is a good one to use. However, you should avoid granting it over the subscription scope unless you need to. In this case, you don't.
56+
- content: |
57+
**Role definition:** Contributor<br />
58+
**Scope:** Resource group
59+
isCorrect: true
60+
explanation: The Contributor role is a good one to use. Additionally, it's a good practice to grant it over the resource group, which is all that this pipeline needs.
61+
- content: |
62+
**Role definition:** Owner<br />
63+
**Scope:** Resource group
64+
isCorrect: false
65+
explanation: This role assignment is too permissive. You should avoid granting the Owner role unless it's required. In this example, it's not.
66+
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.summary
3-
title: Summary
4-
metadata:
5-
unitType: summary
6-
title: Summary
7-
description: Summary.
8-
ms.date: 01/16/2024
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
durationInMinutes: 1
13-
content: |
14-
[!include[](includes/8-summary.md)]
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.authenticate-azure-deployment-pipeline-service-principals.summary
3+
title: Summary
4+
metadata:
5+
unitType: summary
6+
title: Summary
7+
description: Summary.
8+
ms.date: 04/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
durationInMinutes: 1
13+
content: |
14+
[!include[](includes/8-summary.md)]

0 commit comments

Comments
 (0)