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
@@ -46,7 +46,7 @@ If you need to secure your custom domain in Azure Container Apps, you can use a
46
46
47
47
If you have a private certificate stored locally, you can upload it. For more information, see [Custom domain names and bring your own certificates in Azure Container Apps](../../container-apps/custom-domains-certificates.md).
48
48
49
-
If your certificate is from Azure Key Vault, see [Import certificates from Azure Key Vault to Azure Container Apps](../../container-apps/key-vault-certificates-manage.md) for more information.
49
+
If your certificate is from Azure Key Vault, you can import certificates to Azure Container Apps directly. For more information, see [Import certificates from Azure Key Vault to Azure Container Apps](../../container-apps/key-vault-certificates-manage.md).
50
50
51
51
If you want to continue using the original certificate and domain name from Azure Spring Apps, you can upload the certificate to container apps or Azure Key Vault. Also, you can update the A record or CNAME in your DNS provider to redirect the original domain name to the container app IP or URL.
52
52
@@ -117,140 +117,122 @@ For more information, see the [Peer-to-peer encryption](../../container-apps/net
117
117
118
118
## Traffic to external services
119
119
120
-
### Reference a certificate from Key Vault and mount certificates in a volume
120
+
This sample shows how to enable TLS and mTLS for traffic to external services by loading the certificate from Azure Key Vault using the `spring-cloud-azure-starter-keyvault-jca` library. Your Java project must use Spring Boot 3.1+ and include the following dependency in your **pom.xml** file:
121
121
122
-
When you define a certificate, you create a reference to a certificate stored in Azure Key Vault. Azure Container Apps automatically retrieves the certificate value from Key Vault and makes it available as a secret in your container app.
123
-
124
-
To reference a certificate from Key Vault, you must first enable managed identity in your container app and grant the identity access to the Key Vault secrets.
125
-
126
-
To enable managed identity in your container app, see [Managed identities in Azure Container Apps](../../container-apps/managed-identity.md).
127
-
128
-
To grant access to a Key Vault certificate, add the role assignment `Key Vault Secrets User` in Key Vault for the managed identity you created. For more information, see [Best Practices for individual keys, secrets, and certificates role assignments](/azure/key-vault/general/rbac-guide#best-practices-for-individual-keys-secrets-and-certificates-role-assignments).
129
-
130
-
When you create a container app, certificates are defined using the `--secrets` parameter and using the following guidelines:
131
-
132
-
- The parameter accepts a space-delimited set of name/value pairs.
133
-
- Each pair is delimited by an equals sign (`=`).
134
-
- To specify a Key Vault reference, use the format `<certificate-name>=keyvaultref:<key-vault-secret-identifier-of-certificate>,identityref:<managed-identity-ID>`. For example, `my-cert=keyvaultref:https://mykeyvault.vault.azure.net/secrets/mycert,identityref:/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-identity`.
Here, a certificate is declared in the `--secrets` parameter. Replace `<key-vault-secret-identifier-of-certificate>` with the Secret Identifier URI of your certificate in Key Vault. Replace `<user-assigned-identity-ID>` with the resource ID of the user assigned identity. For a system assigned identity, use `system` instead of the resource ID. The certificate mounted in a volume is named `my-cert` of type Secret. The volume is mounted at the path **/mnt/cert**. The application can then read the secrets as files in the volume mount.
130
+
### Load a certificate into the truststore from Key Vaultwith SSL bundle
150
131
151
-
For an existing container app, you can use following commands to reference a secret from Key Vault and mount it to a volume:
132
+
Use the following steps to load a certificate into the truststore from Azure Key Vault using the `spring-cloud-azure-starter-keyvault-jca` library:
1. Generate or import certificates in Azure Key Vault. For more information, see [Create and import certificates in Azure Key Vault](/azure/key-vault/certificates/certificate-scenarios#creating-and-importing-certificates).
158
135
159
-
az containerapp update \
160
-
--resource-group "my-resource-group" \
161
-
--name "my-app" \
162
-
--secret-volume-mount "/mnt/cert"
163
-
```
164
-
165
-
### Load a certificate from code
166
-
167
-
Your loaded certificates are available in your defined mounted path - for example, **/mnt/cert/my-cert**. Use the following Java code to load a certificate in an application in Azure Container Apps.
168
-
169
-
Because the certificate is mounted as a secret, its content is encoded in Base64, so you might need to decode it before use.
1. Enable managed identity in your container app. To enable managed identity in your container app, see [Managed identities in Azure Container Apps](../../container-apps/managed-identity.md).
197
137
198
-
In this sample code, you need to import [org.bouncycastle.bcpkix-lts8on](https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-lts8on) to your project to parse the certificate data.
138
+
1. Grant the `Key Vault Certificate User` role to the managed identity in your Key Vault. For more information, see [Best Practices for individual keys, secrets, and certificates role assignments](/azure/key-vault/general/rbac-guide#best-practices-for-individual-keys-secrets-and-certificates-role-assignments).
199
139
200
-
### Load a certificate into the trust store
140
+
1. Add the following configuration to your **application.yml** file:
201
141
202
-
Use the following steps to load a certificate:
203
-
204
-
1. Set up a storage account - for example, `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageaccount`.
205
-
206
-
1. Download and upload the JCA library. Get the latest version of the JCA library from the Maven repository [azure-security-keyvault-jca](https://mvnrepository.com/artifact/com.azure/azure-security-keyvault-jca) and upload the JAR file to a file share in the storage account - for example, **/jca/lib/azure-security-keyvault-jca.jar**.
207
-
208
-
1. Use the following steps to modify and upload a Java security configuration:
209
-
210
-
1. Make a copy of the **java.security** file in your JDK. For Java version 8 or earlier, you can find the **java.security** file at **$JAVA_HOME/jre/lib/security/java.security**. For Java version 11 or later, you can find the **java.security** file at **$JAVA_HOME/conf/security**.
211
-
212
-
1. Locate `security.provider.<#>=` property in the file and add the following line:
In this line, the number sign placeholder `<#>` represents one increment above the last number in the list - for example, `security.provider.14`.
219
-
220
-
1. Upload the modified **java.security** file to a file share in the storage account - for example, **/jca/security/java.security**.
221
-
222
-
1. Upload the certificates that need to be loaded into the trust store to the file share in the storage account - for example, **/jca/truststore/**.
223
-
224
-
1. Add the volume mount. To add a volume mount for the JCA library and certificates in the container app, see [Tutorial: Create an Azure Files volume mount in Azure Container Apps](../../container-apps/storage-mounts-azure-files.md). You can mount it, for example, as **/mnt/jca/**.
225
-
226
-
1. Update your image with JCA-related parameters. Modify your Dockerfile as shown in the following example:
1. Rebuild the image with the following command and then upload it to the container registry:
242
-
243
-
```azurecli
244
-
docker build -t <image-name>:<image-tag> \
245
-
-f JAR.dockerfile \
246
-
--build-arg JAR_FILENAME=<path-to-jar> \
247
-
.
178
+
### Enable mTLS communication
179
+
180
+
Use the following steps to set up mTLS for two-way authentication between client and server:
181
+
182
+
1. Generate or import both client and server certificates to Azure Key Vault. For more information, see [Create and import certificates in Azure Key Vault](/azure/key-vault/certificates/certificate-scenarios#creating-and-importing-certificates).
183
+
184
+
1. Enable managed identity for your container app. To enable managed identity in your container app, see [Managed identities in Azure Container Apps](../../container-apps/managed-identity.md).
185
+
186
+
1. Grant the `Key Vault Certificate User` role to the managed identity for both key vaults. For more information, see [Best Practices for individual keys, secrets, and certificates role assignments](/azure/key-vault/general/rbac-guide#best-practices-for-individual-keys-secrets-and-certificates-role-assignments).
187
+
188
+
1. Add the following configuration to your **application.yml** file for mTLS:
client-id: ${KEY_VAULT_SSL_BUNDLES_CLIENT_ID} # Required for user-assigned managed identity
217
+
managed-identity-enabled: true
248
218
```
249
219
250
-
1. Create or update your container app. For more information, see [Quickstart: Deploy your first container app using the Azure portal](../../container-apps/quickstart-portal.md).
220
+
1. To apply the Key Vault SSL bundle, update your `RestTemplate` or `WebClient` bean configuration, as shown in the following example:
251
221
252
-
For more information on using the JCA Provider for Azure Key Vault in your Java application, see [JCA Provider Example](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/keyvault/azure-security-keyvault-jca#examples).
This method maintains consistency with the behavior of Azure Spring Apps. You can also use other ways to load certificates into the trust store.
236
+
For more information on using the `spring-cloud-azure-starter-keyvault-jca` library in your Spring Boot application, see [Introducing Spring Cloud Azure Starter Key Vault JCA: Streamlined TLS and mTLS for Spring Boot](https://devblogs.microsoft.com/azure-sdk/introducing-spring-cloud-azure-starter-key-vault-jca-streamlined-tls-and-mtls-for-spring-boot/).
255
237
256
238
By following these steps, you can successfully migrate your custom domain with TLS/SSL from Azure Spring Apps to Azure Container Apps, maintaining secure and efficient communication across all traffic types.
0 commit comments