Skip to content

Commit f50369d

Browse files
committed
fixed indents/spacing, bullets, metadata
1 parent 1a8ee00 commit f50369d

File tree

3 files changed

+101
-37
lines changed

3 files changed

+101
-37
lines changed

articles/key-vault/certificates/quick-create-java.md

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Quickstart for Azure Key Vault Certificate client library - Java
33
description: Learn about the the Azure Key Vault Certificate client library for Java with the steps in this quickstart.
44
author: msmbaldwin
5-
ms.custom: devx-track-java, devx-track-azurecli, devx-track-azurepowershell, mode-api
5+
ms.custom: devx-track-java, devx-track-azurecli, devx-track-azurepowershell, mode-api, passwordless-java
66
ms.author: mbaldwin
77
ms.date: 11/14/2022
88
ms.service: key-vault
@@ -12,16 +12,18 @@ ms.devlang: java
1212
---
1313

1414
# Quickstart: Azure Key Vault Certificate client library for Java (Certificates)
15+
1516
Get started with the Azure Key Vault Certificate client library for Java. Follow the steps below to install the package and try out example code for basic tasks.
1617

1718
Additional resources:
1819

19-
* [Source code](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-certificates)
20-
* [API reference documentation](https://azure.github.io/azure-sdk-for-java/keyvault.html)
21-
* [Product documentation](index.yml)
22-
* [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates)
20+
- [Source code](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-certificates)
21+
- [API reference documentation](https://azure.github.io/azure-sdk-for-java/keyvault.html)
22+
- [Product documentation](index.yml)
23+
- [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates)
2324

2425
## Prerequisites
26+
2527
- An Azure subscription - [create one for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2628
- [Java Development Kit (JDK)](/java/azure/jdk/) version 8 or above
2729
- [Apache Maven](https://maven.apache.org)
@@ -30,23 +32,26 @@ Additional resources:
3032
This quickstart assumes you are running [Azure CLI](/cli/azure/install-azure-cli) and [Apache Maven](https://maven.apache.org) in a Linux terminal window.
3133

3234
## Setting up
35+
3336
This quickstart is using the Azure Identity library with Azure CLI to authenticate user to Azure Services. Developers can also use Visual Studio or Visual Studio Code to authenticate their calls, for more information, see [Authenticate the client with Azure Identity client library](/java/api/overview/azure/identity-readme).
3437

3538
### Sign in to Azure
39+
3640
1. Run the `login` command.
3741

38-
```azurecli-interactive
39-
az login
40-
```
42+
```azurecli-interactive
43+
az login
44+
```
4145

4246
If the CLI can open your default browser, it will do so and load an Azure sign-in page.
4347

4448
Otherwise, open a browser page at [https://aka.ms/devicelogin](https://aka.ms/devicelogin) and enter the
4549
authorization code displayed in your terminal.
4650

47-
2. Sign in with your account credentials in the browser.
51+
1. Sign in with your account credentials in the browser.
4852

4953
### Create a new Java console app
54+
5055
In a console window, use the `mvn` command to create a new Java console app with the name `akv-certificates-java`.
5156

5257
```console
@@ -88,6 +93,7 @@ cd akv-certificates-java
8893
```
8994

9095
### Install the package
96+
9197
Open the *pom.xml* file in your text editor. Add the following dependency elements to the group of dependencies.
9298

9399
```xml
@@ -105,39 +111,49 @@ Open the *pom.xml* file in your text editor. Add the following dependency elemen
105111
```
106112

107113
### Create a resource group and key vault
114+
108115
[!INCLUDE [Create a resource group and key vault](../../../includes/key-vault-rg-kv-creation.md)]
109116

110117
#### Grant access to your key vault
118+
111119
Create an access policy for your key vault that grants certificate permissions to your user account.
112120

113121
```azurecli
114122
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --certificate-permissions delete get list create purge
115123
```
116124

117125
#### Set environment variables
126+
118127
This application is using your key vault name as an environment variable called `KEY_VAULT_NAME`.
119128

120129
Windows
130+
121131
```cmd
122132
set KEY_VAULT_NAME=<your-key-vault-name>
123133
````
134+
124135
Windows PowerShell
136+
125137
```powershell
126138
$Env:KEY_VAULT_NAME="<your-key-vault-name>"
127139
```
128140

129141
macOS or Linux
142+
130143
```cmd
131144
export KEY_VAULT_NAME=<your-key-vault-name>
132145
```
133146

134147
## Object model
148+
135149
The Azure Key Vault Certificate client library for Java allows you to manage certificates. The [Code examples](#code-examples) section shows how to create a client, create a certificate, retrieve a certificate, and delete a certificate.
136150

137151
The entire console app is [below](#sample-code).
138152

139153
## Code examples
154+
140155
### Add directives
156+
141157
Add the following directives to the top of your code:
142158

143159
```java
@@ -154,6 +170,7 @@ import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPo
154170
```
155171

156172
### Authenticate and create a client
173+
157174
In this quickstart, a logged in user is used to authenticate to Key Vault, which is preferred method for local development. For applications deployed to Azure, a Managed Identity should be assigned to an App Service or Virtual Machine. For more information, see [Managed Identity Overview](../../active-directory/managed-identities-azure-resources/overview.md).
158175

159176
In the example below, the name of your key vault is expanded to the key vault URI, in the format "https://\<your-key-vault-name\>.vault.azure.net". This example is using the ['DefaultAzureCredential()'](/java/api/com.azure.identity.defaultazurecredential) class, which allows to use the same code across different environments with different options to provide identity. For more information, see [Default Azure Credential Authentication](/java/api/overview/azure/identity-readme).
@@ -169,6 +186,7 @@ CertificateClient certificateClient = new CertificateClientBuilder()
169186
```
170187

171188
### Save a secret
189+
172190
Now that your application is authenticated, you can create a certificate in your key vault using the `certificateClient.beginCreateCertificate` method. This requires a name for the certificate and a certificate policy -- we've assigned the value "myCertificate" to the `certificateName` variable in this sample and use a default policy.
173191

174192
Certificate creation is a long running operation, for which you can poll its progress or wait for it to complete.
@@ -186,6 +204,7 @@ KeyVaultCertificate createdCertificate = certificatePoller.getFinalResult();
186204
```
187205

188206
### Retrieve a certificate
207+
189208
You can now retrieve the previously created certificate with the `certificateClient.getCertificate` method.
190209

191210
```java
@@ -195,6 +214,7 @@ KeyVaultCertificate retrievedCertificate = certificateClient.getCertificate(cert
195214
You can now access the details of the retrieved certificate with operations like `retrievedCertificate.getName`, `retrievedCertificate.getProperties`, etc. As well as its contents `retrievedCertificate.getCer`.
196215

197216
### Delete a certificate
217+
198218
Finally, let's delete the certificate from your key vault with the `certificateClient.beginDeleteCertificate` method, which is also a long running operation.
199219

200220
```java
@@ -203,6 +223,7 @@ deletionPoller.waitForCompletion();
203223
```
204224

205225
## Clean up resources
226+
206227
When no longer needed, you can use the Azure CLI or Azure PowerShell to remove your key vault and the corresponding resource group.
207228

208229
```azurecli
@@ -214,6 +235,7 @@ Remove-AzResourceGroup -Name "myResourceGroup"
214235
```
215236

216237
## Sample code
238+
217239
```java
218240
package com.keyvault.certificates.quickstart;
219241

@@ -236,16 +258,16 @@ public class App {
236258
System.out.printf("key vault name = %s and kv uri = %s \n", keyVaultName, keyVaultUri);
237259

238260
CertificateClient certificateClient = new CertificateClientBuilder()
239-
.vaultUrl(keyVaultUri)
240-
.credential(new DefaultAzureCredentialBuilder().build())
241-
.buildClient();
261+
.vaultUrl(keyVaultUri)
262+
.credential(new DefaultAzureCredentialBuilder().build())
263+
.buildClient();
242264

243265
String certificateName = "myCertificate";
244266

245267
System.out.print("Creating a certificate in " + keyVaultName + " called '" + certificateName + " ... ");
246268

247269
SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certificatePoller =
248-
certificateClient.beginCreateCertificate(certificateName, CertificatePolicy.getDefault());
270+
certificateClient.beginCreateCertificate(certificateName, CertificatePolicy.getDefault());
249271
certificatePoller.waitForCompletion();
250272

251273
System.out.print("done.");
@@ -265,6 +287,7 @@ public class App {
265287
```
266288

267289
## Next steps
290+
268291
In this quickstart you created a key vault, created a certificate, retrieved it, and then deleted it. To learn more about Key Vault and how to integrate it with your applications, continue on to the articles below.
269292

270293
- Read an [Overview of Azure Key Vault](../general/overview.md)

articles/key-vault/keys/quick-create-java.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Quickstart - Azure Key Vault Key client library for Java
33
description: Provides a quickstart for the Azure Key Vault Keys client library for Java.
44
author: msmbaldwin
5-
ms.custom: devx-track-java, devx-track-azurecli, devx-track-azurepowershell, mode-api
5+
ms.custom: devx-track-java, devx-track-azurecli, devx-track-azurepowershell, mode-api, passwordless-java
66
ms.author: mbaldwin
77
ms.date: 01/04/2023
88
ms.service: key-vault
@@ -17,12 +17,13 @@ Get started with the Azure Key Vault Key client library for Java. Follow these s
1717

1818
Additional resources:
1919

20-
* [Source code](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-keys)
21-
* [API reference documentation](https://azure.github.io/azure-sdk-for-java/keyvault.html)
22-
* [Product documentation](index.yml)
23-
* [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys)
20+
- [Source code](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-keys)
21+
- [API reference documentation](https://azure.github.io/azure-sdk-for-java/keyvault.html)
22+
- [Product documentation](index.yml)
23+
- [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/keyvault/azure-security-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys)
2424

2525
## Prerequisites
26+
2627
- An Azure subscription - [create one for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2728
- [Java Development Kit (JDK)](/java/azure/jdk/) version 8 or above
2829
- [Apache Maven](https://maven.apache.org)
@@ -31,22 +32,25 @@ Additional resources:
3132
This quickstart assumes you're running [Azure CLI](/cli/azure/install-azure-cli) and [Apache Maven](https://maven.apache.org) in a Linux terminal window.
3233

3334
## Setting up
35+
3436
This quickstart is using the Azure Identity library with Azure CLI to authenticate user to Azure Services. Developers can also use Visual Studio or Visual Studio Code to authenticate their calls, for more information, see [Authenticate the client with Azure Identity client library](/java/api/overview/azure/identity-readme).
3537

3638
### Sign in to Azure
39+
3740
1. Run the `login` command.
3841

39-
```azurecli-interactive
40-
az login
41-
```
42+
```azurecli-interactive
43+
az login
44+
```
4245

4346
If the CLI can open your default browser, it will do so and load an Azure sign-in page.
4447

4548
Otherwise, open a browser page at [https://aka.ms/devicelogin](https://aka.ms/devicelogin) and enter the authorization code displayed in your terminal.
4649

47-
2. Sign in with your account credentials in the browser.
50+
1. Sign in with your account credentials in the browser.
4851

4952
### Create a new Java console app
53+
5054
In a console window, use the `mvn` command to create a new Java console app with the name `akv-keys-java`.
5155

5256
```console
@@ -88,6 +92,7 @@ cd akv-keys-java
8892
```
8993

9094
### Install the package
95+
9196
Open the *pom.xml* file in your text editor. Add the following dependency elements to the group of dependencies.
9297

9398
```xml
@@ -105,39 +110,49 @@ Open the *pom.xml* file in your text editor. Add the following dependency elemen
105110
```
106111

107112
### Create a resource group and key vault
113+
108114
[!INCLUDE [Create a resource group and key vault](../../../includes/key-vault-rg-kv-creation.md)]
109115

110116
#### Grant access to your key vault
117+
111118
Create an access policy for your key vault that grants key permissions to your user account.
112119

113120
```azurecli
114121
az keyvault set-policy --name <your-key-vault-name> --upn [email protected] --key-permissions delete get list create purge
115122
```
116123

117124
#### Set environment variables
125+
118126
This application is using your key vault name as an environment variable called `KEY_VAULT_NAME`.
119127

120128
Windows
129+
121130
```cmd
122131
set KEY_VAULT_NAME=<your-key-vault-name>
123132
````
133+
124134
Windows PowerShell
135+
125136
```powershell
126137
$Env:KEY_VAULT_NAME="<your-key-vault-name>"
127138
```
128139

129140
macOS or Linux
141+
130142
```cmd
131143
export KEY_VAULT_NAME=<your-key-vault-name>
132144
```
133145

134146
## Object model
147+
135148
The Azure Key Vault Key client library for Java allows you to manage keys. The [Code examples](#code-examples) section shows how to create a client, create a key, retrieve a key, and delete a key.
136149

137150
The entire console app is supplied in [Sample code](#sample-code).
138151

139152
## Code examples
153+
140154
### Add directives
155+
141156
Add the following directives to the top of your code:
142157

143158
```java
@@ -168,6 +183,7 @@ KeyClient keyClient = new KeyClientBuilder()
168183
```
169184

170185
### Create a key
186+
171187
Now that your application is authenticated, you can create a key in your key vault using the `keyClient.createKey` method. This requires a name for the key and a key type. We've assigned the value "myKey" to the `keyName` variable and use a an RSA `KeyType` in this sample.
172188

173189
```java
@@ -181,6 +197,7 @@ az keyvault key show --vault-name <your-unique-key-vault-name> --name myKey
181197
```
182198

183199
### Retrieve a key
200+
184201
You can now retrieve the previously created key with the `keyClient.getKey` method.
185202

186203
```java
@@ -190,6 +207,7 @@ KeyVaultKey retrievedKey = keyClient.getKey(keyName);
190207
You can now access the details of the retrieved key with operations like `retrievedKey.getProperties`, `retrievedKey.getKeyOperations`, etc.
191208

192209
### Delete a key
210+
193211
Finally, let's delete the key from your key vault with the `keyClient.beginDeleteKey` method.
194212

195213
Key deletion is a long running operation, for which you can poll its progress or wait for it to complete.
@@ -206,6 +224,7 @@ az keyvault key show --vault-name <your-unique-key-vault-name> --name myKey
206224
```
207225

208226
## Clean up resources
227+
209228
When no longer needed, you can use the Azure CLI or Azure PowerShell to remove your key vault and the corresponding resource group.
210229

211230
```azurecli
@@ -217,6 +236,7 @@ Remove-AzResourceGroup -Name "myResourceGroup"
217236
```
218237

219238
## Sample code
239+
220240
```java
221241
package com.keyvault.keys.quickstart;
222242

@@ -237,9 +257,9 @@ public class App {
237257
System.out.printf("key vault name = %s and key vault URI = %s \n", keyVaultName, keyVaultUri);
238258

239259
KeyClient keyClient = new KeyClientBuilder()
240-
.vaultUrl(keyVaultUri)
241-
.credential(new DefaultAzureCredentialBuilder().build())
242-
.buildClient();
260+
.vaultUrl(keyVaultUri)
261+
.credential(new DefaultAzureCredentialBuilder().build())
262+
.buildClient();
243263

244264
String keyName = "myKey";
245265

@@ -264,6 +284,7 @@ public class App {
264284
```
265285

266286
## Next steps
287+
267288
In this quickstart, you created a key vault, created a key, retrieved it, and then deleted it. To learn more about Key Vault and how to integrate it with your applications, continue on to these articles.
268289

269290
- Read an [Overview of Azure Key Vault](../general/overview.md)

0 commit comments

Comments
 (0)