Quickstart: Create an ASP.NET Core app with Azure App Configuration

Azure App Configuration is a managed configuration service in Azure. You can use it to easily store and manage all your application settings in one place that's separated from your code. This quickstart shows you how to incorporate the service into an ASP.NET Core web app.

ASP.NET Core builds a single key-value-based configuration object by using settings from one or more data sources that are specified by an application. These data sources are known as configuration providers. Because App Configuration's .NET Core client is implemented as such a provider, the service appears like another data source.

You can use any code editor to do the steps in this quickstart. Visual Studio Code is an excellent option available on the Windows, macOS, and Linux platforms.

Quickstart app launch local


To do this quickstart, install the .NET Core SDK.

If you don't have an Azure subscription, create a free account before you begin.

Create an app configuration store

  1. To create a new app configuration store, sign in to the Azure portal. In the upper-left corner of the page, select + Create a resource. In the Search the Marketplace box, enter App Configuration and press Enter.

    Search for App Configuration

  2. Select App Configuration from the search results, and then select Create.

  3. On the App Configuration > Create page, enter the following settings.

    Setting Suggested value Description
    Resource name Globally unique name Enter a unique resource name to use for the app configuration store resource. The name must be a string between 1 and 63 characters and contain only numbers, letters, and the - character. The name can't start or end with the - character, and consecutive - characters aren't valid.
    Subscription Your subscription Select the Azure subscription that you want to use to test App Configuration. If your account has only one subscription, it's automatically selected and the Subscription drop-down isn't displayed.
    Resource group AppConfigTestResources Select or create a resource group for your app configuration store resource. This group is useful for organizing multiple resources that you might want to delete at the same time by deleting the resource group. For more information, see Use resource groups to manage your Azure resources.
    Location Central US Use Location to specify the geographic location in which your app configuration store is hosted. For the best performance, create the resource in the same region as other components of your application.

    Create an app configuration store resource

  4. Select Create. The deployment might take a few minutes to finish.

  5. After the deployment is finished, select Settings > Access Keys. Make a note of either the primary read-only or primary read-write key connection string. You use this connection string later to configure your application to communicate with the app configuration store you created.

  1. Select Configuration Explorer > + Create to add the following key-value pairs:

    Key Value
    TestApp:Settings:BackgroundColor White
    TestApp:Settings:FontSize 24
    TestApp:Settings:FontColor Black
    TestApp:Settings:Message Data from Azure App Configuration

    Leave Label and Content Type empty for now.

Create an ASP.NET Core web app

You use the .NET Core command-line interface (CLI) to create a new ASP.NET Core MVC web app project. The advantage of using the .NET Core CLI over Visual Studio is that it's available across the Windows, macOS, and Linux platforms.

  1. Create a new folder for your project. For this quickstart, name it TestAppConfig.

  2. In the new folder, run the following command to create a new ASP.NET Core MVC web app project:

     dotnet new mvc

Add Secret Manager

Add the Secret Manager tool to your project. The Secret Manager tool stores sensitive data for development work outside of your project tree. This approach helps prevent the accidental sharing of app secrets within source code.

  • Open the .csproj file. Add a UserSecretsId element as shown here, and replace its value with your own, which typically is a GUID. Save the file.

    <Project Sdk="Microsoft.NET.Sdk.Web">
        <PackageReference Include="Microsoft.AspNetCore.App" />
        <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />

Connect to an app configuration store

  1. Add a reference to the Microsoft.Extensions.Configuration.AzureAppConfiguration NuGet package by running the following command:

     dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration --version 1.0.0-preview-008520001
  2. Run the following command to restore packages for your project:

     dotnet restore
  3. Add a secret named ConnectionStrings:AppConfig to Secret Manager.

    This secret contains the connection string to access your app configuration store. Replace the value in the following command with the connection string for your app configuration store.

    This command must be executed in the same directory as the .csproj file.

     dotnet user-secrets set ConnectionStrings:AppConfig <your_connection_string>

    Secret Manager is used only to test the web app locally. When the app is deployed to Azure App Service, for example, you use an application setting Connection Strings in App Service instead of with Secret Manager to store the connection string.

    This secret is accessed with the configuration API. A colon (:) works in the configuration name with the configuration API on all supported platforms. See Configuration by environment.

  4. Open Program.cs, and add a reference to the .NET Core App Configuration provider.

    using Microsoft.Extensions.Configuration.AzureAppConfiguration;
  5. Update the CreateWebHostBuilder method to use App Configuration by calling the config.AddAzureAppConfiguration() method.

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            .ConfigureAppConfiguration((hostingContext, config) =>
                var settings = config.Build();
  6. Open Index.cshtml in the Views > Home directory, and replace its content with the following code:

    @using Microsoft.Extensions.Configuration
    @inject IConfiguration Configuration
    <!DOCTYPE html>
    <html lang="en">
        body {
            background-color: @Configuration["TestApp:Settings:BackgroundColor"]
        h1 {
            color: @Configuration["TestApp:Settings:FontColor"];
            font-size: @Configuration["TestApp:Settings:FontSize"];
        <title>Index View</title>
  7. Open _Layout.cshtml in the Views > Shared directory, and replace its content with the following code:

    <!DOCTYPE html>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>@ViewData["Title"] - hello_world</title>
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/css/site.css" />
        <div class="container body-content">
        <script src="~/lib/jquery/dist/jquery.js"></script>
        <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
        <script src="~/js/site.js" asp-append-version="true"></script>
        @RenderSection("Scripts", required: false)

Build and run the app locally

  1. To build the app by using the .NET Core CLI, run the following command in the command shell:

     dotnet build
  2. After the build successfully completes, run the following command to run the web app locally:

     dotnet run
  3. Open a browser window, and go to http://localhost:5000, which is the default URL for the web app hosted locally.

Clean up resources

If you plan to continue to the next tutorial, keep the resources you created in this quickstart. You can reuse them in the next tutorial.

If you're finished with the quickstart sample application, delete the Azure resources you created in this quickstart to avoid charges.


Deleting a resource group is irreversible. The resource group and all the resources in it are permanently deleted. Make sure that you don't accidentally delete the wrong resource group or resources. Maybe you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep. You can delete each resource individually from their respective blades instead of deleting the resource group.

Sign in to the Azure portal, and select Resource groups.

In the Filter by name box, enter the name of your resource group. The instructions for this quickstart used a resource group named AppConfigTestResources. On your resource group in the result list, select ... and then select Delete resource group.

You're asked to confirm the deletion of the resource group. Enter the name of your resource group to confirm, and select Delete.

After a few moments, the resource group and all of its contained resources are deleted.

Next steps

In this quickstart, you created a new app configuration store and used it with an ASP.NET Core web app via the App Configuration provider. To learn more about how to use App Configuration, continue to the next tutorial that demonstrates authentication.