@@ -140,10 +140,16 @@ To set up a managed identity in the portal, you first create an application and
140
140
.ConfigureAppConfiguration((hostingContext, config) =>
141
141
{
142
142
var settings = config.Build();
143
- AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider();
144
- KeyVaultClient kvClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
145
-
146
- config.AddAzureAppConfiguration(options => options.Connect(new Uri(settings["AppConfig:Endpoint"]), new ManagedIdentityCredential()).UseAzureKeyVault(kvClient));
143
+ var credentials = new ManagedIdentityCredential();
144
+
145
+ config.AddAzureAppConfiguration(options =>
146
+ {
147
+ options.Connect(new Uri(settings["AppConfig:Endpoint"]), credentials)
148
+ .ConfigureKeyVault(kv =>
149
+ {
150
+ kv.SetCredential(credentials);
151
+ });
152
+ });
147
153
})
148
154
.UseStartup<Startup>();
149
155
```
@@ -155,12 +161,18 @@ To set up a managed identity in the portal, you first create an application and
155
161
Host.CreateDefaultBuilder(args)
156
162
.ConfigureWebHostDefaults(webBuilder =>
157
163
webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
158
- {
159
- var settings = config.Build();
160
- AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider();
161
- KeyVaultClient kvClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
162
-
163
- config.AddAzureAppConfiguration(options => options.Connect(new Uri(settings["AppConfig:Endpoint"]), new ManagedIdentityCredential()).UseAzureKeyVault(kvClient));
164
+ {
165
+ var settings = config.Build();
166
+ var credentials = new ManagedIdentityCredential();
167
+
168
+ config.AddAzureAppConfiguration(options =>
169
+ {
170
+ options.Connect(new Uri(settings["AppConfig:Endpoint"]), credentials)
171
+ .ConfigureKeyVault(kv =>
172
+ {
173
+ kv.SetCredential(credentials);
174
+ });
175
+ });
164
176
})
165
177
.UseStartup<Startup>());
166
178
```
0 commit comments