Skip to content

Commit 3bc888d

Browse files
authored
Merge pull request #232707 from alexwolfmsft/refactor-conceptual-content
Refactor conceptual content
2 parents 01068c9 + c7d532e commit 3bc888d

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

articles/storage/common/migrate-azure-credentials.md

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,24 @@ ms.devlang: csharp
1515

1616
# Migrate an application to use passwordless connections with Azure Storage
1717

18-
Application requests to Azure Storage must be authenticated using either account access keys or passwordless connections. However, you should prioritize passwordless connections in your applications when possible. This tutorial explores how to migrate from traditional authentication methods to more secure, passwordless connections.
18+
Application requests to Azure Storage must be authenticated using either account access keys or passwordless connections. However, you should prioritize passwordless connections in your applications when possible. Traditional authentication methods that use passwords or secret keys create additional security risks and complications. Visit the [passwordless connections for Azure services](/azure/developer/intro/passwordless-overview) hub to learn more about the advantages of moving to passwordless connections.
1919

20-
## Security risks associated with Shared Key authorization
20+
The following tutorial explains how to migrate an existing application to connect to Azure Storage to use passwordless connections instead of a key-based solution. These same migration steps should apply whether you're using access keys directly, or through connection strings.
2121

22-
The following code example demonstrates how to connect to Azure Storage using a storage account key. When you create a storage account, Azure generates access keys for that account. Many developers gravitate towards this solution because it feels familiar to options they've worked with in the past. For example, connection strings for storage accounts also use access keys as part of the string. If your application currently uses access keys, consider migrating to passwordless connections using the steps described later in this document.
23-
24-
```csharp
25-
var blobServiceClient = new BlobServiceClient(
26-
new Uri("https://<storage-account-name>.blob.core.windows.net"),
27-
new StorageSharedKeyCredential("<storage-account-name>", "<your-access-key>"));
28-
```
29-
30-
Storage account keys should be used with caution. Developers must be diligent to never expose the keys in an unsecure location. Anyone who gains access to the key is able to authenticate. For example, if an account key is accidentally checked into source control, sent through an unsecure email, or viewed by someone who shouldn't have permission, there's risk of a malicious user accessing the application. Instead, consider updating your application to use passwordless connections.
31-
32-
## Migrate to passwordless connections
33-
34-
[!INCLUDE [migrate-to-passwordless-overview](../../../includes/passwordless/migration-guide/migrate-to-passwordless-overview.md)]
35-
36-
## Steps to migrate an app to use passwordless authentication
37-
38-
The following steps explain how to migrate an existing application to use passwordless connections instead of a key-based solution. These same migration steps should apply whether you're using access keys directly, or through connection strings.
39-
40-
### Configure roles and users for local development authentication
22+
## Configure roles and users for local development authentication
4123

4224
[!INCLUDE [assign-roles](../../../includes/assign-roles.md)]
4325

44-
### Sign-in and migrate the app code to use passwordless connections
26+
## Sign-in and migrate the app code to use passwordless connections
4527

4628
For local development, make sure you're authenticated with the same Azure AD account you assigned the role to on your Blob Storage account. You can authenticate via the Azure CLI, Visual Studio, Azure PowerShell, or other tools such as IntelliJ.
4729

4830
[!INCLUDE [default-azure-credential-sign-in](../../../includes/passwordless/default-azure-credential-sign-in.md)]
4931

5032
Next you need to update your code to use passwordless connections.
5133

34+
## [.NET](#tab/dotnet)
35+
5236
1. To use `DefaultAzureCredential` in a .NET application, add the **Azure.Identity** NuGet package to your application.
5337

5438
```dotnetcli
@@ -74,23 +58,25 @@ Next you need to update your code to use passwordless connections.
7458

7559
:::image type="content" source="../blobs/media/storage-quickstart-blobs-dotnet/storage-account-name.png" alt-text="Screenshot showing how to find the storage account name.":::
7660

77-
#### Run the app locally
61+
---
62+
63+
### Run the app locally
7864

7965
After making these code changes, run your application locally. The new configuration should pick up your local credentials, such as the Azure CLI, Visual Studio, or IntelliJ. The roles you assigned to your local dev user in Azure allows your app to connect to the Azure service locally.
8066

81-
### Configure the Azure hosting environment
67+
## Configure the Azure hosting environment
8268

8369
Once your application is configured to use passwordless connections and runs locally, the same code can authenticate to Azure services after it's deployed to Azure. The sections that follow explain how to configure a deployed application to connect to Azure Blob Storage using a managed identity.
8470

85-
#### Create the managed identity
71+
### Create the managed identity
8672

8773
[!INCLUDE [create-managed-identity](../../../includes/passwordless/migration-guide/create-user-assigned-managed-identity.md)]
8874

8975
#### Associate the managed identity with your web app
9076

9177
You need to configure your web app to use the managed identity you created. Assign the identity to your app using either the Azure portal or the Azure CLI.
9278

93-
# [Azure Portal](#tab/azure-portal-associate)
79+
# [Azure portal](#tab/azure-portal-associate)
9480

9581
Complete the following steps in the Azure portal to associate an identity with your app. These same steps apply to the following Azure services:
9682

@@ -119,7 +105,7 @@ Complete the following steps in the Azure portal to associate an identity with y
119105

120106
---
121107

122-
#### Assign roles to the managed identity
108+
### Assign roles to the managed identity
123109

124110
Next, you need to grant permissions to the managed identity you created to access your storage account. Grant permissions by assigning a role to the managed identity, just like you did with your local development user.
125111

@@ -167,10 +153,12 @@ If you connected your services using Service Connector you don't need to complet
167153

168154
---
169155

170-
#### Update the application code
156+
### Update the application code
171157

172158
You need to configure your application code to look for the specific managed identity you created when it is deployed to Azure. In some scenarios, explicitly setting the managed identity for the app also prevents other environment identities from accidentally being detected and used automatically.
173159

160+
## [.NET](#tab/dotnet)
161+
174162
1. On the managed identity overview page, copy the client ID value to your clipboard.
175163
1. Update the `DefaultAzureCredential` object in the `Program.cs` file of your app to specify this managed identity client ID.
176164

@@ -187,7 +175,9 @@ You need to configure your application code to look for the specific managed ide
187175

188176
3. Redeploy your code to Azure after making this change in order for the configuration updates to be applied.
189177

190-
#### Test the app
178+
---
179+
180+
### Test the app
191181

192182
After deploying the updated code, browse to your hosted application in the browser. Your app should be able to connect to the storage account successfully. Keep in mind that it may take several minutes for the role assignments to propagate through your Azure environment. Your application is now configured to run both locally and in a production environment without the developers having to manage secrets in the application itself.
193183

0 commit comments

Comments
 (0)