Skip to content

Commit f409d8a

Browse files
authored
Merge pull request #105953 from lisaguthrie/issue48647-kvrefsmsi
Updating to use ConfigureKeyVault from latest config provider
2 parents 670a6fd + a250f9f commit f409d8a

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

articles/azure-app-configuration/howto-integrate-azure-managed-service-identity.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,16 @@ To set up a managed identity in the portal, you first create an application and
140140
.ConfigureAppConfiguration((hostingContext, config) =>
141141
{
142142
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+
});
147153
})
148154
.UseStartup<Startup>();
149155
```
@@ -155,12 +161,18 @@ To set up a managed identity in the portal, you first create an application and
155161
Host.CreateDefaultBuilder(args)
156162
.ConfigureWebHostDefaults(webBuilder =>
157163
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+
});
164176
})
165177
.UseStartup<Startup>());
166178
```

0 commit comments

Comments
 (0)