Invalid json in azure web app configuration setting

58 Views Asked by At

I have asp.net core application that has complex configuration setting, i am trying to create that setting on azure web app but it says invalid json. I know azure web app configuration support key pair value but i am not sure how to write this settings.

Please check below setting

"TenantSettings": {
        "Identity": {
          "ConnectionString": "Data Source=localhost;Initial Catalog=Identitydb;Integrated Security=True"
        },
        "Tenants": [
          {
            "TenantId": "demo1",
            "ConnectionString": "Data Source=localhost;Initial Catalog=shareddb;Integrated Security=True"
          },
          {
            "TenantId": "demo2",
            "ConnectionString": "Data Source=localhost;Initial Catalog=shareddb1;Integrated Security=True"
          }
        ]
      }

enter image description here

My class look like this to load setting(class Name:TenantSettings), this works fine on local.

public class TenantSettings
{
    public Configuration Identity { get; set; }
    
    public List<Tenant> Tenants { get; set; }
}
public class Tenant
{
    public string TenantId { get; set; }
    public string ConnectionString { get; set; }
}
public class Configuration
{
    public string ConnectionString { get; set; }
}
1

There are 1 best solutions below

0
Bharat On

I found solution for this to add list of configuration we have to use :0 and :1 so on ex: TenantSettings:Tenants:0:ConnectionString, check below setting deployed on azure web app configuration setting.

  {
    "name": "TenantSettings:Identity:ConnectionString",
    "value": "database server path",
    "slotSetting": false
  },
  {
    "name": "TenantSettings:Tenants:0:ConnectionString",
    "value": "database server path",
    "slotSetting": false
  },
  {
    "name": "TenantSettings:Tenants:0:TenantId",
    "value": "tenant1",
    "slotSetting": false
  }

Hope this will help someone.