services | platforms | author |
---|---|---|
key-vault |
nodejs |
lusitanian |
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.
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
-
If you don't already have it, get node.js.
-
Clone the repo.
git clone https://github.com/Azure-Samples/key-vault-node-authentication.git key-vault
-
Install the dependencies.
cd key-vault npm install
-
Create an Azure service principals, 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 sample.
node authentication_sample.js