Skip to content

Commit 0009c0a

Browse files
committed
fixes MicrosoftDocs/azure-docs#108099
1 parent 2d762b0 commit 0009c0a

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

articles/spring-apps/tutorial-managed-identities-key-vault.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The following video describes how to manage secrets using Azure Key Vault.
3939
A resource group is a logical container into which Azure resources are deployed and managed. Create a resource group to contain both the Key Vault and Spring Cloud using the command [az group create](/cli/azure/group#az-group-create):
4040

4141
```azurecli
42-
az group create --name "myResourceGroup" -l "EastUS"
42+
az group create --name "myResourceGroup" --location "EastUS"
4343
```
4444

4545
## Set up your Key Vault
@@ -55,7 +55,7 @@ az keyvault create \
5555
--name "<your-keyvault-name>"
5656
```
5757

58-
Make a note of the returned `vaultUri`, which will be in the format `https://<your-keyvault-name>.vault.azure.net`. It will be used in the following step.
58+
Make a note of the returned `vaultUri`, which is in the format `https://<your-keyvault-name>.vault.azure.net`. You use this value in the following step.
5959

6060
You can now place a secret in your Key Vault with the command [az keyvault secret set](/cli/azure/keyvault/secret#az-keyvault-secret-set):
6161

@@ -84,11 +84,15 @@ The following example creates an app named `springapp` with a system-assigned ma
8484
```azurecli
8585
az spring app create \
8686
--resource-group <your-resource-group-name> \
87-
--name "springapp" \
8887
--service <your-Azure-Spring-Apps-instance-name> \
88+
--name "springapp" \
8989
--assign-endpoint true \
9090
--system-assigned
91-
export SERVICE_IDENTITY=$(az spring app show --name "springapp" -s "myspringcloud" -g "myResourceGroup" | jq -r '.identity.principalId')
91+
export SERVICE_IDENTITY=$(az spring app show \
92+
--resource-group "<your-resource-group-name>" \
93+
--service "<your-Azure-Spring-Apps-instance-name>" \
94+
--name "springapp" \
95+
| jq -r '.identity.principalId')
9296
```
9397

9498
### [User-assigned managed identity](#tab/user-assigned-managed-identity)
@@ -97,29 +101,29 @@ First, create a user-assigned managed identity in advance with its resource ID s
97101

98102
:::image type="content" source="media/tutorial-managed-identities-key-vault/app-user-managed-identity-key-vault.png" alt-text="Screenshot of Azure portal showing the Managed Identity Properties screen with 'Resource ID', 'Principle ID' and 'Client ID' highlighted." lightbox="media/tutorial-managed-identities-key-vault/app-user-managed-identity-key-vault.png":::
99103

100-
```azurecli
101-
export SERVICE_IDENTITY={principal ID of user-assigned managed identity}
102-
export USER_IDENTITY_RESOURCE_ID={resource ID of user-assigned managed identity}
104+
```bash
105+
export SERVICE_IDENTITY=<principal-ID-of-user-assigned-managed-identity>
106+
export USER_IDENTITY_RESOURCE_ID=<resource-ID-of-user-assigned-managed-identity>
103107
```
104108

105109
The following example creates an app named `springapp` with a user-assigned managed identity, as requested by the `--user-assigned` parameter.
106110

107111
```azurecli
108112
az spring app create \
109113
--resource-group <your-resource-group-name> \
110-
--name "springapp" \
111114
--service <your-Azure-Spring-Apps-instance-name> \
112-
--assign-endpoint true \
113-
--user-assigned $USER_IDENTITY_RESOURCE_ID
115+
--name "springapp" \
116+
--user-assigned $USER_IDENTITY_RESOURCE_ID \
117+
--assign-endpoint true
114118
az spring app show \
115119
--resource-group <your-resource-group-name> \
116-
--name "springapp" \
117-
--service <your-Azure-Spring-Apps-instance-name>
120+
--service <your-Azure-Spring-Apps-instance-name> \
121+
--name "springapp"
118122
```
119123

120124
---
121125

122-
Make a note of the returned URL, which will be in the format `https://<your-app-name>.azuremicroservices.io`. This URL will be used in the following step.
126+
Make a note of the returned URL, which is in the format `https://<your-app-name>.azuremicroservices.io`. You use this value in the following step.
123127

124128
## Grant your app access to Key Vault
125129

@@ -137,17 +141,17 @@ az keyvault set-policy \
137141
138142
## Build a sample Spring Boot app with Spring Boot starter
139143

140-
This app will have access to get secrets from Azure Key Vault. Use the Azure Key Vault Secrets Spring boot starter. Azure Key Vault is added as an instance of Spring **PropertySource**. Secrets stored in Azure Key Vault can be conveniently accessed and used like any externalized configuration property, such as properties in files.
144+
This app has access to get secrets from Azure Key Vault. Use the Azure Key Vault Secrets Spring boot starter. Azure Key Vault is added as an instance of Spring **PropertySource**. Secrets stored in Azure Key Vault can be conveniently accessed and used like any externalized configuration property, such as properties in files.
141145

142146
1. Use the following command to generate a sample project from `start.spring.io` with Azure Key Vault Spring Starter.
143147

144-
```azurecli
148+
```bash
145149
curl https://start.spring.io/starter.tgz -d dependencies=web,azure-keyvault -d baseDir=springapp -d bootVersion=2.7.2 -d javaVersion=1.8 | tar -xzvf -
146150
```
147151

148152
1. Specify your Key Vault in your app.
149153

150-
```azurecli
154+
```bash
151155
cd springapp
152156
vim src/main/resources/application.properties
153157
```
@@ -208,7 +212,7 @@ spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id={Cli
208212
}
209213
```
210214

211-
If you open the *pom.xml* file, you'll see the dependency of `spring-cloud-azure-starter-keyvault`.
215+
If you open the *pom.xml* file, you can see the `spring-cloud-azure-starter-keyvault` dependency, as shown in the following example:
212216

213217
```xml
214218
<dependency>
@@ -219,7 +223,7 @@ spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id={Cli
219223

220224
1. Use the following command to package your sample app.
221225

222-
```azurecli
226+
```bash
223227
./mvnw clean package -DskipTests
224228
```
225229

@@ -228,18 +232,18 @@ spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id={Cli
228232
```azurecli
229233
az spring app deploy \
230234
--resource-group <your-resource-group-name> \
231-
--name "springapp" \
232235
--service <your-Azure-Spring-Apps-instance-name> \
236+
--name "springapp" \
233237
--artifact-path target/demo-0.0.1-SNAPSHOT.jar
234238
```
235239

236240
1. To test your app, access the public endpoint or test endpoint by using the following command:
237241

238-
```azurecli
242+
```bash
239243
curl https://myspringcloud-springapp.azuremicroservices.io/get
240244
```
241245

242-
You'll see the message `Successfully got the value of secret connectionString from Key Vault https://<your-keyvault-name>.vault.azure.net/: jdbc:sqlserver://SERVER.database.windows.net:1433;database=DATABASE;`.
246+
You're shown the message `Successfully got the value of secret connectionString from Key Vault https://<your-keyvault-name>.vault.azure.net/: jdbc:sqlserver://SERVER.database.windows.net:1433;database=DATABASE;`.
243247

244248
## Next steps
245249

0 commit comments

Comments
 (0)