Search code examples
azureasp.net-coreazure-appserviceasp.net-core-8

How to override appsettings.json values in Azure app service for an application deployed in Virtual path


I have a .NET 8 application deployed to the Azure app service as a Virtual application along with another application in the root folder.

I was able to overwrite the application settings for the root application but not to the virtual application.

I was not able to find any documentation related to this.


Solution

  • I am able to override the application settings of both Root and Virtual App.

    Virtual Path:

    enter image description here

    • I haven't done any changes in the code.

    Environment Variables:

    enter image description here

    • Try to retrieve the settings in .cshtml file.

    Root Application:

    @inject IConfiguration myconfig;
    <h3>@myconfig["ParentSetting"]</h3>
    

    enter image description here

    Child App:

    @inject IConfiguration myconfig;
     <h3>@myconfig["ChildSetting"]</h3>
     <h3>@myconfig["ParentSetting"]</h3>
    

    enter image description here

    I was not able to find any documentation related to this.

    There is no such documentation related to override Virtual App Settings.

    • You can refer this SOThread on how to deploy and work with Virtual Apps.

    • Make sure you haven't set environment as Development in Web.config(if you have any) or in deployed appsettings.json file.

    • Also refer this to override appsettings.json for the Azure App Service.