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 certificate client library for JavaScript
15
15
16
16
Get started with the Azure Key Vault certificate client library for JavaScript. [Azure Key Vault](../general/overview.md) is a cloud service that provides a secure store for certificates. 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 certificates from an Azure key vault using the JavaScript client library
@@ -76,42 +76,68 @@ Create a Node.js application that uses your key vault.
76
76
npm install @azure/keyvault-certificates
77
77
```
78
78
79
-
1. Install the Azure Identity library, [@azure/identity](https://www.npmjs.com/package/@azure/identity) package to authenticate to a Key Vault.
79
+
1. Install the Azure Identity client library, [@azure/identity](https://www.npmjs.com/package/@azure/identity), to authenticate to a Key Vault.
80
80
81
81
```terminal
82
82
npm install @azure/identity
83
83
```
84
84
85
85
## Grant access to your key vault
86
86
87
-
Create an access policy for your key vault that grants key permissions to your user account
87
+
Create a vault access policy for your key vault that grants key permissions to your user account.
88
88
89
89
```azurecli
90
-
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --key-permissions delete get list create purge
90
+
az keyvault set-policy --name <YourKeyVaultName> --upn [email protected] --certificate-permissions delete get list create purge update
91
91
```
92
92
93
93
## Set environment variables
94
94
95
95
This application is using key vault name as an environment variable called `KEY_VAULT_NAME`.
96
96
97
-
Windows
97
+
### [Windows](#tab/windows)
98
+
98
99
```cmd
99
100
set KEY_VAULT_NAME=<your-key-vault-name>
100
101
````
101
102
103
+
### [PowerShell](#tab/powershell)
104
+
102
105
Windows PowerShell
103
106
```powershell
104
107
$Env:KEY_VAULT_NAME="<your-key-vault-name>"
105
108
```
106
109
107
-
macOS or Linux
110
+
### [macOS or Linux](#tab/linux)
111
+
108
112
```cmd
109
113
export KEY_VAULT_NAME=<your-key-vault-name>
110
114
```
115
+
---
116
+
117
+
## Authenticate and create a client
118
+
119
+
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.
120
+
121
+
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).
122
+
123
+
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).
111
124
112
125
## Code example
113
126
114
-
These code samples demonstrate how to create a client, set a certificate, retrieve a certificate, and delete a certificate.
127
+
This code uses the following [Key Vault Certificate classes and methods](/javascript/api/overview/azure/keyvault-certificates-readme):
0 commit comments