Enable geo-replication
This article covers replication of Azure App Configuration stores. You'll learn about how to create, use and delete a replica in your configuration store.
To learn more about the concept of geo-replication, see Geo-replication in Azure App Configuration.
Prerequisites
- An Azure subscription - create one for free
- We assume you already have an App Configuration store. If you want to create one, create an App Configuration store.
Create and list a replica
To create a replica of your configuration store in the portal, follow the steps below.
Note
Creating a replica for an App Configuration store with private endpoints configured with Static IP is not supported. If you prefer a private endpoint with Static IP configuration, replicas must be created before any private endpoint is added to a store.
In your App Configuration store, under Settings, select Geo-replication.
Under Replica(s), select Create. Choose the location of your new replica in the dropdown, then assign the replica a name. This replica name must be unique.
Select Create.
You should now see your new replica listed under Replica(s). Check that the status of the replica is "Succeeded", which indicates that it was created successfully.
Delete a replica
To delete a replica in the portal, follow the steps below.
In your App Configuration store, under Settings, select Geo-replication.
Under Replica(s), select the ... to the right of the replica you want to delete. Select Delete from the dropdown.
Verify the name of the replica to be deleted and select OK to confirm.
Once the process is complete, check the list of replicas that the correct replica has been deleted.
Use replicas
Each replica you create has its dedicated endpoint. If your application resides in multiple geolocations, you can update each deployment of your application in a location to connect to the replica closer to that location, which helps minimize the network latency between your application and App Configuration. Since each replica has its separate request quota, this setup also helps the scalability of your application while it grows to a multi-region distributed service.
When geo-replication is enabled, and if one replica isn't accessible, you can let your application failover to another replica for improved resiliency. App Configuration provider libraries have built-in failover support by accepting multiple replica endpoints. You can provide a list of your replica endpoints in the order of the most preferred to the least preferred endpoint. When the current endpoint isn't accessible, the provider library will fail over to a less preferred endpoint, but it will try to connect to the more preferred endpoints from time to time. When a more preferred endpoint becomes available, it will switch to it for future requests.
Assuming you have an application using Azure App Configuration, you can update it as the following sample code to take advantage of the failover feature. You can either provide a list of endpoints for Microsoft Entra authentication or a list of connection strings for access key-based authentication.
Edit the call to the AddAzureAppConfiguration
method, which is often found in the program.cs
file of your application.
Connect with Microsoft Entra ID
configurationBuilder.AddAzureAppConfiguration(options =>
{
// Provide an ordered list of replica endpoints
var endpoints = new Uri[] {
new Uri("<first-replica-endpoint>"),
new Uri("<second-replica-endpoint>") };
// Connect to replica endpoints using Azure AD authentication
options.Connect(endpoints, new DefaultAzureCredential());
// Other changes to options
});
Connect with Connection String
configurationBuilder.AddAzureAppConfiguration(options =>
{
// Provide an ordered list of replica connection strings
var connectionStrings = new string[] {
Environment.GetEnvironmentVariable("FIRST_REPLICA_CONNECTION_STRING"),
Environment.GetEnvironmentVariable("SECOND_REPLICA_CONNECTION_STRING") };
// Connect to replica endpoints using connection strings
options.Connect(connectionStrings);
// Other changes to options
});
Note
The failover support is available if you use version 6.0.0 or later of any of the following packages.
Microsoft.Extensions.Configuration.AzureAppConfiguration
Microsoft.Azure.AppConfiguration.AspNetCore
Microsoft.Azure.AppConfiguration.Functions.Worker
The failover may occur if the App Configuration provider observes the following conditions.
- Receives responses with service unavailable status (HTTP status code 500 or above).
- Experiences with network connectivity issues.
- Requests are throttled (HTTP status code 429).
The failover won't happen for client errors like authentication failures.
Next steps
Feedback
Submit and view feedback for