| title | Quickstart for Azure App Configuration with .NET | Microsoft Docs |
|---|---|
| description | In this quickstart, create a .NET app with Azure App Configuration to centralize storage and management of application settings separate from your code. |
| services | azure-app-configuration |
| author | maud-lv |
| ms.service | azure-app-configuration |
| ms.devlang | csharp |
| ms.topic | quickstart |
| ms.custom | devx-track-csharp, mode-other, devx-track-dotnet |
| ms.date | 09/30/2025 |
| ms.author | malev |
In this quickstart, you incorporate Azure App Configuration into a .NET console app to centralize storage and management of application settings separate from your code.
- An Azure account with an active subscription. Create one for free.
- An App Configuration store, as shown in the tutorial for creating a store.
- .NET SDK 6.0 or later - also available in the Azure Cloud Shell.
Add the following key-value to the App Configuration store and leave Label and Content Type with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to Create a key-value.
| Key | Value |
|---|---|
| TestApp:Settings:Message | Data from Azure App Configuration |
You can use the .NET command-line interface (CLI) to create a new .NET console app project. The advantage of using the .NET CLI over Visual Studio is that it's available across the Windows, macOS, and Linux platforms. Alternatively, use the preinstalled tools available in the Azure Cloud Shell.
-
Create a new folder for your project.
-
In the new folder, run the following command to create a new .NET console app project:
dotnet new console
You can connect to your App Configuration store using Microsoft Entra ID (recommended), or a connection string.
-
Add NuGet package references by running the following command:
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration dotnet add package Azure.Identitydotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
-
Run the following command to restore packages for your project:
dotnet restore -
Open the Program.cs file, and add the following namespaces:
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.AzureAppConfiguration; using Azure.Identity;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.AzureAppConfiguration;
-
Connect to your App Configuration store by calling the
AddAzureAppConfigurationmethod in theProgram.csfile.You use the
DefaultAzureCredentialto authenticate to your App Configuration store. Follow the instructions to assign your credential the App Configuration Data Reader role. Be sure to allow sufficient time for the permission to propagate before running your application.var builder = new ConfigurationBuilder(); builder.AddAzureAppConfiguration(options => { string endpoint = Environment.GetEnvironmentVariable("Endpoint"); options.Connect(new Uri(endpoint), new DefaultAzureCredential()); }); var config = builder.Build(); Console.WriteLine(config["TestApp:Settings:Message"] ?? "Hello world!");
var builder = new ConfigurationBuilder(); builder.AddAzureAppConfiguration(Environment.GetEnvironmentVariable("ConnectionString")); var config = builder.Build(); Console.WriteLine(config["TestApp:Settings:Message"] ?? "Hello world!");
-
Set an environment variable.
Set the environment variable named Endpoint to the endpoint of your App Configuration store found under the Overview of your store in the Azure portal.
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
setx Endpoint "<endpoint-of-your-app-configuration-store>"
If you use PowerShell, run the following command:
$Env:Endpoint = "<endpoint-of-your-app-configuration-store>"
If you use macOS or Linux, run the following command:
export Endpoint='<endpoint-of-your-app-configuration-store>'
Set the environment variable named ConnectionString to the read-only connection string of your App Configuration store found under Access keys of your store in the Azure portal.
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
setx ConnectionString "<connection-string-of-your-app-configuration-store>"
If you use PowerShell, run the following command:
$Env:ConnectionString = "<connection-string-of-your-app-configuration-store>"
If you use macOS or Linux, run the following command:
export ConnectionString='<connection-string-of-your-app-configuration-store>'
-
Run the following command to build the console app:
dotnet build -
After the build successfully completes, run the following command to run the app locally:
dotnet run:::image type="content" source="./media/quickstarts/dotnet-core-app-run.png" alt-text="Screenshot of a terminal window showing the app running locally.":::
[!INCLUDE azure-app-configuration-cleanup]
In this quickstart, you created a new App Configuration store and used it with a .NET console app via the App Configuration provider. To learn how to configure your .NET app to dynamically refresh configuration settings, continue to the next tutorial.
[!div class="nextstepaction"] Enable dynamic configuration