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
@@ -86,31 +86,66 @@ 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
+
```azurecli
97
+
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --secret-permissions delete get list set purge
98
+
```
99
+
100
+
## Set environment variables
101
+
102
+
This application is using key vault name as an environment variable called `KEY_VAULT_NAME`.
103
+
104
+
### [Windows](#tab/windows)
105
+
97
106
```cmd
98
107
set KEY_VAULT_NAME=<your-key-vault-name>
99
108
````
100
109
110
+
### [PowerShell](#tab/powershell)
111
+
101
112
Windows PowerShell
102
113
```powershell
103
114
$Env:KEY_VAULT_NAME="<your-key-vault-name>"
104
115
```
105
116
106
-
macOS or Linux
117
+
### [macOS or Linux](#tab/linux)
118
+
107
119
```cmd
108
120
export KEY_VAULT_NAME=<your-key-vault-name>
109
121
```
122
+
---
123
+
124
+
## Authenticate and create a client
125
+
126
+
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.
127
+
128
+
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).
129
+
130
+
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
131
111
132
## Code example
112
133
113
-
This code sample demonstrates how to create a client, set a key, retrieve a key, and delete a key.
134
+
The code samples below will show you how to create a client, set a secret, retrieve a secret, and delete a secret.
135
+
136
+
This code uses the following [Key Vault Secret classes and methods](/javascript/api/overview/azure/keyvault-keys-readme):
0 commit comments