Skip to content

Commit c0c3028

Browse files
committed
Line edits
1 parent f1ee2f0 commit c0c3028

File tree

5 files changed

+37
-36
lines changed

5 files changed

+37
-36
lines changed

learn-pr/azure/authenticate-azure-deployment-pipeline-service-principals/includes/1-introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Deployment pipelines need to communicate with Azure, so they can create and configure your Azure resources. In this module, you'll learn how service principals work, how to create and manage them, and how to authorize them to work with Azure on your behalf.
1+
Deployment pipelines need to communicate with Azure so they can create and configure your Azure resources. In this module, you'll learn how service principals work, how to create and manage them, and how to authorize them to work with Azure on your behalf.
22

33
## Example scenario
44

5-
Suppose you're responsible for deploying and configuring the Azure infrastructure at a toy company. You've created a Bicep template to deploy your company's website. Until now, you've been deploying it from your own computer by using command-line tools. You've decided to move the deployment into a pipeline.
5+
Suppose you're responsible for deploying and configuring the Azure infrastructure at a toy company. You've created a Bicep template to deploy your company's website. Until now, you've been deploying it from your own computer by using command-line tools. You've decided to move the deployment into a pipeline.
66

77
One of your colleagues has told you that you'll need to set up a service principal for the deployment pipeline. You need to understand what this is, and then set it up so you can deploy your company's website.
88

learn-pr/azure/authenticate-azure-deployment-pipeline-service-principals/includes/2-understand-service-principals.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Service principals provide a way to authenticate pipelines, applications, and so
22

33
## Why does a pipeline need to authenticate?
44

5-
When you deploy a Bicep template, you effectively ask Azure Resource Manager to create or modify your Azure resources. In this example scenario, you've created a Bicep template to deploy your toy company's website. The Bicep template declares resources that include an Azure App Service plan, an app, and an Application Insights instance.
5+
When you deploy a Bicep template, you effectively ask Azure Resource Manager to create or modify your Azure resources. In this example scenario, you've created a Bicep template to deploy your toy company's website. The Bicep template declares resources that include an Azure App Service plan, an app, and an Application Insights instance.
66

77
When you deploy the template, Resource Manager checks whether the resources exist. If they don't, Resource Manager creates them. If any already exist, Resource Manager ensures that their configuration matches the configuration that you specify in the template.
88

@@ -22,10 +22,10 @@ Microsoft Entra ID is the service that manages identities for Azure. Microsoft E
2222

2323
:::image type="content" source="../media/2-security-principals.png" alt-text="Diagram that shows the four types of security principals: user, group, service principal, and managed identity." border="false":::
2424

25-
- A *user* represents a human who usually signs in interactively by using a browser. Users often have additional security checks to perform when they sign in, such as multifactor authentication (MFA) and Conditional Access based on their location or network.
26-
- A *group* represents a collection of users. Groups don't authenticate directly, but they provide a convenient way to assign permissions to a set of users together.
27-
- A *service principal* represents an automated process or system that usually doesn't have a human directly running it.
28-
- A *managed identity* is a special type of service principal that's designed for situations where a human isn't involved in the authentication process.
25+
- A _user_ represents a human who usually signs in interactively by using a browser. Users often have additional security checks to perform when they sign in, such as multifactor authentication (MFA) and Conditional Access based on their location or network.
26+
- A _group_ represents a collection of users. Groups don't authenticate directly, but they provide a convenient way to assign permissions to a set of users together.
27+
- A _service principal_ represents an automated process or system that usually doesn't have a human directly running it.
28+
- A _managed identity_ is a special type of service principal that's designed for situations where a human isn't involved in the authentication process.
2929

3030
### Service principals
3131

@@ -42,20 +42,20 @@ Managed identities are available for Azure-hosted resources like virtual machine
4242
When you work with pipelines, you usually can't use managed identities. This is because managed identities require that you own and manage the Azure resources that run your deployments. When you work with Azure Pipelines, you usually rely on shared infrastructure provided by Microsoft.
4343

