How to read application setting of azure app service in asp net core 6 0 web api


ASP.NET is a popular used for building web applications. In this article, we will discuss how to read application settings of an Azure App Service in ASP.NET Core 6.0 Web API.

Step 1: Accessing Application Settings

To the application settings of an Azure App Service in ASP.NET Core 6.0 Web API, you can use the Configuration object provided by the framework. This object allows you to read values from configuration sources, the application settings.

First, make sure you have the necessary NuGet packages installed. Open your project in Visual and navigate to the Manage NuGet Packages option. Search for and install the following packages:


Once the packages are installed, you need to the Configuration object to read the application settings. Open the Startup.cs file and add the following code to the ConfigureServices method:

This code configures the Configuration object to use Azure App Configuration as a configuration . It also registers the IConfiguration interface with the dependency injection container.

Step 2: Reading Application Settings

Now that the Configuration object is configured, you can easily read the application settings. In your controller or service class, the IConfiguration interface as a dependency:

private readonly IConfiguration _configuration;

public MyController(IConfiguration configuration)
    _configuration = configuration;

Once injected, you can access the application settings using the _configuration object. For example, to read a setting MySetting, use the following code:

string mySetting = _configuration["MySetting"];

You can also specify a default value in case the setting is not found:


Reading application settings of an Azure App Service in ASP.NET Core 6.0 Web API is straightforward using the Configuration object. By following the steps outlined in this article, you can easily access and utilize the application settings in your web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents