Skip to content

efredin/key-vault-node-authentication

 
 

Repository files navigation

services platforms author
key-vault
nodejs
lusitanian

Authentication sample for Azure Key Vault using the Azure Node 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.

Prerequisites

If you don't have an Azure subscription, please create a free account before you begin. In addition you would need

  • Node
    • Please install Node JS. This can be run on Windows, Mac and Linux.
  • Git
    • Please download git from here.
  • Azure CLI
    • For the purpose of this tutorial we would work with Azure CLI which is available on Windows, Mac and Linux

Quickstart

  1. If you don't already have it, get node.js.

  2. Clone the repo.

    git clone https://github.com/Azure-Samples/key-vault-node-authentication.git key-vault
    
  3. Install the dependencies.

    cd key-vault
    npm install
    
  4. Create an Azure service principals, using one of the following:

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

  5. 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 sample.

    node authentication_sample.js
    

References and further reading

About

Node.js Sample for Authenticating to Key Vault

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%