Reputation: 31
We are trying to create azure function app using .NET pre-compiled libraries (without .NET core) and all application configurations we have added in appsettings.json file that is working fine locally. We are able to get the key's value using below code
ConfigurationManager.AppSettings["keyName"]
But, after deployment using VS2017 we are not able to get the key's value from appsetting.json file unless we have to create configurations in Azure Application-setting blade manually.
We also tried to add configuration in Web.config but it didn't work and Azure-Functions: Can you use web.config restrictions (e.g. IP restriction or basic Auth) suggested that web.config is not supported to Azure Function app.
What is the best way to store application settings for Azure function app except Azure Application-setting blade?.
Upvotes: 2
Views: 2732
Reputation: 24539
In the VS 2017 Azure function project, using the file local.settings.json to stores app settings, connection strings, and settings for Azure Functions Core Tools. I also can repro the issue (no appsetting item in theApplication-setting blade) you mentioned when using that vs2017 to publish the project.
What is the best way to store application settings for Azure function app except Azure Application-setting blade?
We could use the Azure Functions Core Tools to do that easily. It works correctly on my side.
func azure functionapp publish azurefunctionname --publish-local-settings
The following is the detail steps:
1.create an Azure function project with VS2017 preview 2.0 and following content in the local.setting.json file
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "xxxxxxxx",
"AzureWebJobsDashboard": "xxxxxxx",
"Message": "Hello world!"
}
}
2.install the Azure Functions Core Tools
3.switch to Azure function project directory
4.before run the cmd required azure login
5.publish the local settings to Azure appsettings
5.Check from Azure portal.
More detail about developing and test Azure function please refer to the official tutorials.
Upvotes: 2