1

I have a set of appsetting vaues as below. We are on Windows App service

"MainDomains": {
"Domains": [
  {
    "Id": "123456",        
    "Domain": "Technical",       
    "PolicyUrl": "https://www.mytechdomain.net",
    "LearningPoint": "https://www.mytechdomain.net",
    "Hostnames": [
      "https://localhost:4567",
      "http://localhost:34565",          
      "https://mytechdomain.latestlearn.com"
    ],
    "UsePreviewContent": true,
    "IsDefault": true,
    "OriginEmail": "info@techdomain.net",
    "mytechname": "Techdomain"
  }
]

}

How would i properly set these values in Azure App settings under configurations. I have already tried like property1:property2:0 --> xxxvalue. This does not seem to work however. What I am guessing is may be I have an array within another array. Where first array is the MainDomains and another array within the MainDomains array is the Domains.

Vaishnav
  • 611
  • 1
  • 9
  • 23
  • Please try to use `__` instead of `:` as the separator. Something like `MainDomains__Domains__Id`. – Gaurav Mantri Apr 01 '21 at 09:31
  • I missed to mention, we are on windows. So the __ works for linux i guess. However let me try – Vaishnav Apr 01 '21 at 10:39
  • 1
    `__` is platform safe. According to the documentation `:` should work on Windows. Can you edit your question and give an actual example of what you're trying to set that is not working? – Gaurav Mantri Apr 01 '21 at 10:47
  • Yes Gaurav, I edited the topic. Here I am trying to set in App setting like below for example. 1. MainDomains:Domains:Id --> 123456 2. MainDomains:Domains:Hostnames:0 --> https://localhost:4567 I found some information here : https://stackoverflow.com/questions/34063167/using-an-array-in-azure-web-app-settings – Vaishnav Apr 01 '21 at 12:39
  • I am not sure how to get this achieven in this case. An example for the above one is what I am looking for. I would need an example for setting (MainDomains:Domains:Id --> 123456) and (MainDomains:Domains:Hostnames:0 --> localhost:4567) – Vaishnav Apr 01 '21 at 14:03

1 Answers1

4

You should set the app setting name with the same delimited format in the appsettings.json. But just like Gaurav Mantri said, use double underscore __ rather than : on portal.

Refer to the description about Configuration keys and values:

In environment variables, a colon separator may not work on all platforms. A double underscore, __, is supported by all platforms and is automatically converted into a colon :.

You could also have a look at the official document about how to set App Settings.

Doris Lv
  • 3,083
  • 1
  • 5
  • 14
  • I read somewhere __ works for linux and : works for Windows app services. Let me try anyways. Thank you – Vaishnav Apr 01 '21 at 10:41