Skip to content

Azure-Samples/key-vault-dotnet-authentication

Repository files navigation

services platforms author
key-vault
dotnet
lusitanian

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

  1. If you don't already have it, get and install .NET

  2. Clone the repo.

    git clone https://github.com/Azure-Samples/key-vault-dotnet-authentication.git key-vault
    cd key-vault
    
  3. Create an Azure service principal, using one of the following:

    This service principal is to run the sample on your Azure account.

  4. 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 of export.

  1. Run the project with dotnet run

About

.NET Key Vault Authentication Sample

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages