Using an array in Azure web app settings

后端 未结 2 1269
慢半拍i
慢半拍i 2020-12-14 00:15

In my ASP.NET 5 (RC1) code I have an appsetting.json that looks something like this:

{
    \"SomeSettings\": {
        \"PropA\": \"ValueA\",
        \"PropB         


        
相关标签:
2条回答
  • 2020-12-14 00:39

    Adding the settings under "App settings" like this will do the trick... Notice the ":0" and ":1" below

    Format: Key -> Value

    SomeSettings:PropA -> AzureValueA
    SomeSettings:PropB:0 -> AzureValueB1
    SomeSettings:PropB:1 -> AzureValueB2
    

    If you aren't running on Windows, replace the colon : with double underscore __ to get your app to see the settings. So instead of e.g. SomeSettings:PropA, you'd use SomeSettings__PropA.

    0 讨论(0)
  • 2020-12-14 00:59

    Simple approach is store the JSON as string in AppSetting, and de-serialize by yourself

    var serializer = new JavaScriptSerializer();
    var settings = serializer.Deserialize<SomeSettings>(configuration.GetSection("SomeSettings"));
    

    or you will have to create your own customer configuration i believe. https://msdn.microsoft.com/en-us/library/2tw134k3.aspx

    0 讨论(0)
提交回复
热议问题