Skip to content

Commit 65c2d27

Browse files
committed
edits
1 parent 7d765a0 commit 65c2d27

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

articles/storage/common/multiple-identity-scenarios.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ services: storage
66
author: alexwolfmsft
77
ms.service: storage
88
ms.topic: how-to
9-
ms.date: 08/01/2022
9+
ms.date: 09/23/2022
1010
ms.author: alexwolf
1111
ms.subservice: common
1212
ms.custom: devx-track-csharp
1313
---
1414

1515
# Configure passwordless connections between multiple Azure apps and services
1616

17-
Applications often require secure connections between multiple Azure services simultaneously. For example, an enterprise Azure App Service instance might connect to several different storage accounts, an Azure SQL database instance, a service bus, and more.
17+
Applications often require secure connections between multiple Azure services simultaneously. For example, an enterprise Azure App Service instance might connect to several different storage accounts, an Azure SQL database instance, a service bus, and more.
1818

1919
[Managed identities](/azure/active-directory/managed-identities-azure-resources/overview) are the recommended authentication option for secure, passwordless connections between Azure resources. Developers do not have to manually track and manage many different secrets for managed identities, since most of these tasks are handled internally by Azure. This tutorial explores how to manage connections between multiple services using managed identities and the Azure Identity client library.
2020

2121
## Compare the types of managed identities
2222

2323
Azure provides the following types of managed identities:
2424

25-
* **System-assigned managed identities** are directly tied to a single Azure resource. When you enable a system-assigned managed identity on a service, Azure will create a linked identity and handle administrative tasks for that identity internally. When the Azure resource is deleted, the identity is also deleted.
26-
* **User-assigned managed identities** are independent identities that are created by an administrator and can be associated with one or more Azure resources. The lifecycle of the identity is independent of those resources.
25+
* **System-assigned managed identities** are directly tied to a single Azure resource. When you enable a system-assigned managed identity on a service, Azure will create a linked identity and handle administrative tasks for that identity internally. When the Azure resource is deleted, the identity is also deleted.
26+
* **User-assigned managed identities** are independent identities that are created by an administrator and can be associated with one or more Azure resources. The lifecycle of the identity is independent of those resources.
2727

2828
You can read more about best practices and when to use system-assigned identities versus user-assigned identities in the [identities best practice recommendations](/azure/active-directory/managed-identities-azure-resources/managed-identity-best-practice-recommendations).
2929

3030
## Explore DefaultAzureCredential
3131

32-
Managed identities are generally implemented in your application code through a class called `DefaultAzureCredential` from the `Azure.Identity` client library. `DefaultAzureCredential` supports multiple authentication methods and automatically determines which should be used at runtime. You can read more about this approach in the [DefaultAzureCredential overview](/dotnet/api/overview/azure/Identity-readme#defaultazurecredential).
32+
Managed identities are generally implemented in your application code through a class called `DefaultAzureCredential` from the `Azure.Identity` client library. `DefaultAzureCredential` supports multiple authentication methods and automatically determines which should be used at runtime. You can read more about this approach in the [DefaultAzureCredential overview](/dotnet/api/overview/azure/Identity-readme#defaultazurecredential).
3333

3434
## Connect an Azure hosted app to multiple Azure services
3535

3636
You have been tasked with connecting an existing app to multiple Azure services and databases using passwordless connections. The application is an ASP.NET Core Web API hosted on Azure App Service, though the steps below apply to other Azure hosting environments as well, such as Azure Spring Apps, Virtual Machines, Container Apps and AKS.
3737

3838
This tutorial applies to the following architectures, though it can be adapted to many other scenarios as well through minimal configuration changes.
3939

40-
:::image type="content" source="media/architecture-diagram-multiple-services-small.png" alt-text="A diagram showing the user assigned identity relationships." lightbox="media/architecture-diagram-multiple-services.png":::
40+
:::image type="content" source="media/architecture-diagram-multiple-services-small.png" alt-text="Diagram showing the user assigned identity relationships." lightbox="media/architecture-diagram-multiple-services.png":::
4141

42-
The following steps demonstrate how to configure an app to use a system-assigned managed identity and your local development account to connect to multiple Azure Services.
42+
The following steps demonstrate how to configure an app to use a system-assigned managed identity and your local development account to connect to multiple Azure Services.
4343

4444
### Create a system-assigned managed identity
4545

@@ -49,33 +49,33 @@ The following steps demonstrate how to configure an app to use a system-assigned
4949

5050
3) Toggle the **Status** setting to **On** to enable a system assigned managed identity for the service.
5151

52-
:::image type="content" source="media/enable-system-assigned-identity.png" alt-text="A screenshot showing how to assign a system assigned managed identity." :::
52+
:::image type="content" source="media/enable-system-assigned-identity.png" alt-text="Screenshot showing how to assign a system assigned managed identity." :::
5353

5454
### Assign roles to the managed identity for each connected service
55-
55+
5656
1) Navigate to the overview page of the storage account you would like to grant access your identity access to.
5757

