Skip to content

Commit d987417

Browse files
Merge pull request #210734 from KarlErickson/karler-fix
fixes MicrosoftDocs/azure-docs#97901
2 parents 55e49b1 + bf92362 commit d987417

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

articles/spring-apps/tutorial-managed-identities-mysql.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ The following video describes how to manage secrets using Azure Key Vault.
3636
A resource group is a logical container where 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):
3737

3838
```azurecli
39-
az group create --location <myLocation> --name <myResourceGroup>
39+
az group create --location <location> --name <resource-group-name>
4040
```
4141

4242
## Set up your Key Vault
4343

4444
To create a Key Vault, use the command [az keyvault create](/cli/azure/keyvault#az-keyvault-create):
4545

4646
> [!IMPORTANT]
47-
> Each Key Vault must have a unique name. Replace *\<myKeyVaultName>* with the name of your Key Vault in the following examples.
47+
> Each Key Vault must have a unique name. Replace *\<key-vault-name>* with the name of your Key Vault in the following examples.
4848
4949
```azurecli
50-
az keyvault create --name <myKeyVaultName> -g <myResourceGroup>
50+
az keyvault create --resource-group <resource-group-name> --name <key-vault-name>
5151
```
5252

53-
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.
53+
Make a note of the returned `vaultUri`, which will be in the format `https://<key-vault-name>.vault.azure.net`. It will be used in the following step.
5454

5555
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):
5656

5757
```azurecli
5858
az keyvault secret set \
59-
--vault-name <your-keyvault-name> \
60-
--name <MYSQL-PASSWORD> \
61-
--value <MySQL-PASSWORD>
59+
--vault-name <key-vault-name> \
60+
--name <mysql-password> \
61+
--value <mysql-password>
6262
```
6363

6464
## Set up your Azure Database for MySQL
@@ -69,9 +69,9 @@ Create a database named *demo* for later use.
6969

7070
```azurecli
7171
az mysql db create \
72-
--resource-group <myResourceGroup> \
72+
--resource-group <resource-group-name> \
7373
--name demo \
74-
--server-name <mysqlName>
74+
--server-name <mysql-instance-name>
7575
```
7676

7777
## Create an app and service in Azure Spring Apps
@@ -80,84 +80,84 @@ After installing the corresponding extension, create an Azure Spring Apps instan
8080

8181
```azurecli
8282
az extension add --name spring
83-
az spring create --name <myService> --group <myResourceGroup>
83+
az spring create --name <Azure-Spring-Apps-instance-name> --resource-group <resource-group-name>
8484
```
8585

8686
The following example creates an app named `springapp` with a system-assigned managed identity, as requested by the `--assign-identity` parameter.
8787

8888
```azurecli
8989
az spring app create \
90+
--resource-group <resource-group-name> \
91+
--service <Azure-Spring-Apps-instance-name>
9092
--name springapp
91-
--service <myService>
92-
--group <myResourceGroup> \
9393
--assign-endpoint true \
9494
--assign-identity
95-
export SERVICE_IDENTITY=$(az spring app show --name springapp -s <myService> -g <myResourceGroup> | jq -r '.identity.principalId')
95+
export SERVICE_IDENTITY=$(az spring app show --name springapp -s <Azure-Spring-Apps-instance-name> -g <resource-group-name> | jq -r '.identity.principalId')
9696
```
9797

98-
Make a note of the returned `url`, which will be in the format `https://<your-app-name>.azuremicroservices.io`. It will be used in the following step.
98+
Make a note of the returned `url`, which will be in the format `https://<app-name>.azuremicroservices.io`. It will be used in the following step.
9999

100100
## Grant your app access to Key Vault
101101

102102
Use [az keyvault set-policy](/cli/azure/keyvault#az-keyvault-set-policy) to grant proper access in Key Vault for your app.
103103

104104
```azurecli
105105
az keyvault set-policy
106-
--name <myKeyVaultName> \
106+
--name <key-vault-name> \
107107
--object-id ${SERVICE_IDENTITY} \
108108
--secret-permissions set get list
109109
```
110110

111111
> [!NOTE]
112-
> Use `az keyvault delete-policy --name <myKeyVaultName> --object-id ${SERVICE_IDENTITY}` to remove the access for your app after system-assigned managed identity is disabled.
112+
> Use `az keyvault delete-policy --name <key-vault-name> --object-id ${SERVICE_IDENTITY}` to remove the access for your app after system-assigned managed identity is disabled.
113113
114114
## Build a sample Spring Boot app with Spring Boot starter
115115

116116
This [sample](https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples/tree/master/managed-identity-mysql) will create an entry and list entires from MySQL.
117117

118118
1. Clone a sample project.
119119

120-
```azurecli
121-
git clone https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples.git
122-
```
120+
```azurecli
121+
git clone https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples.git
122+
```
123123

124124
2. Specify your Key Vault and Azure Database for MySQL information in your app's `application.properties`.
125125

126-
```
127-
spring.datasource.url=jdbc:mysql://<mysql-instance-name>.mysql.database.azure.com:3306/demo?serverTimezone=UTC
128-
spring.datasource.username=<mysql-username>@<mysql-instance-name>
129-
spring.cloud.azure.keyvault.secret.endpoint=https://<keyvault-instance-name>.vault.azure.net/
130-
```
126+
```properties
127+
spring.datasource.url=jdbc:mysql://<mysql-instance-name>.mysql.database.azure.com:3306/demo?serverTimezone=UTC
128+
spring.datasource.username=<mysql-username>@<mysql-instance-name>
129+
spring.cloud.azure.keyvault.secret.endpoint=https://<keyvault-instance-name>.vault.azure.net/
130+
```
131131

132132
3. Package your sample app.
133133

134-
```azurecli
135-
mvn clean package
136-
```
134+
```azurecli
135+
mvn clean package
136+
```
137137

138138
4. Now deploy the app to Azure with the Azure CLI command [az spring app deploy](/cli/azure/spring/app#az-spring-cloud-app-deploy).
139139

140-
```azurecli
141-
az spring app deploy \
140+
```azurecli
141+
az spring app deploy \
142+
--resource-group <resource-group-name> \
143+
--service <Azure-Spring-Apps-instance-name> \
142144
--name springapp \
143-
--service <myService> \
144-
--group <myResourceGroup> \
145145
--jar-path target/asc-managed-identity-mysql-sample-0.1.0.jar
146-
```
146+
```
147147

148148
5. Access the public endpoint or test endpoint to test your app.
149149

150-
```
151-
# Create an entry in table
152-
curl --header "Content-Type: application/json" \
153-
--request POST \
154-
--data '{"description":"configuration","details":"congratulations, you have set up JDBC correctly!","done": "true"}' \
155-
https://myspringcloud-springapp.azuremicroservices.io
156-
157-
# List entires in table
158-
curl https://myspringcloud-springapp.azuremicroservices.io
159-
```
160-
150+
```bash
151+
# Create an entry in table
152+
curl --header "Content-Type: application/json" \
153+
--request POST \
154+
--data '{"description":"configuration","details":"congratulations, you have set up JDBC correctly!","done": "true"}' \
155+
https://myspringcloud-springapp.azuremicroservices.io
156+
157+
# List entires in table
158+
curl https://myspringcloud-springapp.azuremicroservices.io
159+
```
160+
161161
## Next Steps
162162

163163
* [Managed identity to connect Key Vault](tutorial-managed-identities-key-vault.md)

0 commit comments

Comments
 (0)