You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the resource is created, select **Go to resource** to view the details of the managed identity.
90
+
89
91
#### Associate the managed identity with your web app
90
92
91
93
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
96
98
97
99
* Azure Spring Apps
98
100
* Azure Container Apps
99
-
* Azure virtual Machines
101
+
* Azure virtual machines
100
102
* Azure Kubernetes Service.
101
103
102
104
1. Navigate to the overview page of your web app.
103
105
1. Select **Identity** from the left navigation.
104
106
1. On the Identity page, switch to the **User assigned** tab.
105
107
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.
107
109
1. Search for the **MigrationIdentity** by name and select it from the search results.
108
110
1. Select **Add** to associate the identity with your app.
109
111
@@ -171,9 +173,29 @@ If you connected your services using the Service Connector you don't need to com
171
173
172
174
---
173
175
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
You will need to redeploy your code to Azure after making this change in order for the configuration updates to be applied.
195
+
174
196
#### Test the app
175
197
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.
0 commit comments