You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Quickstart: Azure Key Vault key client library for JavaScript
15
15
16
16
Get started with the Azure Key Vault key client library for JavaScript. [Azure Key Vault](../general/overview.md) is a cloud service that provides a secure store for cryptographic keys. You can securely store keys, passwords, certificates, and other secrets. Azure key vaults may be created and managed through the Azure portal. In this quickstart, you learn how to create, retrieve, and delete keys from an Azure key vault using the JavaScript key client library
@@ -68,13 +68,13 @@ Create a Node.js application that uses your key vault.
68
68
69
69
## Install Key Vault packages
70
70
71
-
1. Using the terminal, install the Azure Key Vault secrets library, [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) for Node.js.
71
+
1. Using the terminal, install the Azure Key Vault secrets client library, [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) for Node.js.
72
72
73
73
```terminal
74
74
npm install @azure/keyvault-keys
75
75
```
76
76
77
-
1. Install the Azure Identity library, [@azure/identity](https://www.npmjs.com/package/@azure/identity) package to authenticate to a Key Vault.
77
+
1. Install the Azure Identity client library, [@azure/identity](https://www.npmjs.com/package/@azure/identity) package to authenticate to a Key Vault.
78
78
79
79
```terminal
80
80
npm install @azure/identity
@@ -86,31 +86,58 @@ Create a Node.js application that uses your key vault.
86
86
Create an access policy for your key vault that grants key permissions to your user account
87
87
88
88
```azurecli
89
-
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --key-permissions delete get list create purge
89
+
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --key-permissions delete get list create update purge
90
90
```
91
91
92
92
## Set environment variables
93
93
94
94
This application is using key vault name as an environment variable called `KEY_VAULT_NAME`.
95
95
96
-
Windows
96
+
### [Windows](#tab/windows)
97
+
97
98
```cmd
98
99
set KEY_VAULT_NAME=<your-key-vault-name>
99
100
````
100
101
102
+
### [PowerShell](#tab/powershell)
103
+
101
104
Windows PowerShell
102
105
```powershell
103
106
$Env:KEY_VAULT_NAME="<your-key-vault-name>"
104
107
```
105
108
106
-
macOS or Linux
109
+
### [macOS or Linux](#tab/linux)
110
+
107
111
```cmd
108
112
export KEY_VAULT_NAME=<your-key-vault-name>
109
113
```
114
+
---
115
+
116
+
## Authenticate and create a client
117
+
118
+
Application requests to most Azure services must be authorized. Using the [DefaultAzureCredential](/javascript/api/@azure/identity/#@azure-identity-getdefaultazurecredential) method provided by the [Azure Identity client library](/javascript/api/@azure/identity) is the recommended approach for implementing passwordless connections to Azure services in your code. `DefaultAzureCredential` supports multiple authentication methods and determines which method should be used at runtime. This approach enables your app to use different authentication methods in different environments (local vs. production) without implementing environment-specific code.
119
+
120
+
In this quickstart, `DefaultAzureCredential` authenticates to key vault using the credentials of the local development user logged into the Azure CLI. When the application is deployed to Azure, the same `DefaultAzureCredential` code can automatically discover and use a managed identity that is assigned to an App Service, Virtual Machine, or other services. For more information, see [Managed Identity Overview](/azure/active-directory/managed-identities-azure-resources/overview).
121
+
122
+
In this code, the name of your key vault is used to create the key vault URI, in the format `https://<your-key-vault-name>.vault.azure.net`. For more information about authenticating to key vault, see [Developer's Guide](/azure/key-vault/general/developers-guide#authenticate-to-key-vault-in-code).
110
123
111
124
## Code example
112
125
113
-
This code sample demonstrates how to create a client, set a key, retrieve a key, and delete a key.
126
+
The code samples below will show you how to create a client, set a secret, retrieve a secret, and delete a secret.
127
+
128
+
This code uses the following [Key Vault Secret classes and methods](/javascript/api/overview/azure/keyvault-keys-readme):
0 commit comments