4444
> [!NOTE]
45-
> There are some situations where pipelines can use managed identities. In Azure Pipelines, you can create a _self-hosted agent_ to run your pipeline's scripts and code by using on your own Azure-based virtual machine. Because you own the virtual machine, you can assign it a managed identity and use it from your pipeline.
45+
> There are some situations where pipelines can use managed identities. In Azure Pipelines, you can create a _self-hosted agent_ to run your pipeline's scripts and code by using on your own Azure-based virtual machine. Because you own the virtual machine, you can assign it a managed identity and use it from your pipeline.
4646
>
4747
> However, most of the time your pipelines run by using a _hosted agent_, which is a server that Microsoft manages. Hosted agents aren't currently compatible with managed identities.
48-
48+
>
4949
> [!TIP]
5050
> In other parts of your solution, if you have a choice between using a managed identity or using a normal service principal, it's best to go with a managed identity. They're easier to work with and are usually more secure.
5151
5252
## Why can't you just use your user account?
5353

5454
You might wonder why you need to create this whole new type of object just to authenticate a pipeline, when you have user accounts that work perfectly well.
5555

56-
User accounts aren't designed for unattended use. The authentication process for a user account often checks that a human is the entity that's trying to sign in. Increasingly, organizations use additional security checks during authentication. These checks include MFA, CAPTCHA checks, and inspecting the device and network that the user is using so that they can verify the legitimacy of a request to sign in.
56+
User accounts aren't designed for unattended use. The authentication process for a user account often checks that a human is the entity that's trying to sign in. Increasingly, organizations use additional security checks during authentication. These checks include MFA, CAPTCHA checks, and inspecting the device and network that the user is using so they can verify the legitimacy of a request to sign in.
5757

58-
Pipelines are designed to run your deployments even when no-one is actively running them. In fact, most of the benefits of pipelines come from the fact that they are completely automated and don't require human interaction. If you store your username and password in a pipeline and try to use them to sign in, they probably won't work. Even if they do seem to work, they can easily break in the future if Microsoft Entra ID or your organizational administrator adds more security checks to your user authentication process.
58+
Pipelines are designed to run your deployments even when no one is actively running them. In fact, most of the benefits of pipelines come from the fact that they're completely automated and don't require human interaction. If you store your username and password in a pipeline and try to use them to sign in, they probably won't work. Even if they do seem to work, they can easily break in the future if Microsoft Entra ID or your organizational administrator adds more security checks to your user authentication process.
5959

6060
> [!WARNING]
6161
> It's also a bad idea to save your username and password anywhere, because someone else might get access to them and then use them to impersonate you.
@@ -64,11 +64,11 @@ For these reasons, the built-in pipeline tasks that interact with Azure don't le
6464

6565
## How do service principals work?
6666

67-
You might see a few different terms in use when you work with service principals, or with tools like the Azure portal or the Microsoft Graph API. Although it's not essential to understand these terms just to use service principals in a pipeline, it is helpful to know a little about the concepts.
67+
You might see a few different terms in use when you work with service principals, or with tools like the Azure portal or the Microsoft Graph API. Although it's not essential to understand these terms just to use service principals in a pipeline, it's helpful to know a little about the concepts.
6868

6969
Service principals are a feature of Microsoft Entra ID. Microsoft Entra ID is a global identity service. Many companies use Microsoft Entra ID, and each company is called a _tenant_.
7070

71-
Microsoft Entra ID has a concept of an _application_, which represents a system, piece of software, process, or some other non-human agent. You can think of a deployment pipeline as an application.
71+
Microsoft Entra ID has a concept of an _application_, which represents a system, piece of software, process, or some other non-human agent. You can think of a deployment pipeline as an application.
7272

7373
In Microsoft Entra ID, applications can do many things that are beyond the scope of authentication and pipeline deployments. When you create an application and tell Microsoft Entra ID about it, you create an object called an _application registration_. An application registration represents the application in Microsoft Entra ID.
7474

learn-pr/azure/authenticate-azure-deployment-pipeline-service-principals/includes/3-create-service-principal-key.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ Now that you understand the concept of a service principal, you might wonder how
22

33
## Understand how service principals are authenticated
44

5-
When a service principal needs to communicate with Azure, it signs in to Microsoft Entra ID. After Microsoft Entra ID verifies the service principal's identity, it issues a _token_ that the client application stores and uses when it makes any requests to Azure.
5+
When a service principal needs to communicate with Azure, it signs in to Microsoft Entra ID. After Microsoft Entra ID verifies the service principal's identity, it issues a _token_ that the client application stores and uses when it makes any requests to Azure.
66

