Application configuration
Azure Azure App Services PaaS

How to use Azure App Service Settings in .NET Core Applications

Welcome to today’s post.

In today’s blog I will show how you can use Azure to investigate application settings for your web application that has been deployed into Azure as an App Service.

To be able to complete this exercise you should already have a web application deployed into Azure under an Application Service Plan.

When you access your Azure web site, you would normally use a URL of the form:

https://[web application name].azurewebsites.net/

To be able to access your application settings for your deployed Azure web site, you will need to use a URL of the form:

https://[web application name].scm.azurewebsites.net/

Note that the above URL is accessible after you have logged into the Azure portal.

Once you browse to the above URL, you will see a utility screen like the one shown:

This is called the Kudu utility console. It allows you to investigate deployment settings for your Azure application.

From here you can access the debug console, which will allow you to view configuration settings:

Once selected, you will be in the Kudo debug console as shown:

The application settings for your application are stored in the folder:

D:\home\site\wwwroot

Once you are in the above folder you can see a number of binaries and also the appsettings.* configuration files as shown:

Each file can be downloaded for viewing in the browser. For example, when you view the production settings configuration file, the URL will be:

https://[web application name].
scm.azurewebsites.net/api/vfs/
site/wwwroot/appsettings.production.json

The content of the above production configuration file in Azure will be almost identical to that deployed from your visual studio development environment:

{
  "ConnectionStrings": {
    "AppDbContext": "Server=tcp:????.database.windows.net,1433;Initial Catalog=BookLoanDb;Persist Security Info=False;User ID=????;Password=????;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AppSettings": {
    "AppName": "BookLoan",
    "AppVersion": "1.0.0",
    "AdminEmail": "???",
    "AdminPwd": "???"
  }
}

When you publish your .NET Core web application to Azure using the publish wizard (which I will show in a separate post), you specify the database connection string of your Azure SQL database (or other database) in the wizard and the setting is applied into the appsettings.production.json file in Azure.

If you are using a local SQL express database on your local development environment, then the development configuration settings will also be deployed into the appsettings.json file:

{
  "ConnectionStrings": {
    "AppDbContext": "Server=(localdb)\\mssqllocaldb;Database=aspnet-BookLoan-8939A8CF-89E2-42F3-9A64-E13624F164AB; Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AppSettings": {
    "AppName": "BookLoan",
    "AppVersion": "1.0.0",
    "AdminEmail": "???",
    "AdminPwd": "???"
  }
}

From here you can verify your application settings and which deployed settings you wish to override from within your Azure Application Service settings.

I hope this post has been informative.

In a future post I will discuss how to override your application settings in Azure.

Social media & sharing icons powered by UltimatelySocial