@@ -3,12 +3,12 @@ title: Quickstart - Azure Key Vault certificate client library for JavaScript (
3
3
description : Learn how to create, retrieve, and delete certificates from an Azure key vault using the JavaScript client library
4
4
author : msmbaldwin
5
5
ms.author : mbaldwin
6
- ms.date : 01/04 /2023
6
+ ms.date : 02/01 /2023
7
7
ms.service : key-vault
8
8
ms.subservice : certificates
9
9
ms.topic : quickstart
10
10
ms.devlang : javascript
11
- ms.custom : devx-track-js, mode-api
11
+ ms.custom : devx-track-js, mode-api, passwordless-js
12
12
---
13
13
14
14
# Quickstart: Azure Key Vault certificate client library for JavaScript (version 4)
@@ -84,30 +84,35 @@ Create a Node.js application that uses your key vault.
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
+ ---
111
116
112
117
## Code example
113
118
@@ -117,6 +122,20 @@ These code samples demonstrate how to create a client, set a certificate, retrie
117
122
118
123
1 . Create new text file and paste the following code into the ** index.js** file.
119
124
125
+ This code uses the following [ Key Vault Certificate classes and methods] ( /javascript/api/overview/azure/keyvault-certificates-readme ) :
126
+
127
+ * [ DefaultAzureCredential] ( /javascript/api/@azure/identity/#@azure-identity-getdefaultazurecredential )
128
+ * [ CertificateClient class] ( /javascript/api/@azure/keyvault-certificates/certificateclient )
129
+ * [ beginCreateCertificate] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-begincreatecertificate )
130
+ * [ getCertificate] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-getcertificate )
131
+ * [ getCertificateVersion] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-getcertificateversion )
132
+ * [ updateCertificateProperties] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-updatecertificateproperties )
133
+ * [ updateCertificatePolicy] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-updatecertificateproperties )
134
+ * [ beginDeleteCertificate] ( /javascript/api/@azure/keyvault-certificates/certificateclient#@azure-keyvault-certificates-certificateclient-begindeletecertificate )
135
+ * [ PollerLike Interface] ( /javascript/api/@azure/core-lro/pollerlike )
136
+ * [ getResult] ( /javascript/api/@azure/core-lro/pollerlike#@azure-core-lro-pollerlike-getresult )
137
+ * [ pollUntilDone] ( /javascript/api/@azure/core-lro/pollerlike@azure-core-lro-pollerlike-polluntildone )
138
+
120
139
``` javascript
121
140
const { CertificateClient , DefaultCertificatePolicy } = require (" @azure/keyvault-certificates" );
122
141
const { DefaultAzureCredential } = require (" @azure/identity" );
@@ -127,10 +146,10 @@ These code samples demonstrate how to create a client, set a certificate, retrie
127
146
// - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
128
147
// - AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
129
148
// - AZURE_CLIENT_SECRET: The client secret for the registered application
130
- const url = process .env [" AZURE_KEY_VAULT_URI" ] || " <keyvault-url>" ;
131
149
const credential = new DefaultAzureCredential ();
132
150
133
151
const keyVaultName = process .env [" KEY_VAULT_NAME" ];
152
+ if (! keyVaultName) throw new Error (" KEY_VAULT_NAME is empty" );
134
153
const url = " https://" + keyVaultName + " .vault.azure.net" ;
135
154
136
155
const client = new CertificateClient (url, credential);
0 commit comments