Muokkaa

Jaa


Adding Azure App Configuration by using Visual Studio Connected Services

In this tutorial, you will learn how to easily add everything you need to start using Azure App Configuration to manage your configuration and feature flags for web projects in Visual Studio. By using the Connected Services feature in Visual Studio, you can have Visual Studio automatically add all the code, NuGet packages, and configuration settings you need to connect to your App Configuration resource in Azure. To use this feature, you must be using Visual Studio 2019 version 16.9 or later.

You can use the App Configuration Connected Services feature in the following project types:

  • ASP.NET Core
  • .NET Core Console
  • .NET Framework projects.

Prerequisites

Connect to Azure App Configuration using Connected Services

  1. Open your project in Visual Studio.

  2. In Solution Explorer, right-click the Connected Services node, and, from the context menu, select Add Connected Service.

    Screenshot showing "Add Azure connected service" screen.

  3. In the Connected Services tab, select the + icon for Service Dependencies.

    Screenshot showing "Add Service Dependency" screen.

  4. In the Add Dependency page, select Azure App Configuration.

    Screenshot showing "Add App Configuration" screen.

    If you aren't signed in already, sign in to your Azure account. If you don't have an Azure account, you can sign up for a free trial.

  5. In the Configure Azure App Configuration screen, select your subscription and an existing configuration store. Then select Next.

    If you need to create an App Configuration store, go to the next step. Otherwise, skip to step 6.

    Screenshot showing "Add existing configuration account to project" screen.

  6. To create an app configuration store:

    1. Select the + icon to the right of the App Configuration stores header.

    2. Fill out the Azure App Configuration: Create new dialog, and select Create. Note that the Resource Name field needs to be unique.

      Screenshot showing New Azure app config store.

    3. When the Azure App Configuration dialog is displayed, the new configuration store appears in the list. Select this new store, then select Next.

  7. Enter a connection string name, and choose whether you want the connection string stored in a local secrets file, or in Azure Key Vault.

    Screenshot showing "Specify connection string" screen.

  8. The Summary of changes screen shows all the modifications that will be made to your project if you complete the process. If the changes look OK, choose Finish.

    Screenshot showing summary of changes.

  9. Once the Dependency configuration process has finished, Azure App Configuration now appears under the Service Dependencies node of your project.

  1. Open your project in Visual Studio.

  2. In Solution Explorer, right-click the Connected Services node, and, from the context menu, select Add to open the menu of available services.

    Screenshot showing Connected Services context menu options.

  3. Choose Azure App Configuration. The Connect to dependency page appears.

    Screenshot showing Connect to dependency for Azure App Configuration.

    If you aren't signed in already, sign in to your Azure account. If you don't have an Azure account, you can sign up for a free trial.

  4. In the Configure Azure App Configuration screen, select your subscription and an existing configuration store. Then select Next.

    If you need to create an App Configuration store, go to the next step. Otherwise, skip to step 6.

    Screenshot showing 'Add existing configuration account to project".

  5. To create an app configuration store:

    1. Select the + icon to the right of the App Configuration stores header.

    2. Fill out the Azure App Configuration: Create new dialog, and select Create. Note that the Resource Name field needs to be unique.

      Screenshot showing new Azure app config store.

    3. When the Azure App Configuration dialog is displayed, the new configuration store appears in the list. Select this new store, then select Next.

  6. Enter a connection string name, and choose whether you want the connection string stored in a local secrets file, or in Azure Key Vault.

    Screenshot showing "Specify connection string" screen.

  7. The Summary of changes screen shows all the modifications that will be made to your project if you complete the process. If the changes look OK, choose Finish.

    Screenshot showing summary of changes.

    Once the Dependency configuration process has finished, Azure App Configuration now appears under the Service Dependencies node of your project.

  8. In Solution Explorer, double-click on the Connected Services node to open the Connected Services tab. The connection appears under the Service Dependencies section:

    Screenshot of Service Dependencies section showing Azure App Configuration connection.

    There's also a Secrets.json entry that supports secure storage of the connection string locally. Read about how this works at Screenshot showing safe storage of app secrets in development in ASP.NET Core.

    If you click on the three dots next to the dependencies you added, you can see various options such as Connect to reopen the wizard and change the connection, and for Secrets.json, the option to manage secrets. You can also click the three dots at the top right of the window to see options to start local dependencies, change settings, and more.