5858
3) Select **Access Control (IAM)** from the storage account navigation.
5959

6060
4) Choose **+ Add** and then **Add role assignment**.
6161

62-
:::image type="content" source="media/assign-role-system-identity.png" alt-text="A screenshot showing how to assign a system-assigned identity." :::
62+
:::image type="content" source="media/assign-role-system-identity.png" alt-text="Screenshot showing how to assign a system-assigned identity." :::
6363

6464
5) In the **Role** search box, search for *Storage Blob Data Contributor*, which grants permissions to perform read and write operations on blob data. You can assign whatever role is appropriate for your use case. Select the *Storage Blob Data Contributor* from the list and choose **Next**.
6565

6666
6) On the **Add role assignment** screen, for the **Assign access to** option, select **Managed identity**. Then choose **+Select members**.
6767

6868
7) In the flyout, search for the managed identity you created by entering the name of your app service. Select the system assigned identity, and then choose **Select** to close the flyout menu.
6969

70-
:::image type="content" source="media/migration-select-identity.png" alt-text="A screenshot showing how to select a system-assigned identity." :::
70+
:::image type="content" source="media/migration-select-identity.png" alt-text="Screenshot showing how to select a system-assigned identity." :::
7171

7272
8) Select **Next** a couple times until you're able to select **Review + assign** to finish the role assignment.
7373

7474
9) Repeat this process for the other services you would like to connect to.
7575

7676
#### Local development considerations
7777

78-
You can also enable access to Azure resources for local development by assigning roles to a user account the same way you assigned roles to your managed identity.
78+
You can also enable access to Azure resources for local development by assigning roles to a user account the same way you assigned roles to your managed identity.
7979

8080
1) After assigning the **Storage Blob Data Contributor** role to your managed identity, under **Assign access to**, this time select **User, group or service principal**. Choose **+ Select members** to open the flyout menu again.
8181

