0

We're trying to migrate a net6.0 console from ADAL to MSAL. After removing packages- Microsoft.Extensions.Configuration.AzureKeyVault and Microsoft.IdentityModel.Clients.ActiveDirectory, we're getting compile time errors on AzureServiceTokenProvider, KeyVaultClient and AddAzureKeyVault shown below. How should we replace the following block of code to provide the same functionality but using MSAL packages?

MyJobOption jobOption = Configuration.GetSection("MyJobOption").Get<MyJobOption>();
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
// The following line causes CS1061: 'ConfigurationBuilder' does not contain a definition for 'AddAzureKeyVault' without the Microsoft.Extensions.Configuration.AzureKeyVault package
Configuration = configBuilder.AddAzureKeyVault(
    new AzureKeyVaultConfigurationOptions()
    {
        Vault = jobOption.KeyVaultUrl,
        Client = keyVaultClient,
        Manager = new DefaultKeyVaultSecretManager()
    })
    .Build();
services.AddSingleton(Configuration);
samsu
  • 63
  • 8

0 Answers0