You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article shows you how to create a managed identity for an Azure Spring Apps app and use it to access Azure Key Vault.
22
22
@@ -32,14 +32,14 @@ The following video describes how to manage secrets using Azure Key Vault.
32
32
33
33
*[Sign up for an Azure subscription](https://azure.microsoft.com/free/)
34
34
*[Install the Azure CLI version 2.45.0 or higher](/cli/azure/install-azure-cli)
35
-
*[Install Maven 3.0 or above](https://maven.apache.org/download.cgi)
35
+
*[Install Maven 3.0 or higher](https://maven.apache.org/download.cgi)
36
36
37
37
## Create a resource group
38
38
39
39
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):
40
40
41
41
```azurecli
42
-
az group create --name "myResourceGroup" -l "EastUS"
42
+
az group create --name "myResourceGroup" --location "EastUS"
43
43
```
44
44
45
45
## Set up your Key Vault
@@ -55,7 +55,7 @@ az keyvault create \
55
55
--name "<your-keyvault-name>"
56
56
```
57
57
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.
59
59
60
60
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):
61
61
@@ -84,42 +84,46 @@ The following example creates an app named `springapp` with a system-assigned ma
First, create a user-assigned managed identity in advance with its resource ID set to `$USER_IDENTITY_RESOURCE_ID`. Save the client ID for the property configuration below.
100
+
First, create a user-assigned managed identity in advance with its resource ID set to `$USER_IDENTITY_RESOURCE_ID`. Save the client ID for the property configuration.
97
101
98
102
:::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":::
99
103
100
-
```azurecli
101
-
export SERVICE_IDENTITY={principal ID of user-assignedmanagedidentity}
102
-
export USER_IDENTITY_RESOURCE_ID={resource ID of user-assignedmanagedidentity}
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.
123
127
124
128
## Grant your app access to Key Vault
125
129
@@ -137,17 +141,17 @@ az keyvault set-policy \
137
141
138
142
## Build a sample Spring Boot app with Spring Boot starter
139
143
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.
141
145
142
146
1. Use the following command to generate a sample project from `start.spring.io` with Azure Key Vault Spring Starter.
> You must add the key vault URL in the *application.properties* file as shown above. Otherwise, the key vault URL may not be captured during runtime.
179
+
> You must add the key vault URL in the *application.properties* file as shown previously. Otherwise, the key vault URL may not be captured during runtime.
176
180
177
181
1. Add the following code example to *src/main/java/com/example/demo/DemoApplication.java*. This code retrieves the connection string from the key vault.
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;`.
0 commit comments