Authentication sample for Azure Key Vault using the Azure .NET SDK

Автор: David Desberg
Последнее обновление: 05.02.2018
Редактирование в GitHub

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
  1. Create an Azure service principal, using one of the following:

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

  2. 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

  2. Azure SDK for .NET

  3. Azure KeyVault Documentation

  4. Key Vault REST API Reference

  5. Manage Key Vault using CLI

  6. Storing and using secrets in Azure

Другие примеры от David Desberg