{"id":6759,"date":"2020-01-07T00:55:17","date_gmt":"2020-01-07T00:55:17","guid":{"rendered":"http:\/\/blogs.aaddevsup.xyz\/?p=6759"},"modified":"2020-07-02T17:49:35","modified_gmt":"2020-07-02T17:49:35","slug":"exploring-azureservicetokenprovider-class-with-azure-key-vault","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2020\/01\/exploring-azureservicetokenprovider-class-with-azure-key-vault\/","title":{"rendered":"Exploring AzureServiceTokenProvider class with Azure Key Vault and Azure SQL"},"content":{"rendered":"\n
The AzureServiceTokenProvider<\/a> class from the Nuget package Microsoft.Azure.Services.AppAuthentication<\/a> can be used to obtain an access token. When running in Azure it can also utilize managed identities<\/a> to request an access token. In this post I\u2019ll focus on using this class to get an access token for Azure Key Vault<\/a>. Keep in mind that you can also use this class to obtain an access token for any Azure resources integrated with Azure Active Directory. Below are some code sample showing a couple of ways to use this class to get an access token and call Azure Key Vault:<\/p>\n\n\n\n Note<\/strong>: Before trying out the following, you should make sure the signed-in principal (application or user) has access to Azure Key Vault. See my previous<\/a> blog post for more info on this and the Azure Key Vault documentation. For example, I have configured my Azure Key Vault to allow access to the following 2 users and 2 Applications in the Azure Key Vault\u2019s Access Policies blade:<\/p>\n\n\n\n