How to use nested values from secrets.json Azure's App Service Configuration

664 Views Asked by At

In my app's secrets.json file, I have the following section.

"Serilog": {
    "WriteTo": [
      {
        "Name": "AzureTableStorage", 
        "Args": {
          "storageTableName": "Logging", 
          "connectionString": "DefaultEndpointsProtocol=xxxxxxxxxxx"
        }
      }
    ]
  }

I am attempting to deploy to Azure and have added the keys to my app service's configuration like this.

  Serilog__WriteTo__Name
  Serilog__WriteTo__Args__storageTableName
  Serilog__WriteTo__Args__connectionString

However, the application will not start (just shows an errror: "If you are the application administrator, you can access the diagnostic resources.") if I use either of the two longer keys. I have another setting named CosmosConnectionSettings__ContainerName which works fine, so it seems to be a problem with the nesting rather than they key lengths.

The app service is configured to use Linux.

Is there a better way to approach this, and is this limitation documented anywhere?

1

There are 1 best solutions below

0
On

I think it's not the nesting's fault.

I have test it on my side, here is my secrets.json file:

{
  "Serilog": {
    "WriteTo": {
      "Name": "AzureTableStorage",
      "Args": {
        "storageBlobName": "1.jpg",
        "connectionString": "DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;"
      }
    }
   
  }
}

And I write the value to the endpoint page like this: enter image description here Here is the Appsettings in my configuration on portal: enter image description here

The Appsettings I set works well on azure web app. enter image description here

My suggestion is:

  1. Check how you use the key AzureTableStorage and connectionString in your scripts.
  2. Test your project on IIS. Actually if it works well on IIS, it should work well on Azure.