@azure/keyvault-certificates 4.9.1-alpha.20250206.1 → 4.9.1-alpha.20250211.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,12 +71,22 @@ class CertificateClient {
71
71
  * in the response. No values are returned for the certificates. This operations requires the certificates/list permission.
72
72
  *
73
73
  * Example usage:
74
- * ```ts
75
- * const client = new CertificateClient(url, credentials);
74
+ * ```ts snippet:IndexListCertificates
75
+ * import { DefaultAzureCredential } from "@azure/identity";
76
+ * import { CertificateClient } from "@azure/keyvault-certificates";
77
+ *
78
+ * const credential = new DefaultAzureCredential();
79
+ *
80
+ * const vaultName = "<YOUR KEYVAULT NAME>";
81
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
82
+ *
83
+ * const client = new CertificateClient(keyVaultUrl, credential);
84
+ *
76
85
  * // All in one call
77
86
  * for await (const certificateProperties of client.listPropertiesOfCertificates()) {
78
87
  * console.log(certificateProperties);
79
88
  * }
89
+ *
80
90
  * // By pages
81
91
  * for await (const page of client.listPropertiesOfCertificates().byPage()) {
82
92
  * for (const certificateProperties of page) {
@@ -95,9 +105,20 @@ class CertificateClient {
95
105
  * vault. This operation requires the certificates/list permission.
96
106
  *
97
107
  * Example usage:
98
- * ```ts
99
- * const client = new CertificateClient(url, credentials);
100
- * for await (const certificateProperties of client.listPropertiesOfCertificateVersions("MyCertificate")) {
108
+ * ```ts snippet:IndexListCertificateVersions
109
+ * import { DefaultAzureCredential } from "@azure/identity";
110
+ * import { CertificateClient } from "@azure/keyvault-certificates";
111
+ *
112
+ * const credential = new DefaultAzureCredential();
113
+ *
114
+ * const vaultName = "<YOUR KEYVAULT NAME>";
115
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
116
+ *
117
+ * const client = new CertificateClient(keyVaultUrl, credential);
118
+ *
119
+ * for await (const certificateProperties of client.listPropertiesOfCertificateVersions(
120
+ * "MyCertificate",
121
+ * )) {
101
122
  * console.log(certificateProperties.version!);
102
123
  * }
103
124
  * ```
@@ -116,25 +137,38 @@ class CertificateClient {
116
137
  * This operation requires the certificates/delete permission.
117
138
  *
118
139
  * Example usage:
119
- * ```ts
120
- * const client = new CertificateClient(url, credentials);
121
- * const createPoller = await client.beginCreateCertificate("MyCertificate", {
122
- * issuerName: "Self",
123
- * subject: "cn=MyCert"
124
- * });
125
- * await createPoller.pollUntilDone();
140
+ * ```ts snippet:ReadmeSampleDeleteCertificate
141
+ * import { DefaultAzureCredential } from "@azure/identity";
142
+ * import { CertificateClient } from "@azure/keyvault-certificates";
126
143
  *
127
- * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
144
+ * const credential = new DefaultAzureCredential();
128
145
  *
129
- * // Serializing the poller
130
- * const serialized = deletePoller.toString();
146
+ * const vaultName = "<YOUR KEYVAULT NAME>";
147
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
131
148
  *
132
- * // A new poller can be created with:
133
- * // const newPoller = await client.beginDeleteCertificate("MyCertificate", { resumeFrom: serialized });
149
+ * const client = new CertificateClient(keyVaultUrl, credential);
134
150
  *
135
- * // Waiting until it's done
136
- * const deletedCertificate = await deletePoller.pollUntilDone();
137
- * console.log(deletedCertificate);
151
+ * const certificateName = "MyCertificate";
152
+ *
153
+ * const poller = await client.beginDeleteCertificate(certificateName);
154
+ *
155
+ * // You can use the deleted certificate immediately:
156
+ * const deletedCertificate = poller.getResult();
157
+ *
158
+ * // The certificate is being deleted. Only wait for it if you want to restore it or purge it.
159
+ * await poller.pollUntilDone();
160
+ *
161
+ * // You can also get the deleted certificate this way:
162
+ * await client.getDeletedCertificate(certificateName);
163
+ *
164
+ * // Deleted certificates can also be recovered or purged.
165
+ *
166
+ * // recoverDeletedCertificate returns a poller, just like beginDeleteCertificate.
167
+ * // const recoverPoller = await client.beginRecoverDeletedCertificate(certificateName);
168
+ * // await recoverPoller.pollUntilDone();
169
+ *
170
+ * // If a certificate is done and the Key Vault has soft-delete enabled, the certificate can be purged with:
171
+ * await client.purgeDeletedCertificate(certificateName);
138
172
  * ```
139
173
  * Deletes a certificate from a specified key vault.
140
174
  * @param certificateName - The name of the certificate.
@@ -150,13 +184,17 @@ class CertificateClient {
150
184
  * Deletes all of the certificate contacts. This operation requires the certificates/managecontacts permission.
151
185
  *
152
186
  * Example usage:
153
- * ```ts
154
- * let client = new CertificateClient(url, credentials);
155
- * await client.setContacts([{
156
- * email: "b@b.com",
157
- * name: "b",
158
- * phone: "222222222222"
159
- * }]);
187
+ * ```ts snippet:CertificateClientDeleteContacts
188
+ * import { DefaultAzureCredential } from "@azure/identity";
189
+ * import { CertificateClient } from "@azure/keyvault-certificates";
190
+ *
191
+ * const credential = new DefaultAzureCredential();
192
+ *
193
+ * const vaultName = "<YOUR KEYVAULT NAME>";
194
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
195
+ *
196
+ * const client = new CertificateClient(keyVaultUrl, credential);
197
+ *
160
198
  * await client.deleteContacts();
161
199
  * ```
162
200
  * Deletes all of the certificate contacts
@@ -175,13 +213,24 @@ class CertificateClient {
175
213
  * Sets the certificate contacts for the key vault. This operation requires the certificates/managecontacts permission.
176
214
  *
177
215
  * Example usage:
178
- * ```ts
179
- * let client = new CertificateClient(url, credentials);
180
- * await client.setContacts([{
181
- * email: "b@b.com",
182
- * name: "b",
183
- * phone: "222222222222"
184
- * }]);
216
+ * ```ts snippet:CertificateClientSetContacts
217
+ * import { DefaultAzureCredential } from "@azure/identity";
218
+ * import { CertificateClient } from "@azure/keyvault-certificates";
219
+ *
220
+ * const credential = new DefaultAzureCredential();
221
+ *
222
+ * const vaultName = "<YOUR KEYVAULT NAME>";
223
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
224
+ *
225
+ * const client = new CertificateClient(keyVaultUrl, credential);
226
+ *
227
+ * await client.setContacts([
228
+ * {
229
+ * email: "b@b.com",
230
+ * name: "b",
231
+ * phone: "222222222222",
232
+ * },
233
+ * ]);
185
234
  * ```
186
235
  * Sets the certificate contacts.
187
236
  * @param contacts - The contacts to use
@@ -202,15 +251,21 @@ class CertificateClient {
202
251
  * Returns the set of certificate contact resources in the specified key vault. This operation requires the certificates/managecontacts permission.
203
252
  *
204
253
  * Example usage:
205
- * ```ts
206
- * let client = new CertificateClient(url, credentials);
207
- * await client.setContacts([{
208
- * email: "b@b.com",
209
- * name: "b",
210
- * phone: "222222222222"
211
- * }]);
254
+ * ```ts snippet:CertificateClientGetContacts
255
+ * import { DefaultAzureCredential } from "@azure/identity";
256
+ * import { CertificateClient } from "@azure/keyvault-certificates";
257
+ *
258
+ * const credential = new DefaultAzureCredential();
259
+ *
260
+ * const vaultName = "<YOUR KEYVAULT NAME>";
261
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
262
+ *
263
+ * const client = new CertificateClient(keyVaultUrl, credential);
264
+ *
212
265
  * const contacts = await client.getContacts();
213
- * console.log(contacts);
266
+ * for (const contact of contacts) {
267
+ * console.log(contact);
268
+ * }
214
269
  * ```
215
270
  * Sets the certificate contacts.
216
271
  * @param options - The optional parameters
@@ -225,13 +280,24 @@ class CertificateClient {
225
280
  * Returns the set of certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
226
281
  *
227
282
  * Example usage:
228
- * ```ts
229
- * const client = new CertificateClient(url, credentials);
283
+ * ```ts snippet:CertificateClientListIssuers
284
+ * import { DefaultAzureCredential } from "@azure/identity";
285
+ * import { CertificateClient } from "@azure/keyvault-certificates";
286
+ *
287
+ * const credential = new DefaultAzureCredential();
288
+ *
289
+ * const vaultName = "<YOUR KEYVAULT NAME>";
290
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
291
+ *
292
+ * const client = new CertificateClient(keyVaultUrl, credential);
293
+ *
230
294
  * await client.createIssuer("IssuerName", "Test");
295
+ *
231
296
  * // All in one call
232
297
  * for await (const issuerProperties of client.listPropertiesOfIssuers()) {
233
298
  * console.log(issuerProperties);
234
299
  * }
300
+ *
235
301
  * // By pages
236
302
  * for await (const page of client.listPropertiesOfIssuers().byPage()) {
237
303
  * for (const issuerProperties of page) {
@@ -250,8 +316,17 @@ class CertificateClient {
250
316
  * operation requires the certificates/setissuers permission.
251
317
  *
252
318
  * Example usage:
253
- * ```ts
254
- * const client = new CertificateClient(url, credentials);
319
+ * ```ts snippet:CertificateClientCreateIssuer
320
+ * import { DefaultAzureCredential } from "@azure/identity";
321
+ * import { CertificateClient } from "@azure/keyvault-certificates";
322
+ *
323
+ * const credential = new DefaultAzureCredential();
324
+ *
325
+ * const vaultName = "<YOUR KEYVAULT NAME>";
326
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
327
+ *
328
+ * const client = new CertificateClient(keyVaultUrl, credential);
329
+ *
255
330
  * await client.createIssuer("IssuerName", "Test");
256
331
  * ```
257
332
  * Sets the specified certificate issuer.
@@ -297,11 +372,19 @@ class CertificateClient {
297
372
  * entity. This operation requires the certificates/setissuers permission.
298
373
  *
299
374
  * Example usage:
300
- * ```ts
301
- * const client = new CertificateClient(url, credentials);
302
- * await client.createIssuer("IssuerName", "Test");
375
+ * ```ts snippet:CertificateClientUpdateIssuer
376
+ * import { DefaultAzureCredential } from "@azure/identity";
377
+ * import { CertificateClient } from "@azure/keyvault-certificates";
378
+ *
379
+ * const credential = new DefaultAzureCredential();
380
+ *
381
+ * const vaultName = "<YOUR KEYVAULT NAME>";
382
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
383
+ *
384
+ * const client = new CertificateClient(keyVaultUrl, credential);
385
+ *
303
386
  * await client.updateIssuer("IssuerName", {
304
- * provider: "Provider2"
387
+ * provider: "Provider2",
305
388
  * });
306
389
  * ```
307
390
  * Updates the specified certificate issuer.
@@ -349,9 +432,17 @@ class CertificateClient {
349
432
  * permission.
350
433
  *
351
434
  * Example usage:
352
- * ```ts
353
- * const client = new CertificateClient(url, credentials);
354
- * await client.createIssuer("IssuerName", "Test");
435
+ * ```ts snippet:CertificateClientGetIssuer
436
+ * import { DefaultAzureCredential } from "@azure/identity";
437
+ * import { CertificateClient } from "@azure/keyvault-certificates";
438
+ *
439
+ * const credential = new DefaultAzureCredential();
440
+ *
441
+ * const vaultName = "<YOUR KEYVAULT NAME>";
442
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
443
+ *
444
+ * const client = new CertificateClient(keyVaultUrl, credential);
445
+ *
355
446
  * const certificateIssuer = await client.getIssuer("IssuerName");
356
447
  * console.log(certificateIssuer);
357
448
  * ```
@@ -370,9 +461,17 @@ class CertificateClient {
370
461
  * the vault. This operation requires the certificates/manageissuers/deleteissuers permission.
371
462
  *
372
463
  * Example usage:
373
- * ```ts
374
- * const client = new CertificateClient(url, credentials);
375
- * await client.createIssuer("IssuerName", "Provider");
464
+ * ```ts snippet:CertificateClientDeleteIssuer
465
+ * import { DefaultAzureCredential } from "@azure/identity";
466
+ * import { CertificateClient } from "@azure/keyvault-certificates";
467
+ *
468
+ * const credential = new DefaultAzureCredential();
469
+ *
470
+ * const vaultName = "<YOUR KEYVAULT NAME>";
471
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
472
+ *
473
+ * const client = new CertificateClient(keyVaultUrl, credential);
474
+ *
376
475
  * await client.deleteIssuer("IssuerName");
377
476
  * ```
378
477
  * Deletes the specified certificate issuer.
@@ -394,26 +493,31 @@ class CertificateClient {
394
493
  * This operation requires the certificates/create permission.
395
494
  *
396
495
  * Example usage:
397
- * ```ts
398
- * const client = new CertificateClient(url, credentials);
496
+ * ```ts snippet:ReadmeSampleCreateCertificatePoller
497
+ * import { DefaultAzureCredential } from "@azure/identity";
498
+ * import { CertificateClient } from "@azure/keyvault-certificates";
499
+ *
500
+ * const credential = new DefaultAzureCredential();
501
+ *
502
+ * const vaultName = "<YOUR KEYVAULT NAME>";
503
+ * const url = `https://${vaultName}.vault.azure.net`;
504
+ *
505
+ * const client = new CertificateClient(url, credential);
506
+ *
507
+ * const certificateName = "MyCertificateName";
399
508
  * const certificatePolicy = {
400
509
  * issuerName: "Self",
401
- * subject: "cn=MyCert"
510
+ * subject: "cn=MyCert",
402
511
  * };
403
- * const createPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy);
404
512
  *
405
- * // The pending certificate can be obtained by calling the following method:
406
- * const pendingCertificate = createPoller.getResult();
513
+ * const poller = await client.beginCreateCertificate(certificateName, certificatePolicy);
407
514
  *
408
- * // Serializing the poller
409
- * const serialized = createPoller.toString();
410
- *
411
- * // A new poller can be created with:
412
- * // const newPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy, { resumeFrom: serialized });
515
+ * // You can use the pending certificate immediately:
516
+ * const pendingCertificate = poller.getResult();
413
517
  *
414
- * // Waiting until it's done
415
- * const certificate = await createPoller.pollUntilDone();
416
- * console.log(certificate);
518
+ * // Or you can wait until the certificate finishes being signed:
519
+ * const keyVaultCertificate = await poller.pollUntilDone();
520
+ * console.log(keyVaultCertificate);
417
521
  * ```
418
522
  * Creates a certificate
419
523
  * @param certificateName - The name of the certificate
@@ -439,15 +543,21 @@ class CertificateClient {
439
543
  * Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission.
440
544
  *
441
545
  * Example usage:
442
- * ```ts
443
- * const client = new CertificateClient(url, credentials);
444
- * const poller = await client.beginCreateCertificate("MyCertificate", {
445
- * issuerName: "Self",
446
- * subject: "cn=MyCert"
447
- * });
448
- * await poller.pollUntilDone();
449
- * const certificate = await client.getCertificate("MyCertificate");
450
- * console.log(certificate);
546
+ * ```ts snippet:CertificateClientGetCertificate
547
+ * import { DefaultAzureCredential } from "@azure/identity";
548
+ * import { CertificateClient } from "@azure/keyvault-certificates";
549
+ *
550
+ * const credential = new DefaultAzureCredential();
551
+ *
552
+ * const vaultName = "<YOUR KEYVAULT NAME>";
553
+ * const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
554
+ *
555
+ * const client = new CertificateClient(keyVaultUrl, credential);
556
+ *
557
+ * const certificateName = "MyCertificate";
558
+ *
559
+ * const result = await client.getCertificate(certificateName);
560
+ * console.log(result.name);
451
561
  * ```
452
562
  * Retrieves a certificate from the certificate's name (includes the certificate policy)
453
563
  * @param certificateName - The name of the certificate
@@ -463,16 +573,29 @@ class CertificateClient {
463
573
  * Gets information about a specific certificate on a specific version. It won't return the certificate's policy. This operation requires the certificates/get permission.
464
574
  *
465
575
  * Example usage:
466
- * ```ts
467
- * const client = new CertificateClient(url, credentials);
468
- * const poller = await client.beginCreateCertificate("MyCertificate", {
469
- * issuerName: "Self",
470
- * subject: "cn=MyCert"
471
- * });
472
- * await poller.pollUntilDone();
473
- * const certificateWithPolicy = await client.getCertificate("MyCertificate");
474
- * const certificate = await client.getCertificateVersion("MyCertificate", certificateWithPolicy.properties.version!);
475
- * console.log(certificate);
576
+ * ```ts snippet:CertificateClientGetCertificateVersion
577
+ * import { DefaultAzureCredential } from "@azure/identity";
578
+ * import { CertificateClient } from "@azure/keyvault-certificates";
579
+ *
580
+ * const credential = new DefaultAzureCredential();
581
+ *
582
+ * const vaultName = "<YOUR KEYVAULT NAME>";
583
+ * const url = `https://${vaultName}.vault.azure.net`;
584
+ *
585
+ * const client = new CertificateClient(url, credential);
586
+ *
587
+ * const certificateName = "MyCertificateName";
588
+ *
589
+ * const latestCertificate = await client.getCertificate(certificateName);
590
+ * console.log(`Latest version of the certificate ${certificateName}: `, latestCertificate);
591
+ * const specificCertificate = await client.getCertificateVersion(
592
+ * certificateName,
593
+ * latestCertificate.properties.version,
594
+ * );
595
+ * console.log(
596
+ * `The certificate ${certificateName} at the version ${latestCertificate.properties.version}: `,
597
+ * specificCertificate,
598
+ * );
476
599
  * ```
477
600
  * Retrieves a certificate from the certificate's name and a specified version
478
601
  * @param certificateName - The name of the certificate
@@ -493,19 +616,26 @@ class CertificateClient {
493
616
  * If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates. This operation requires the certificates/import permission.
494
617
  *
495
618
  * Example usage:
496
- * ```ts
497
- * const client = new CertificateClient(url, credentials);
498
- * // See: @azure/keyvault-secrets
619
+ * ```ts snippet:CertificateClientImportCertificate
620
+ * import { DefaultAzureCredential } from "@azure/identity";
621
+ * import { CertificateClient } from "@azure/keyvault-certificates";
622
+ * import { SecretClient } from "@azure/keyvault-secrets";
623
+ * import { isNodeLike } from "@azure/core-util";
624
+ *
625
+ * const credential = new DefaultAzureCredential();
626
+ *
627
+ * const vaultName = "<YOUR KEYVAULT NAME>";
628
+ * const url = `https://${vaultName}.vault.azure.net`;
629
+ *
630
+ * const client = new CertificateClient(url, credential);
631
+ * const secretClient = new SecretClient(url, credential);
632
+ *
499
633
  * const certificateSecret = await secretClient.getSecret("MyCertificate");
500
634
  * const base64EncodedCertificate = certificateSecret.value!;
501
- * let buffer: Uint8Array;
502
- *
503
- * if (isNode) {
504
- * buffer = Buffer.from(base64EncodedCertificate, "base64");
505
- * } else {
506
- * buffer = Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
507
- * }
508
635
  *
636
+ * const buffer = isNodeLike
637
+ * ? Buffer.from(base64EncodedCertificate, "base64")
638
+ * : Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
509
639
  * await client.importCertificate("MyCertificate", buffer);
510
640
  * ```
511
641
  * Imports a certificate from a certificate's secret value
@@ -525,12 +655,17 @@ class CertificateClient {
525
655
  * The getCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. This operation requires the certificates/get permission.
526
656
  *
527
657
  * Example usage:
528
- * ```ts
529
- * const client = new CertificateClient(url, credentials);
530
- * await client.beginCreateCertificate("MyCertificate", {
531
- * issuerName: "Self",
532
- * subject: "cn=MyCert"
533
- * });
658
+ * ```ts snippet:CertificateClientGetCertificatePolicy
659
+ * import { DefaultAzureCredential } from "@azure/identity";
660
+ * import { CertificateClient } from "@azure/keyvault-certificates";
661
+ *
662
+ * const credential = new DefaultAzureCredential();
663
+ *
664
+ * const vaultName = "<YOUR KEYVAULT NAME>";
665
+ * const url = `https://${vaultName}.vault.azure.net`;
666
+ *
667
+ * const client = new CertificateClient(url, credential);
668
+ *
534
669
  * const policy = await client.getCertificatePolicy("MyCertificate");
535
670
  * console.log(policy);
536
671
  * ```
@@ -564,19 +699,23 @@ class CertificateClient {
564
699
  * certificate's attributes. This operation requires the certificates/update permission.
565
700
  *
566
701
  * Example usage:
567
- * ```ts
568
- * const client = new CertificateClient(url, credentials);
569
- * await client.beginCreateCertificate("MyCertificate", {
570
- * issuerName: "Self",
571
- * subject: "cn=MyCert"
572
- * });
702
+ * ```ts snippet:CertificateClientUpdateCertificate
703
+ * import { DefaultAzureCredential } from "@azure/identity";
704
+ * import { CertificateClient } from "@azure/keyvault-certificates";
705
+ *
706
+ * const credential = new DefaultAzureCredential();
707
+ *
708
+ * const vaultName = "<YOUR KEYVAULT NAME>";
709
+ * const url = `https://${vaultName}.vault.azure.net`;
710
+ *
711
+ * const client = new CertificateClient(url, credential);
573
712
  *
574
713
  * // You may pass an empty string for version which will update
575
714
  * // the latest version of the certificate
576
715
  * await client.updateCertificateProperties("MyCertificate", "", {
577
716
  * tags: {
578
- * customTag: "value"
579
- * }
717
+ * customTag: "value",
718
+ * },
580
719
  * });
581
720
  * ```
582
721
  * Updates a certificate
@@ -598,11 +737,20 @@ class CertificateClient {
598
737
  * This function returns a Long Running Operation poller that allows you to wait indefinitely until the certificate is fully recovered.
599
738
  *
600
739
  * Example usage:
601
- * ```ts
602
- * const client = new CertificateClient(url, credentials);
740
+ * ```ts snippet:CertificateClientGetCertificateOperation
741
+ * import { DefaultAzureCredential } from "@azure/identity";
742
+ * import { CertificateClient } from "@azure/keyvault-certificates";
743
+ *
744
+ * const credential = new DefaultAzureCredential();
745
+ *
746
+ * const vaultName = "<YOUR KEYVAULT NAME>";
747
+ * const url = `https://${vaultName}.vault.azure.net`;
748
+ *
749
+ * const client = new CertificateClient(url, credential);
750
+ *
603
751
  * const createPoller = await client.beginCreateCertificate("MyCertificate", {
604
752
  * issuerName: "Self",
605
- * subject: "cn=MyCert"
753
+ * subject: "cn=MyCert",
606
754
  * });
607
755
  *
608
756
  * const poller = await client.getCertificateOperation("MyCertificate");
@@ -633,14 +781,24 @@ class CertificateClient {
633
781
  * The certificate is no longer created. This operation requires the certificates/update permission.
634
782
  *
635
783
  * Example usage:
636
- * ```ts
637
- * const client = new CertificateClient(url, credentials);
784
+ * ```ts snippet:CertificateClientDeleteCertificateOperation
785
+ * import { DefaultAzureCredential } from "@azure/identity";
786
+ * import { CertificateClient } from "@azure/keyvault-certificates";
787
+ *
788
+ * const credential = new DefaultAzureCredential();
789
+ *
790
+ * const vaultName = "<YOUR KEYVAULT NAME>";
791
+ * const url = `https://${vaultName}.vault.azure.net`;
792
+ *
793
+ * const client = new CertificateClient(url, credential);
794
+ *
638
795
  * await client.beginCreateCertificate("MyCertificate", {
639
796
  * issuerName: "Self",
640
- * subject: "cn=MyCert"
797
+ * subject: "cn=MyCert",
641
798
  * });
642
799
  * await client.deleteCertificateOperation("MyCertificate");
643
- * await client.getCertificateOperation("MyCertificate"); // Throws error: Pending certificate not found: "MyCertificate"
800
+ *
801
+ * await client.getCertificateOperation("MyCertificate");
644
802
  * ```
645
803
  * Delete a certificate's operation
646
804
  * @param certificateName - The name of the certificate
@@ -656,28 +814,41 @@ class CertificateClient {
656
814
  * Performs the merging of a certificate or certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.
657
815
  *
658
816
  * Example usage:
659
- * ```ts
660
- * const client = new CertificateClient(url, credentials);
817
+ * ```ts snippet:CertificateClientMergeCertificate
818
+ * import { DefaultAzureCredential } from "@azure/identity";
819
+ * import { CertificateClient } from "@azure/keyvault-certificates";
820
+ * import { writeFileSync, readFileSync } from "node:fs";
821
+ * import { execSync } from "node:child_process";
822
+ *
823
+ * const credential = new DefaultAzureCredential();
824
+ *
825
+ * const vaultName = "<YOUR KEYVAULT NAME>";
826
+ * const url = `https://${vaultName}.vault.azure.net`;
827
+ *
828
+ * const client = new CertificateClient(url, credential);
829
+ *
661
830
  * await client.beginCreateCertificate("MyCertificate", {
662
831
  * issuerName: "Unknown",
663
- * subject: "cn=MyCert"
832
+ * subject: "cn=MyCert",
664
833
  * });
665
834
  * const poller = await client.getCertificateOperation("MyCertificate");
666
835
  * const { csr } = poller.getOperationState().certificateOperation!;
667
836
  * const base64Csr = Buffer.from(csr!).toString("base64");
668
- * const wrappedCsr = ["-----BEGIN CERTIFICATE REQUEST-----", base64Csr, "-----END CERTIFICATE REQUEST-----"].join("\n");
837
+ * const wrappedCsr = [
838
+ * "-----BEGIN CERTIFICATE REQUEST-----",
839
+ * base64Csr,
840
+ * "-----END CERTIFICATE REQUEST-----",
841
+ * ].join("\n");
669
842
  *
670
- * const fs = require("fs");
671
- * fs.writeFileSync("test.csr", wrappedCsr);
843
+ * writeFileSync("test.csr", wrappedCsr);
672
844
  *
673
845
  * // Certificate available locally made using:
674
846
  * // openssl genrsa -out ca.key 2048
675
847
  * // openssl req -new -x509 -key ca.key -out ca.crt
676
848
  * // You can read more about how to create a fake certificate authority here: https://gist.github.com/Soarez/9688998
677
849
  *
678
- * const childProcess = require("child_process");
679
- * childProcess.execSync("openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out test.crt");
680
- * const base64Crt = fs.readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
850
+ * execSync("openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out test.crt");
851
+ * const base64Crt = readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
681
852
  *
682
853
  * await client.mergeCertificate("MyCertificate", [Buffer.from(base64Crt)]);
683
854
  * ```
@@ -697,11 +868,20 @@ class CertificateClient {
697
868
  * This operation requires the certificates/backup permission.
698
869
  *
699
870
  * Example usage:
700
- * ```ts
701
- * const client = new CertificateClient(url, credentials);
871
+ * ```ts snippet:CertificateClientBackupCertificate
872
+ * import { DefaultAzureCredential } from "@azure/identity";
873
+ * import { CertificateClient } from "@azure/keyvault-certificates";
874
+ *
875
+ * const credential = new DefaultAzureCredential();
876
+ *
877
+ * const vaultName = "<YOUR KEYVAULT NAME>";
878
+ * const url = `https://${vaultName}.vault.azure.net`;
879
+ *
880
+ * const client = new CertificateClient(url, credential);
881
+ *
702
882
  * await client.beginCreateCertificate("MyCertificate", {
703
883
  * issuerName: "Self",
704
- * subject: "cn=MyCert"
884
+ * subject: "cn=MyCert",
705
885
  * });
706
886
  * const backup = await client.backupCertificate("MyCertificate");
707
887
  * ```
@@ -719,15 +899,26 @@ class CertificateClient {
719
899
  * Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission.
720
900
  *
721
901
  * Example usage:
722
- * ```ts
723
- * const client = new CertificateClient(url, credentials);
902
+ * ```ts snippet:CertificateClientRestoreCertificateBackup
903
+ * import { DefaultAzureCredential } from "@azure/identity";
904
+ * import { CertificateClient } from "@azure/keyvault-certificates";
905
+ *
906
+ * const credential = new DefaultAzureCredential();
907
+ *
908
+ * const vaultName = "<YOUR KEYVAULT NAME>";
909
+ * const url = `https://${vaultName}.vault.azure.net`;
910
+ *
911
+ * const client = new CertificateClient(url, credential);
912
+ *
724
913
  * await client.beginCreateCertificate("MyCertificate", {
725
914
  * issuerName: "Self",
726
- * subject: "cn=MyCert"
915
+ * subject: "cn=MyCert",
727
916
  * });
728
917
  * const backup = await client.backupCertificate("MyCertificate");
918
+ *
729
919
  * const poller = await client.beginDeleteCertificate("MyCertificate");
730
920
  * await poller.pollUntilDone();
921
+ *
731
922
  * // Some time is required before we're able to restore the certificate
732
923
  * await client.restoreCertificateBackup(backup!);
733
924
  * ```
@@ -746,11 +937,21 @@ class CertificateClient {
746
937
  * information. This operation requires the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults.
747
938
  *
748
939
  * Example usage:
749
- * ```ts
750
- * const client = new CertificateClient(url, credentials);
940
+ * ```ts snippet:CertificateClientListDeletedCertificates
941
+ * import { DefaultAzureCredential } from "@azure/identity";
942
+ * import { CertificateClient } from "@azure/keyvault-certificates";
943
+ *
944
+ * const credential = new DefaultAzureCredential();
945
+ *
946
+ * const vaultName = "<YOUR KEYVAULT NAME>";
947
+ * const url = `https://${vaultName}.vault.azure.net`;
948
+ *
949
+ * const client = new CertificateClient(url, credential);
950
+ *
751
951
  * for await (const deletedCertificate of client.listDeletedCertificates()) {
752
952
  * console.log(deletedCertificate);
753
953
  * }
954
+ *
754
955
  * for await (const page of client.listDeletedCertificates().byPage()) {
755
956
  * for (const deletedCertificate of page) {
756
957
  * console.log(deletedCertificate);
@@ -768,8 +969,17 @@ class CertificateClient {
768
969
  * current deletion recovery level. This operation requires the certificates/get permission.
769
970
  *
770
971
  * Example usage:
771
- * ```ts
772
- * const client = new CertificateClient(url, credentials);
972
+ * ```ts snippet:CertificateClientGetDeletedCertificate
973
+ * import { DefaultAzureCredential } from "@azure/identity";
974
+ * import { CertificateClient } from "@azure/keyvault-certificates";
975
+ *
976
+ * const credential = new DefaultAzureCredential();
977
+ *
978
+ * const vaultName = "<YOUR KEYVAULT NAME>";
979
+ * const url = `https://${vaultName}.vault.azure.net`;
980
+ *
981
+ * const client = new CertificateClient(url, credential);
982
+ *
773
983
  * const deletedCertificate = await client.getDeletedCertificate("MyDeletedCertificate");
774
984
  * console.log("Deleted certificate:", deletedCertificate);
775
985
  * ```
@@ -788,10 +998,20 @@ class CertificateClient {
788
998
  * recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.
789
999
  *
790
1000
  * Example usage:
791
- * ```ts
792
- * const client = new CertificateClient(url, credentials);
1001
+ * ```ts snippet:CertificateClientPurgeDeletedCertificate
1002
+ * import { DefaultAzureCredential } from "@azure/identity";
1003
+ * import { CertificateClient } from "@azure/keyvault-certificates";
1004
+ *
1005
+ * const credential = new DefaultAzureCredential();
1006
+ *
1007
+ * const vaultName = "<YOUR KEYVAULT NAME>";
1008
+ * const url = `https://${vaultName}.vault.azure.net`;
1009
+ *
1010
+ * const client = new CertificateClient(url, credential);
1011
+ *
793
1012
  * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
794
1013
  * await deletePoller.pollUntilDone();
1014
+ *
795
1015
  * // Deleting a certificate takes time, make sure to wait before purging it
796
1016
  * client.purgeDeletedCertificate("MyCertificate");
797
1017
  * ```
@@ -812,20 +1032,22 @@ class CertificateClient {
812
1032
  * This operation requires the certificates/recover permission.
813
1033
  *
814
1034
  * Example usage:
815
- * ```ts
816
- * const client = new CertificateClient(url, credentials);
1035
+ * ```ts snippet:CertificateClientRecoverDeletedCertificate
1036
+ * import { DefaultAzureCredential } from "@azure/identity";
1037
+ * import { CertificateClient } from "@azure/keyvault-certificates";
1038
+ *
1039
+ * const credential = new DefaultAzureCredential();
1040
+ *
1041
+ * const vaultName = "<YOUR KEYVAULT NAME>";
1042
+ * const url = `https://${vaultName}.vault.azure.net`;
1043
+ *
1044
+ * const client = new CertificateClient(url, credential);
817
1045
  *
818
1046
  * const deletePoller = await client.beginDeleteCertificate("MyCertificate");
819
1047
  * await deletePoller.pollUntilDone();
820
1048
  *
821
1049
  * const recoverPoller = await client.beginRecoverDeletedCertificate("MyCertificate");
822
1050
  *
823
- * // Serializing the poller
824
- * const serialized = deletePoller.toString();
825
- *
826
- * // A new poller can be created with:
827
- * // const newPoller = await client.beginRecoverDeletedCertificate("MyCertificate", { resumeFrom: serialized });
828
- *
829
1051
  * // Waiting until it's done
830
1052
  * const certificate = await recoverPoller.pollUntilDone();
831
1053
  * console.log(certificate);