By using this site, you acknowledge that you have read and understand our Cookie and Privacy policy. Your use of Kontext website is subject to this policy. Accept

Retrieve Azure AppSettings and Connection String Settings in ASP.NET Core Apps

3620 views last modified about 2 years ago Raymond

.net core Azure


In ASP.NET Core, we can easily use user secrets to manage our password or credentials. This post will summarize the approaches we can use after the websites are deployed into Azure.

Azure AppSettings & Connection Strings

In Azure management portal, navigate your App Services. And then in SETTINGS section, click on Application settings.
In App settings section, you can setup up any key way pairs:


In Connection strings section, you can setup all the connection strings:


You can also choose the connection type:


These settings are injected at run time.

Access App settings and Connection strings in your application


All the configurations will be injected and can accessed through IConfiguration. You can directly add IConfiguration into your controller or services. You can also inject this directly into your views.

Sample code in Controller

using AzureWebAppTest.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Diagnostics;

namespace AzureWebAppTest.Controllers
     public class HomeController : Controller
         private readonly IConfiguration configuration;

        public HomeController(IConfiguration configuration)
             this.configuration = configuration;

        public IActionResult Index()
             var appSettingTest1 = configuration["appSettingTest1"];
             var connectionStringTest1 = configuration.GetConnectionString("connectionStringTest1");

            return Json(new { appSettingTest1, connectionStringTest1 });


Sample configuration in Azure


Result in Azure website


Sample code in View

     ViewData["Title"] = "Home Page";
     Layout = null;
@using Microsoft.Extensions.Configuration
@inject Microsoft.Extensions.Configuration.IConfiguration configuration

<p>appSettingTest1: @configuration["appSettingTest1"]</p>
<p>connectionStringTest1: @configuration.GetConnectionString("connectionStringTest1")</p>

Result in Azure website


Access through environment variables

All these settings are injected into environment variables and you can access them in other programming languages by adding some prefix:

For App settings, ‘APPSETTING_’ is added to each settings. and for connection strings, there are different prefixes added for different connection types:


For more details, please refer to:

Update these settings in CI/CD environment

Instead of manually updating these settings through Azure management portal, you can also Azure Resource Manager PowerShell module to implement it in a continuous integration and deployment environment. Refer the following post for examples:


If you are using Visual Studio online build and release functions, you can also just install some extensions available in Visual Studio marketplace. For instance, the following link provide you the functionality to configure App settings:

Related pages

ASP.NET Core 2.2 Implementation for Consumer Data Standards

84 views   0 comments last modified about 16 days ago

I’ve just started an core 2.2 based implementation for Australia Consumer Data Standards (published by Data 61). Opening Banking initiative will follow these standards. The purpose is to help you to get familiar with these standards, especially the APIs that need to be implemented. ...

View detail

ASP.NET Core 2.1 Error - 'Cyrillic' is not a supported encoding name

691 views   0 comments last modified about 9 months ago

After upgrading to ASP.NET Core 2.1 (.NET Core SDK 2.1.301), you may encounter the following error about encoding: System.ArgumentException &nbsp;&nbsp; HResult=0x80070057 &nbsp;&nbsp; Message='Cyrillic' is not a supported encoding name. For information on defining a custo...

View detail

Graphics Programming and Image Processing in .NET Core 2.x

531 views   0 comments last modified about 9 months ago

In .NET Core 2.x, Windows Forms or WPF are not implemented since they are based on GDI+ and DirectX respectively in Windows. In .NET Core 3.0, there is plan to add Desktop Packs which includes UWP. WPF and Windows Forms. However, they will still be Windows-only. In .NET Core applications, you may...

View detail

ASP.NET Core 2 with Bootstrap 4 Bundler Minifier Issue: Expected semicolon or closing curly-brace found '-'

1314 views   1 comments last modified about 2 years ago

Background When upgrading Bootstrap to v4.0.0 release, the bundler and minifier doesn’t work properly due to CSS variable is commonly used: :root{--blue:#007bff; About 26 errors will show up in the Error List with the following message: ...

View detail

Issue - Unable to get property 'apply' of undefined or null reference occurred in Angular 4.*, VS2017 15.3, ASP.NET Core 2.0

7702 views   10 comments last modified about 2 years ago

Issue Context After installed Visual Studio 2017 15.3 preview and .net core 2.0 preview SDK, I upgraded one of my existing core project to 2.0. The project was created using ‘dotnet new angular’ SPA template.&nbsp; I also upgraded all the client app packages to the latest. For exa...

View detail

Retrieve Http client request metadata like IP address and languages in core

2383 views   0 comments last modified about 2 years ago

IP Address In ASP.NET Core, Request.UserHostAddress has been removed though that attribute exists in the traditional ASP.NET applications. We can use HttpContext.Connection to retrieve the remove client IP address: var ipAddress = HttpContext.Connecti...

View detail

Add comment

Comments (0)

No comments yet.


  • enquiry[at]