@@ -115,9 +115,9 @@ var serviceBusClient = new ServiceBusClient("<your-namespace>", new DefaultAzure
115115
var sender = serviceBusClient.CreateSender("producttracking");
116116
```
117117

118-
#### [java](#tab/java)
118+
#### [Java](#tab/java)
119119

120-
Inside of your project, add dependency `azure-identity` to your pom.xml. This library contains all the necessary entities to implement `DefaultAzureCredential`. You can also add any other Azure dependencies that are relevant to your app. For this example, the `azure-storage-blob` and `azure-messaging-servicebus` dependencies are added in order to connect to Blob Storage and Key Vault.
120+
Inside your project, add the `azure-identity` dependency to your *pom.xml* file. This library contains all the necessary entities to implement `DefaultAzureCredential`. You can also add any other Azure dependencies that are relevant to your app. For this example, the `azure-storage-blob` and `azure-messaging-servicebus` dependencies are added in order to connect to Blob Storage and Key Vault.
121121

122122
```xml
123123
<dependencyManagement>
@@ -171,9 +171,9 @@ class Demo {
171171
}
172172
```
173173

174-
#### [spring](#tab/spring)
174+
#### [Spring](#tab/spring)
175175

176-
Inside of your project, only need to add service dependencies you use. For this example, the `spring-cloud-azure-starter-storage-blob` and `spring-cloud-azure-starter-servicebus` dependencies are added in order to connect to Blob Storage and Key Vault.
176+
Inside your project, only need to add service dependencies you use. For this example, the `spring-cloud-azure-starter-storage-blob` and `spring-cloud-azure-starter-servicebus` dependencies are added in order to connect to Blob Storage and Key Vault.
177177

178178
```xml
179179
<dependencyManagement>
@@ -239,9 +239,10 @@ This overall process ensures that your app can run securely locally and in Azure
239239

240240
Although the apps in the previous example all shared the same service access requirements, real environments are often more nuanced. Consider a scenario where multiple apps all connect to the same storage accounts, but two of the apps also access different services or databases.
241241

242-
:::image type="content" source="media/multiple-managed-identities-small.png" lightbox="media/multiple-managed-identities.png" alt-text="A diagram showing multiple user-assigned managed identities.":::
242+
:::image type="content" source="media/multiple-managed-identities-small.png" lightbox="media/multiple-managed-identities.png" alt-text="Diagram showing multiple user-assigned managed identities.":::
243243

244244
To configure this setup in your code, make sure your application registers separate services to connect to each storage account or database. Make sure to pull in the correct managed identity client IDs for each service when configuring `DefaultAzureCredential`. The following code example configures the following service connections:
245+
245246
* Two connections to separate storage accounts using a shared user-assigned managed identity
246247
* A connection to Azure Cosmos DB and Azure SQL services using a second shared user-assigned managed identity
247248

@@ -263,7 +264,7 @@ BlobServiceClient blobServiceClient = new BlobServiceClient(
263264
BlobServiceClient blobServiceClient2 = new BlobServiceClient(
264265
new Uri("https://<contract-storage-account>.blob.core.windows.net"),
265266
new DefaultAzureCredential()
266-
{
267+
{
267268
ManagedIdentityClientId = clientIDstorage
268269
});
269270

@@ -289,9 +290,9 @@ using (SqlConnection conn = new SqlConnection(ConnectionString1))
289290

290291
```
291292

292-
### [java](#tab/java)
293+
### [Java](#tab/java)
293294

294-
Add the following to your `pom.xml`:
295+
Add the following to your *pom.xml* file:
295296

296297
```xml
297298
<dependencyManagement>
@@ -374,9 +375,9 @@ class Demo {
374375
}
375376
```
376377

377-
### [spring](#tab/spring)
378+
### [Spring](#tab/spring)
378379

379-
Add the following to your `pom.xml`:
380+
Add the following to your *pom.xml* file:
380381

381382
```xml
382383
<dependencyManagement>
@@ -409,7 +410,8 @@ Add the following to your `pom.xml`:
409410
</dependency>
410411
</dependencies>
411412
```
412-
Add the following to your `application.yml`:
413+
414+
Add the following to your *application.yml* file:
413415

414416
```yaml
415417
spring:
@@ -433,7 +435,7 @@ spring:
433435
Add the following to your code:
434436
435437
> [!NOTE]
436-
> Spring Cloud Azure doesn't support configure multiple clients of the same service, the following codes create multiple beans for this situation.
438+
> Spring Cloud Azure doesn't support configure multiple clients of the same service, the following codes create multiple beans for this situation.
437439
438440
```java
439441
@Configuration
@@ -476,15 +478,15 @@ public class ExampleService {
476478

477479
You can also associate a user-assigned managed identity as well as a system-assigned managed identity to a resource simultaneously. This can be useful in scenarios where all of the apps require access to the same shared services, but one of the apps also has a very specific dependency on an additional service. Using a system-assigned identity also ensures that the identity tied to that specific app is deleted when the app is deleted, which can help keep your environment clean.
478480

479-
:::image type="content" lightbox="media/user-and-system-assigned-identities-small.png" source="media/user-and-system-assigned-identities.png" alt-text="A diagram showing user-assigned and system-assigned managed identities.":::
481+
:::image type="content" lightbox="media/user-and-system-assigned-identities-small.png" source="media/user-and-system-assigned-identities.png" alt-text="Diagram showing user-assigned and system-assigned managed identities.":::
480482

481483
These types of scenarios are explored in more depth in the [identities best practice recommendations](/azure/active-directory/managed-identities-azure-resources/managed-identity-best-practice-recommendations).
482484

483485
## Next steps
484486

485487
In this tutorial, you learned how to migrate an application to passwordless connections. You can read the following resources to explore the concepts discussed in this article in more depth:
486488

487-
- For more information on authorizing access with managed identity, visit [Authorize access to blob data with managed identities for Azure resources](/azure/storage/blobs/authorize-managed-identity).
488-
-[Authorize with Azure roles](/azure/storage/blobs/authorize-access-azure-active-directory)
489-
- To learn more about .NET Core, see [Get started with .NET in 10 minutes](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro).
490-
- To learn more about authorizing from a web application, visit [Authorize from a native or web application](/azure/storage/common/storage-auth-aad-app)
489+
* For more information on authorizing access with managed identity, visit [Authorize access to blob data with managed identities for Azure resources](/azure/storage/blobs/authorize-managed-identity).
490+
* [Authorize with Azure roles](/azure/storage/blobs/authorize-access-azure-active-directory)
491+
* To learn more about .NET Core, see [Get started with .NET in 10 minutes](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro).
492+
* To learn more about authorizing from a web application, visit [Authorize from a native or web application](/azure/storage/common/storage-auth-aad-app).

0 commit comments

Comments
 (0)