Authentication sample for Azure Key Vault using the Azure .NET SDK
This sample repo demonstrates how to connect and authenticate to an Azure Key Vault vault. To do so, it first uses the Key Vault Management Client to create a vault. The Key Vault client is then used to authenticate to the vault and set/retrieve a sample secret.
How to run this sample
If you don't already have it, get and install .NET
Clone the repo.
git clone https://github.com/Azure-Samples/key-vault-dotnet-authentication.git key-vault
cd key-vault
Create an Azure service principal, using one of the following:
This service principal is to run the sample on your Azure account.
Set the following environment variables using the information from the service principal that you created.
export AZURE_SUBSCRIPTION_ID={your subscription id}
export AZURE_CLIENT_ID={your client id}
export AZURE_CLIENT_SECRET={your client secret}
export AZURE_TENANT_ID={your tenant id as a GUID}
export AZURE_CLIENT_OID={Object id of the service principal}
On Windows, use
set
instead ofexport
.
Run the project with
dotnet run