This page shows supported authentication methods and clients. It provides sample code you can use to connect Azure App Configuration to other cloud services using Service Connector. You might be able to connect to App Configuration using other methods. This page also shows default environment variable names and values you get when you create the service connection.
Supported compute services
Service Connector can be used to connect the following compute services to Azure App Configuration:
- Azure App Service
- Azure Container Apps
- Azure Functions
- Azure Kubernetes Service (AKS)
- Azure Spring Apps
Supported authentication types and client types
This table shows which combinations of authentication methods and clients are supported for connecting your compute service to Azure App Configuration using Service Connector. A "Yes" indicates that the combination is supported, while a "No" indicates that it isn't supported.
| Client type |
System-assigned managed identity |
User-assigned managed identity |
Secret/connection string |
Service principal |
| .NET |
Yes |
Yes |
Yes |
Yes |
| Java |
Yes |
Yes |
Yes |
Yes |
| Node.js |
Yes |
Yes |
Yes |
Yes |
| Python |
Yes |
Yes |
Yes |
Yes |
| None |
Yes |
Yes |
Yes |
Yes |
This table indicates that all combinations of client types and authentication methods in the table are supported. All client types can use any of the authentication methods to connect to Azure App Configuration using Service Connector.
Default environment variable names or application properties and sample code
Use the following connection details to connect compute services to Azure App Configuration stores. For more information, see Configuration naming convention.
System-assigned managed identity
| Default environment variable name |
Description |
Sample value |
| AZURE_APPCONFIGURATION_ENDPOINT |
App Configuration endpoint |
https://<App-Configuration-name>.azconfig.io |
Sample code
To connect to Azure App Configuration using a system-assigned managed identity, refer to the following steps and code.
Install dependencies.
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
dotnet add package Azure.Identity
Authenticate using Azure.Identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
string endpoint = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
var client = new ConfigurationClient(new Uri(endpoint), credential);
Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential defaultCredential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .clientSecret(System.getenv("AZURE_APPCONFIGURATION_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_APPCONFIGURATION_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_APPCONFIGURATION_ENDPOINT");
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
Install dependencies.
pip install azure-appconfiguration
pip install azure-identity
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_APPCONFIGURATION_TENANTID')
# client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# client_secret = os.getenv('AZURE_APPCONFIGURATION_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint_url = os.getenv('AZURE_APPCONFIGURATION_ENDPOINT')
client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential)
Install dependencies.
npm install --save @azure/identity
npm install @azure/app-configuration
Authenticate using @azure/identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const appConfig = require("@azure/app-configuration");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_APPCONFIGURATION_TENANTID;
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const clientSecret = process.env.AZURE_APPCONFIGURATION_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_APPCONFIGURATION_ENDPOINT;
const client = new appConfig.AppConfigurationClient(
endpoint,
credential
);
User-assigned managed identity
| Default environment variable name |
Description |
Sample value |
| AZURE_APPCONFIGURATION_ENDPOINT |
App Configuration Endpoint |
https://App-Configuration-name>.azconfig.io |
| AZURE_APPCONFIGURATION_CLIENTID |
Your client ID |
<client-ID> |
Sample code
To connect to Azure App Configuration using a user-assigned managed identity, refer to the following steps and code.
Install dependencies.
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
dotnet add package Azure.Identity
Authenticate using Azure.Identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
string endpoint = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
var client = new ConfigurationClient(new Uri(endpoint), credential);
Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential defaultCredential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .clientSecret(System.getenv("AZURE_APPCONFIGURATION_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_APPCONFIGURATION_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_APPCONFIGURATION_ENDPOINT");
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
Install dependencies.
pip install azure-appconfiguration
pip install azure-identity
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_APPCONFIGURATION_TENANTID')
# client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# client_secret = os.getenv('AZURE_APPCONFIGURATION_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint_url = os.getenv('AZURE_APPCONFIGURATION_ENDPOINT')
client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential)
Install dependencies.
npm install --save @azure/identity
npm install @azure/app-configuration
Authenticate using @azure/identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const appConfig = require("@azure/app-configuration");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_APPCONFIGURATION_TENANTID;
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const clientSecret = process.env.AZURE_APPCONFIGURATION_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_APPCONFIGURATION_ENDPOINT;
const client = new appConfig.AppConfigurationClient(
endpoint,
credential
);
Connection string
Warning
Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application. It carries risks that aren't present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
| Default environment variable name |
Description |
Sample value |
| AZURE_APPCONFIGURATION_CONNECTIONSTRING |
Your App Configuration Connection String |
Endpoint=https://<App-Configuration-name>.azconfig.io;Id=<ID>;Secret=<secret> |
Sample Code
To connect to Azure App Configuration using a connection string, refer to the following steps and code.
Install dependencies.
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
Get the App Configuration connection string from the environment variables added by Service Connector.
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
var connectionString = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CONNECTIONSTRING");
var builder = new ConfigurationBuilder();
builder.AddAzureAppConfiguration(connectionString);
var config = builder.Build();
Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>1.4.9</version>
</dependency>
Get the App Configuration connection string from the environment variables added by Service Connector.
String connectionString = System.getenv("AZURE_APPCONFIGURATION_CONNECTIONSTRING");
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.connectionString(connectionString)
.buildClient();
Install dependencies.
pip install azure-appconfiguration
Get the App Configuration connection string from the environment variables added by Service Connector.
import os
from azure.appconfiguration import AzureAppConfigurationClient
connection_string = os.getenv('AZURE_APPCONFIGURATION_CONNECTIONSTRING')
app_config_client = AzureAppConfigurationClient.from_connection_string(connection_string)
Install dependencies.
npm install @azure/app-configuration
Get the App Configuration connection string from the environment variables added by Service Connector.
const appConfig = require("@azure/app-configuration");
const connection_string = process.env.AZURE_APPCONFIGURATION_CONNECTIONSTRING;
const client = new appConfig.AppConfigurationClient(connection_string);
Service principal
| Default environment variable name |
Description |
Sample value |
| AZURE_APPCONFIGURATION_ENDPOINT |
App Configuration Endpoint |
https://<AppConfigurationName>.azconfig.io |
| AZURE_APPCONFIGURATION_CLIENTID |
Your client ID |
<client-ID> |
| AZURE_APPCONFIGURATION_CLIENTSECRET |
Your client secret |
<client-secret> |
| AZURE_APPCONFIGURATION_TENANTID |
Your tenant ID |
<tenant-ID> |
Sample code
To connect to Azure App Configuration using a service principal, refer to the following steps and code.
Install dependencies.
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
dotnet add package Azure.Identity
Authenticate using Azure.Identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
string endpoint = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
var client = new ConfigurationClient(new Uri(endpoint), credential);
Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential defaultCredential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_APPCONFIGURATION_CLIENTID"))
// .clientSecret(System.getenv("AZURE_APPCONFIGURATION_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_APPCONFIGURATION_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_APPCONFIGURATION_ENDPOINT");
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
Install dependencies.
pip install azure-appconfiguration
pip install azure-identity
Authenticate using azure-identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_APPCONFIGURATION_TENANTID')
# client_id = os.getenv('AZURE_APPCONFIGURATION_CLIENTID')
# client_secret = os.getenv('AZURE_APPCONFIGURATION_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint_url = os.getenv('AZURE_APPCONFIGURATION_ENDPOINT')
client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential)
Install dependencies.
npm install --save @azure/identity
npm install @azure/app-configuration
Authenticate using @azure/identity and get the Azure App Configuration endpoint from the environment variables added by Service Connector. When using this code, uncomment the part of the code snippet for the authentication type you want to use.
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const appConfig = require("@azure/app-configuration");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_APPCONFIGURATION_TENANTID;
// const clientId = process.env.AZURE_APPCONFIGURATION_CLIENTID;
// const clientSecret = process.env.AZURE_APPCONFIGURATION_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_APPCONFIGURATION_ENDPOINT;
const client = new appConfig.AppConfigurationClient(
endpoint,
credential
);
Next step