77
Broadly speaking, this process is similar to how things work when you sign in to Azure yourself as a user. However, compared to users, service principals have a slightly different type of credential to prove their identity. Service principals use two main credentials: keys and certificates.
88

99
> [!NOTE]
10-
> Remember that managed identities are special service principals that work within Azure. They have a different type of authentication process that doesn't require that you know or handle credentials at all.
10+
> Remember that managed identities are special service principals that work within Azure. They have a different type of authentication process that doesn't require you know or handle credentials at all.
1111
1212
### Keys
1313

1414
Keys are similar to passwords. However, keys are much longer and more complex. In fact, for most situations, Microsoft Entra ID generates keys itself to ensure that:
1515

1616
- The keys are _cryptographically random_. That is, they're extremely hard to guess.
17-
- Humans don't accidentally use weak passwords as keys.
17+
- Humans don't accidentally use weak passwords as keys.
1818

19-
Service principals often have highly privileged permissions, so it's essential that they're secure. Typically, you only need to handle the key briefly when first configuring the service principal and your pipeline. So the key doesn't need to be memorable or easy to type.
19+
Service principals often have highly privileged permissions, so it's essential that they're secure. Typically, you only need to handle the key briefly when first configuring the service principal and your pipeline. So the key doesn't need to be memorable or easy to type.
2020

2121
A single service principal can have multiple keys at the same time, but users can't have multiple passwords. Like passwords, keys have an expiration date. You'll learn more about that soon.
2222

@@ -25,7 +25,7 @@ A single service principal can have multiple keys at the same time, but users ca
2525
2626
### Certificates
2727

28-
Certificates are another way to authenticate service principals. They're very secure but can be hard to manage. Some organizations require the use of certificates for certain types of service principals.
28+
Certificates are another way to authenticate service principals. They're very secure but can be hard to manage. Some organizations require the use of certificates for certain types of service principals.
2929

3030
We won't discuss certificates in this module. However, if you work with a service principal that uses certificate authentication, it basically works the same way as any other service principal in terms of managing it and granting it permission for your pipeline.
3131

@@ -37,15 +37,15 @@ We won't discuss certificates in this module. However, if you work with a servic
3737
When you create a service principal, you generally ask Azure to create a key at the same time. Azure typically generates a random key for you.
3838

3939
> [!NOTE]
40-
> Remember our earlier discussion about how service principals work? Keys are stored as part of the application registration object. If you open the Azure portal, look within the Microsoft Entra configuration, and then go to the application registrations, you can create and delete keys there too.
40+
> Remember our earlier discussion about how service principals work? Keys are stored as part of the application registration object. If you open the Azure portal, look within the Microsoft Entra configuration, and then go to the application registrations. You can create and delete keys there too.
4141
4242
Azure shows you the key when you create the service principal. This is the only time that Azure will ever show you the key. After that, you can't retrieve it anymore. It's important that you securely copy the key so you can use it when you configure your pipeline. Don't share the key by email or another non-secure means. If you lose a key, you must delete it and create a new one.
4343

4444
## Manage service principals for Azure Pipelines
4545

46-
When you create a key for a pipeline's service principal, it's a good idea to immediately copy the key into the pipeline's configuration. That way, you avoid storing or transmitting the key unnecessarily.
46+
When you create a key for a pipeline's service principal, it's a good idea to immediately copy the key into the pipeline's configuration. That way, you avoid storing or transmitting the key unnecessarily.
4747

48-
Pipeline tools include secure ways to specify your service principal's application ID and key. Never store credentials of any kind in source control. Instead, use *service connections* when you work with Azure Pipelines. In this module, we only discuss how to create a service principal and key. You'll learn how to configure your pipeline with the key in a later module.
48+
Pipeline tools include secure ways to specify your service principal's application ID and key. Never store credentials of any kind in source control. Instead, use _service connections_ when you work with Azure Pipelines. In this module, we only discuss how to create a service principal and key. You'll learn how to configure your pipeline with the key in a later module.
4949

5050
> [!TIP]
5151
> Azure Pipelines can create service principals for you automatically. In this module, you'll manually create and manage your service principals to gain a better understanding of what's happening. In other modules, you'll use the automatic creation method for simplicity.
@@ -108,7 +108,7 @@ Service principals have several identifiers and names that you use to identify a
108108

