Read custom settings from local.settings.json in Azure functions

后端 未结 2 1228
借酒劲吻你
借酒劲吻你 2020-12-15 10:25

I am trying to retrieve a custom setting from local.settings.json file. Example I am trying to read tables list present in the below local.settings.json file



        
2条回答
  •  渐次进展
    2020-12-15 10:59

    When using Environment.GetEnvironmentVariable in an .Net Core Azure Function I had to add the EnvironmentVariableTarget.Process parameter to retrieve the connection string

     string connectionString= Environment.GetEnvironmentVariable("DBConnectionString", 
     EnvironmentVariableTarget.Process);
    

    My local.settings.json looked something like this:

     {"IsEncrypted": false,
     "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "DBConnectionString": ""
     }
    }
    

提交回复
热议问题