Skip to content

Commit 2b3a107

Browse files
authored
Merge pull request #193158 from mrm9084/AppConfigSpringManagedIdentity
App Configuration Spring Managed Identity
2 parents 8f922ef + 33859a4 commit 2b3a107

File tree

3 files changed

+63
-6
lines changed

3 files changed

+63
-6
lines changed

articles/azure-app-configuration/howto-integrate-azure-managed-service-identity.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@ ms.service: azure-app-configuration
88
ms.custom: devx-track-csharp, fasttrack-edit, subject-rbac-steps
99
ms.topic: conceptual
1010
ms.date: 04/08/2021
11+
zone_pivot_groups: appconfig-provider
1112
---
1213
# Use managed identities to access App Configuration
1314

1415
Azure Active Directory [managed identities](../active-directory/managed-identities-azure-resources/overview.md) simplify secrets management for your cloud application. With a managed identity, your code can use the service principal created for the Azure service it runs on. You use a managed identity instead of a separate credential stored in Azure Key Vault or a local connection string.
1516

1617
Azure App Configuration and its .NET Core, .NET Framework, and Java Spring client libraries have managed identity support built into them. Although you aren't required to use it, the managed identity eliminates the need for an access token that contains secrets. Your code can access the App Configuration store using only the service endpoint. You can embed this URL in your code directly without exposing any secret.
1718

19+
:::zone target="docs" pivot="framework-dotnet"
20+
1821
This article shows how you can take advantage of the managed identity to access App Configuration. It builds on the web app introduced in the quickstarts. Before you continue, [Create an ASP.NET Core app with App Configuration](./quickstart-aspnet-core-app.md) first.
1922

23+
:::zone-end
24+
25+
:::zone target="docs" pivot="framework-spring"
26+
27+
This article shows how you can take advantage of the managed identity to access App Configuration. It builds on the web app introduced in the quickstarts. Before you continue, [Create a Java Spring app with Azure App Configuration](./quickstart-java-spring-app.md) first.
28+
29+
:::zone-end
30+
2031
> [!IMPORTANT]
2132
> Managed Identity cannot be used to authenticate locally-running applications. Your application must be deployed to an Azure service that supports Managed Identity. This article uses Azure App Service as an example, but the same concept applies to any other Azure service that supports managed identity, for example, [Azure Kubernetes Service](../aks/use-azure-ad-pod-identity.md), [Azure Virtual Machine](../active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm.md), and [Azure Container Instances](../container-instances/container-instances-managed-identity.md). If your workload is hosted in one of those services, you can leverage the service's managed identity support, too.
2233
@@ -28,14 +39,25 @@ In this article, you learn how to:
2839
> * Grant a managed identity access to App Configuration.
2940
> * Configure your app to use a managed identity when you connect to App Configuration.
3041
31-
3242
## Prerequisites
3343

3444
To complete this tutorial, you must have:
3545

46+
:::zone target="docs" pivot="framework-dotnet"
47+
3648
* [.NET Core SDK](https://dotnet.microsoft.com/download).
3749
* [Azure Cloud Shell configured](../cloud-shell/quickstart.md).
3850

51+
:::zone-end
52+
53+
:::zone target="docs" pivot="framework-spring"
54+
55+
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
56+
- A supported [Java Development Kit (JDK)](/java/azure/jdk) with version 11.
57+
- [Apache Maven](https://maven.apache.org/download.cgi) version 3.0 or above.
58+
59+
:::zone-end
60+
3961
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
4062

4163
## Add a managed identity
@@ -66,16 +88,18 @@ The following steps describe how to assign the App Configuration Data Reader rol
6688

6789
1. On the **Role** tab, select the **App Configuration Data Reader** role.
6890

69-
![Add role assignment page with Role tab selected.](../../includes/role-based-access-control/media/add-role-assignment-role-generic.png)
91+
![Add role assignment page with Role tab selected.](./media/add-role-assignment-role.png)
7092

7193
1. On the **Members** tab, select **Managed identity**, and then select **Select members**.
7294

73-
1. Select your Azure subscription, select **System-assigned managed identity**, and then select **App Service**.
95+
1. Select your Azure subscription, for Managed Identity select **App Service**, then select your App Service name.
7496

7597
1. On the **Review + assign** tab, select **Review + assign** to assign the role.
7698

7799
## Use a managed identity
78100

101+
:::zone target="docs" pivot="framework-dotnet"
102+
79103
1. Add a reference to the *Azure.Identity* package:
80104

81105
```bash
@@ -158,13 +182,38 @@ The following steps describe how to assign the App Configuration Data Reader rol
158182
> });
159183
>```
160184
>As explained in the [Managed Identities for Azure resources FAQs](../active-directory/managed-identities-azure-resources/known-issues.md), there is a default way to resolve which managed identity is used. In this case, the Azure Identity library enforces you to specify the desired identity to avoid posible runtime issues in the future (for instance, if a new user-assigned managed identity is added or if the system-assigned managed identity is enabled). So, you will need to specify the clientId even if only one user-assigned managed identity is defined, and there is no system-assigned managed identity.
161-
162-
185+
186+
:::zone-end
187+
188+
:::zone target="docs" pivot="framework-spring"
189+
190+
1. Find the endpoint to your App Configuration store. This URL is listed on the **Overview** tab for the store in the Azure portal.
191+
192+
1. Open `bootstrap.properties`, remove the connection-string property and replace it with endpoint:
193+
194+
```properties
195+
spring.cloud.azure.appconfiguration.stores[0].endpoint=<service_endpoint>
196+
```
197+
198+
> [!NOTE]
199+
> If you want to use **user-assigned managed identity** the property `spring.cloud.azure.appconfiguration.stores[0].managed-identity.client-id`, be sure to specify the clientId when creating the [ManagedIdentityCredential](/java/api/com.azure.identity.managedidentitycredential).
200+
201+
:::zone-end
163202
164203
## Deploy your application
165204
205+
:::zone target="docs" pivot="framework-dotnet"
206+
166207
Using managed identities requires you to deploy your app to an Azure service. Managed identities can't be used for authentication of locally-running apps. To deploy the .NET Core app that you created in the [Create an ASP.NET Core app with App Configuration](./quickstart-aspnet-core-app.md) quickstart and modified to use managed identities, follow the guidance in [Publish your web app](../app-service/quickstart-dotnetcore.md?pivots=development-environment-vs&tabs=netcore31#publish-your-web-app).
167208
209+
:::zone-end
210+
211+
:::zone target="docs" pivot="framework-spring"
212+
213+
Using managed identities requires you to deploy your app to an Azure service. Managed identities can't be used for authentication of locally-running apps. To deploy the Spring app that you created in the [Create a Java Spring app with Azure App Configuration](./quickstart-java-spring-app.md) quickstart and modified to use managed identities, follow the guidance in [Publish your web app](../app-service/quickstart-java.md?tabs=javase&pivots=platform-linux).
214+
215+
:::zone-end
216+
168217
In addition to App Service, many other Azure services support managed identities. For more information, see [Services that support managed identities for Azure resources](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md).
169218
170219
## Clean up resources
444 KB
Loading

articles/zone-pivot-groups.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,4 +1749,12 @@ groups:
17491749
title: Azure Resouce Manager
17501750
- id: aro-bicep
17511751
title: Bicep
1752-
1752+
# Owner: mametcal
1753+
- id: appconfig-provider
1754+
title: Client Library pivots
1755+
prompt: Choose a Client Library
1756+
pivots:
1757+
- id: framework-dotnet
1758+
title: .Net
1759+
- id: framework-spring
1760+
title: Spring

0 commit comments

Comments
 (0)