diff --git a/examples/QuickStart/DotNet/QuickStartApp/Program.cs b/examples/QuickStart/DotNet/QuickStartApp/Program.cs index bbcb0d9c..3c0bb58e 100644 --- a/examples/QuickStart/DotNet/QuickStartApp/Program.cs +++ b/examples/QuickStart/DotNet/QuickStartApp/Program.cs @@ -1,9 +1,13 @@ using Microsoft.Extensions.Configuration; +using Azure.Identity; + +Uri endpoint = new(Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT") ?? + throw new InvalidOperationException("The environment variable 'AZURE_APPCONFIGURATION_ENDPOINT' is not set or is empty.")); var builder = new ConfigurationBuilder(); builder.AddAzureAppConfiguration(options => { - options.Connect(Environment.GetEnvironmentVariable("AZURE_APPCONFIG_CONNECTION_STRING")) + options.Connect(endpoint, new DefaultAzureCredential()) .Select("QuickStartApp*"); }); diff --git a/examples/QuickStart/DotNet/QuickStartApp/QuickStartApp.csproj b/examples/QuickStart/DotNet/QuickStartApp/QuickStartApp.csproj index a2457ca0..cf201b20 100644 --- a/examples/QuickStart/DotNet/QuickStartApp/QuickStartApp.csproj +++ b/examples/QuickStart/DotNet/QuickStartApp/QuickStartApp.csproj @@ -8,7 +8,8 @@ - + + diff --git a/examples/QuickStart/JavaScript/QuickStartApp/QuickStartApp.js b/examples/QuickStart/JavaScript/QuickStartApp/QuickStartApp.js index f0dffae1..fd8caf18 100644 --- a/examples/QuickStart/JavaScript/QuickStartApp/QuickStartApp.js +++ b/examples/QuickStart/JavaScript/QuickStartApp/QuickStartApp.js @@ -1,11 +1,13 @@ const { load } = require("@azure/app-configuration-provider"); -const connectionString = process.env.AZURE_APPCONFIG_CONNECTION_STRING; +const { DefaultAzureCredential } = require("@azure/identity"); + +const endpoint = process.env.AZURE_APPCONFIGURATION_ENDPOINT; async function run() { console.log("Sample 1: Load key-values with default selector"); - // Connect to Azure App Configuration using a connection string and load all key-values with null label. - const settings = await load(connectionString); + // Connect to Azure App Configuration using Microsoft Entra ID authentication and load all key-values with null label. + const settings = await load(endpoint, new DefaultAzureCredential()); console.log("---Consume configuration as a Map---"); // Find the key "message" and print its value. diff --git a/examples/QuickStart/JavaScript/QuickStartApp/package.json b/examples/QuickStart/JavaScript/QuickStartApp/package.json index 072e33a7..140f18fc 100644 --- a/examples/QuickStart/JavaScript/QuickStartApp/package.json +++ b/examples/QuickStart/JavaScript/QuickStartApp/package.json @@ -1,5 +1,6 @@ { "dependencies": { - "@azure/app-configuration-provider": "latest" + "@azure/app-configuration-provider": "latest", + "@azure/identity": "latest" } } \ No newline at end of file diff --git a/examples/QuickStart/JavaSpring/QuickStart/pom.xml b/examples/QuickStart/JavaSpring/QuickStart/pom.xml index 5037320c..f94d821e 100644 --- a/examples/QuickStart/JavaSpring/QuickStart/pom.xml +++ b/examples/QuickStart/JavaSpring/QuickStart/pom.xml @@ -17,6 +17,10 @@ com.azure.spring spring-cloud-azure-appconfiguration-config-web + + com.azure.spring + azure-identity-spring + diff --git a/examples/QuickStart/JavaSpring/QuickStart/src/main/resources/bootstrap.properties b/examples/QuickStart/JavaSpring/QuickStart/src/main/resources/bootstrap.properties index 9a1ccf1d..218d3be8 100644 --- a/examples/QuickStart/JavaSpring/QuickStart/src/main/resources/bootstrap.properties +++ b/examples/QuickStart/JavaSpring/QuickStart/src/main/resources/bootstrap.properties @@ -1,4 +1,4 @@ spring.application.name=QuickStart # Either a connection string or endpoint needs to be provided per store. # 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) -spring.cloud.azure.appconfiguration.stores[0].connection-string= ${AZURE_APPCONFIG_CONNECTION_STRING} +spring.cloud.azure.appconfiguration.stores[0].endpoint= ${AZURE_APPCONFIGURATION_ENDPOINT} diff --git a/examples/QuickStart/Python/QuickStartApp/QuickStartApp.py b/examples/QuickStart/Python/QuickStartApp/QuickStartApp.py index eb19301b..fb75d289 100644 --- a/examples/QuickStart/Python/QuickStartApp/QuickStartApp.py +++ b/examples/QuickStart/Python/QuickStartApp/QuickStartApp.py @@ -2,12 +2,13 @@ load, SettingSelector ) +from azure.identity import DefaultAzureCredential import os -connection_string = os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING") +endpoint = os.environ.get("AZURE_APPCONFIGURATION_ENDPOINT") -# Connect to Azure App Configuration using a connection string. -config = load(connection_string=connection_string) +# Connect to Azure App Configuration using Microsoft Entra ID authentication. +config = load(endpoint=endpoint, credential=DefaultAzureCredential()) # Find the key "message" and print its value. print(config["message"])