Skip to content

Commit 2d31781

Browse files
committed
client id
1 parent a5108d5 commit 2d31781

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Once your application is configured to use passwordless connections and runs loc
8686

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

89+
After the resource is created, select **Go to resource** to view the details of the managed identity.
90+
8991
#### Associate the managed identity with your web app
9092

9193
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.
@@ -96,14 +98,14 @@ Complete the following steps to use the Azure portal to associate an identity wi
9698

9799
* Azure Spring Apps
98100
* Azure Container Apps
99-
* Azure virtual Machines
101+
* Azure virtual machines
100102
* Azure Kubernetes Service.
101103

102104
1. Navigate to the overview page of your web app.
103105
1. Select **Identity** from the left navigation.
104106
1. On the Identity page, switch to the **User assigned** tab.
105107
1. Select **+ Add** to open the **Add user assigned managed identity** flyout.
106-
1. Select the subscription you used previously to create the **MigrationIdentity**.
108+
1. Select the subscription you used previously to create the identity.
107109
1. Search for the **MigrationIdentity** by name and select it from the search results.
108110
1. Select **Add** to associate the identity with your app.
109111

@@ -171,9 +173,29 @@ If you connected your services using the Service Connector you don't need to com
171173

172174
---
173175

176+
#### Update the application code
177+
178+
You need to configure your application code to look for the specific managed identity you created when it is deployed to Azure. Explicitly setting the managed identity for the app also prevents other environment identities from accidentally being detected and used automatically.
179+
180+
1. On the managed identity overview page, copy the client ID value to your clipboard.
181+
1. Update the `DefaultAzureCredential` object in the `Program.cs` file of your app to specify this managed identity client ID.
182+
183+
```csharp
184+
// TODO: Update the <your-storage-account-name> and <your-managed-identity-client-id> placeholders
185+
var blobServiceClient = new BlobServiceClient(
186+
new Uri("https://<your-storage-account-name>.blob.core.windows.net"),
187+
new DefaultAzureCredential(
188+
new DefaultAzureCredentialOptions()
189+
{
190+
ManagedIdentityClientId = "<your-managed-identity-client-id>"
191+
}));
192+
```
193+
194+
You will need to redeploy your code to Azure after making this change in order for the configuration updates to be applied.
195+
174196
#### Test the app
175197

176-
After making these code changes, 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.
198+
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.
177199

178200
## Next steps
179201

includes/passwordless/migration-guide/service-connector-commands.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ You can use Service Connector to create a connection between an Azure compute ho
22

33
1. Retrieve the client-id of the managed identity you created using the `az identity show` command. Copy the value for later use.
44

5-
```azurecli
6-
az identity show --name MigrationIdentity --resource-group <your-resource-group> --query clientId
7-
```
5+
```azurecli
6+
az identity show --name MigrationIdentity --resource-group <your-resource-group> --query clientId
7+
```
88
99
1. Use the appropriate CLI command to establish the service connection:
1010

0 commit comments

Comments
 (0)