109109
> [!TIP]
110110
> Use a clear, descriptive display name for your service principal. It's important to help your team understand what the service principal is for, so that nobody accidentally deletes it or changes its permissions.
111-
111+
>
112112
> [!CAUTION]
113113
> A display name isn't unique. Multiple service principals might share the same display name. Be careful when you grant permissions to a service principal by using its display name to identify it. You might accidentally give permissions to the wrong service principal. It's a good practice to use the application ID instead.
114114
@@ -154,17 +154,17 @@ $newKey = $newCredential.SecretText
154154
155155
## Manage the lifecycle of your service principal
156156

157-
It's important to consider the whole lifecycle of each service principal that you create. When you build a service principal for a pipeline, what will happen if the pipeline is eventually deleted or is no longer used?
157+
It's important to consider the whole lifecycle of each service principal that you create. When you build a service principal for a pipeline, what will happen if the pipeline is eventually deleted or is no longer used?
158158

159-
Service principals aren't removed automatically, so you need to audit and remove old service principals. It's important to remove old service principals for the same reason that you delete old user accounts: attackers might gain access to their keys. It's best not to have credentials that aren't actively used.
159+
Service principals aren't removed automatically, so you need to audit and remove old ones. It's important to remove old service principals for the same reason that you delete old user accounts: attackers might gain access to their keys. It's best not to have credentials that aren't actively used.
160160

161161
It's a good practice to document your service principals in a place that you and your team can easily access. You should include the following information for each service principal:
162162

163163
> [!div class="checklist"]
164164
> * Essential identifying information, including its name and application ID.
165-
> * The purpose of the service principal.
166-
> * Who created it, who's responsible for managing it and its keys, and who might have answers if there's a problem.
167-
> * The permissions that it needs, and a clear justification for why it needs them.
168-
> * What its expected lifetime is.
165+
> - The purpose of the service principal.
166+
> - Who created it, who's responsible for managing it and its keys, and who might have answers if there's a problem.
167+
> - The permissions that it needs, and a clear justification for why it needs them.
168+
> - What its expected lifetime is.
169169
170170
You should regularly audit your service principals to ensure that they're still being used and that the permissions they've been assigned are still correct.

learn-pr/azure/authenticate-azure-deployment-pipeline-service-principals/includes/4-exercise-create-service-principal-key.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ This exercise requires that you have permission to create applications and servi
1515

1616
::: zone pivot="cli"
1717

18-
To work with service principals in Azure, you need to sign in to your Azure account from the Visual Studio Code terminal.
18+
To work with service principals in Azure, you need to sign in to your Azure account from the Visual Studio Code terminal.
1919

2020
[!include[](../../includes/azure-exercise-terminal-cli.md)]
2121

2222
### Sign in to Azure by using the Azure CLI
2323

24-
1. In the Visual Studio Code terminal, sign in to Azure by running the following command:
24+
1. In the Visual Studio Code terminal, sign in to Azure by running the following command:
2525

2626
```azurecli
2727
az login
@@ -33,7 +33,7 @@ To work with service principals in Azure, you need to sign in to your Azure acco
3333
3434
::: zone pivot="powershell"
3535
36-
To deploy this template to Azure, sign in to your Azure account from the Visual Studio Code terminal.
36+
To deploy this template to Azure, sign in to your Azure account from the Visual Studio Code terminal.
3737
3838
[!include[](../../includes/azure-exercise-terminal-powershell.md)]
3939
@@ -67,7 +67,7 @@ To deploy this template to Azure, sign in to your Azure account from the Visual
6767
* `password`: The service principal's key.
6868
* `tenant`: Your Microsoft Entra tenant ID.
6969

70-
Copy these values somewhere safe. You'll use them soon.
70+
Copy these values somewhere safe. You'll use them soon.
7171

7272
::: zone-end
7373

@@ -79,9 +79,10 @@ To deploy this template to Azure, sign in to your Azure account from the Visual
7979
$servicePrincipal = New-AzADServicePrincipal `
8080
-DisplayName ToyWebsitePipeline
8181
```
82+
8283
1. Run the following command to get the service principal's key:
8384

84-
```azurepowershell
85+
```azurepowershell
8586
$servicePrincipalKey = $servicePrincipal.PasswordCredentials.SecretText
8687
```
8788

0 commit comments

Comments
 (0)