In the previous post, we used ClientSecretCredential Token Credential to read the secret from the Key Vault. In this post, we’d use UsernamePasswordCredential class instead.
Login to Azure Portal –
Here we have generated a Secret named secret1 inside MyKeyVaultCRM
We have also provided Get – Secret permission to the below User account
Also, we have registered an app
And enabled All public client flows for generating the token using username and password.
Let us create a console app to read the secret.
Add the following NuGet packages to the project.
Get the Vault URI and Directory ID (tenant id)
And the Client Id of the App registered
Sample source code:
We are using SecretClient class here.
Get all the details here
Hope it helps..