1
votes

I have this custom section in my web.config

  <defaultUserAccounts>
    <userAccount email="[email protected]" password="xxx" />
    <userAccount email="[email protected]" password="yyy" />
  </defaultUserAccounts>

I host my web app on Azure and I want to be able to add new userAccount in the Azure App Settings.

I tried with:

defaultUserAccounts.userAccount.email / [email protected]
defaultUserAccounts.userAccount.password / zzz

OR

defaultUserAccounts:userAccount:email / [email protected]
defaultUserAccounts:userAccount:password / zzz

But it doesnt work. I can read the web.config custom section in localhost, but not when the app is hosted.

Could you help me?

2
A couple thoughts, but not towards an answer. Are you planning on ever moving to Core? Have you considered doing this a much better way? Like a database? As this approach isn't really the right way... docs.microsoft.com/en-us/azure/azure-app-configuration/overviewAustin T French
We dont want to move to core. We doesnt want to use a database. This way is the way we want. We need to have the list of user available in the web.config. Do you have a solution to help me?Cedric Arnould

2 Answers

0
votes

You can only write the app settings using the management API of Azure. See here for an example using the Fluent SDK. Otherwise the settings are read-only from within the app. https://stackoverflow.com/a/50116234

-1
votes

If you don't want to configure app setting in the Configuration you could follow this tutorial:Configure app settings configure it under tag <appSettings> in Web.config, but the values in App Service override the ones in Web.config.

The below is my test:

enter image description here

And use System.Configuration.ConfigurationManager.AppSettings["testkey"] to get the value, the below page is get the value with host in Azure.

enter image description here

Hope this could help you.