File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Microsoft . Extensions . Configuration ;
2+ using Azure . Identity ;
3+
4+ Uri endpoint = new ( Environment . GetEnvironmentVariable ( "AZURE_APPCONFIGURATION_ENDPOINT" ) ??
5+ throw new InvalidOperationException ( "The environment variable 'AZURE_APPCONFIGURATION_ENDPOINT' is not set or is empty." ) ) ;
26
37var builder = new ConfigurationBuilder ( ) ;
48builder . AddAzureAppConfiguration ( options =>
59{
6- options . Connect ( Environment . GetEnvironmentVariable ( "AZURE_APPCONFIG_CONNECTION_STRING" ) )
10+ options . Connect ( endpoint , new DefaultAzureCredential ( ) )
711 . Select ( "QuickStartApp*" ) ;
812} ) ;
913
Original file line number Diff line number Diff line change 88 </PropertyGroup >
99
1010 <ItemGroup >
11- <PackageReference Include =" Microsoft.Extensions.Configuration.AzureAppConfiguration" Version =" 6.0.1" />
11+ <PackageReference Include =" Azure.Identity" Version =" 1.14.0" />
12+ <PackageReference Include =" Microsoft.Extensions.Configuration.AzureAppConfiguration" Version =" 8.4.0" />
1213 </ItemGroup >
1314
1415</Project >
Original file line number Diff line number Diff line change 11const { load } = require ( "@azure/app-configuration-provider" ) ;
2- const connectionString = process . env . AZURE_APPCONFIG_CONNECTION_STRING ;
2+ const { DefaultAzureCredential } = require ( "@azure/identity" ) ;
3+
4+ const endpoint = process . env . AZURE_APPCONFIGURATION_ENDPOINT ;
35
46async function run ( ) {
57 console . log ( "Sample 1: Load key-values with default selector" ) ;
68
7- // Connect to Azure App Configuration using a connection string and load all key-values with null label.
8- const settings = await load ( connectionString ) ;
9+ // Connect to Azure App Configuration using Microsoft Entra ID authentication and load all key-values with null label.
10+ const settings = await load ( endpoint , new DefaultAzureCredential ( ) ) ;
911
1012 console . log ( "---Consume configuration as a Map---" ) ;
1113 // Find the key "message" and print its value.
Original file line number Diff line number Diff line change 11{
22 "dependencies" : {
3- "@azure/app-configuration-provider" : " latest"
3+ "@azure/app-configuration-provider" : " latest" ,
4+ "@azure/identity" : " latest"
45 }
56}
Original file line number Diff line number Diff line change 1717 <groupId >com.azure.spring</groupId >
1818 <artifactId >spring-cloud-azure-appconfiguration-config-web</artifactId >
1919 </dependency >
20+ <dependency >
21+ <groupId >com.azure.spring</groupId >
22+ <artifactId >azure-identity-spring</artifactId >
23+ </dependency >
2024 </dependencies >
2125
2226 <dependencyManagement >
Original file line number Diff line number Diff line change 11spring.application.name =QuickStart
22# Either a connection string or endpoint needs to be provided per store.
33# All possible configurations can be found in the [README](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/spring-cloud-azure-starter-appconfiguration-config)
4- spring.cloud.azure.appconfiguration.stores[0].connection-string = ${AZURE_APPCONFIG_CONNECTION_STRING }
4+ spring.cloud.azure.appconfiguration.stores[0].endpoint = ${AZURE_APPCONFIGURATION_ENDPOINT }
Original file line number Diff line number Diff line change 22 load ,
33 SettingSelector
44)
5+ from azure .identity import DefaultAzureCredential
56import os
67
7- connection_string = os .environ .get ("AZURE_APPCONFIG_CONNECTION_STRING " )
8+ endpoint = os .environ .get ("AZURE_APPCONFIGURATION_ENDPOINT " )
89
9- # Connect to Azure App Configuration using a connection string .
10- config = load (connection_string = connection_string )
10+ # Connect to Azure App Configuration using Microsoft Entra ID authentication .
11+ config = load (endpoint = endpoint , credential = DefaultAzureCredential () )
1112
1213# Find the key "message" and print its value.
1314print (config ["message" ])
You can’t perform that action at this time.
0 commit comments