Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure function App settings is null after deployment

Here is my scenario:

  • I have a c# blob trigger azure function (alwaysON set to true).
  • I am setting the appsettings of the function app using New-AzureRmResource ps cmdlet.
  • I am deploying the azure function by calling PUT Rest call on "https://$functionAppName.scm.azurewebsites.net/api/zip/site/wwwroot" to upload a zip file (which contains run.csx, function.json and bin/*.dll files).
  • I use CloudConfigurationManager.GetSetting(settingKey) to get the appsettings in the *.dll files. I have a IsNullOrWhiteSpace check on these appsettings to throw a ConfigurationErrorsException.

Problem: After deploying, always the first trigger to the azure function fails. It fails with the ConfigurationErrorsException exception which i am throwing if a appsetting is IsNullOrWhiteSpace. After about a minute after the first failed trigger, all the subsequent triggers start to be successful.

Is it that it takes time for appsettings to get loaded ? Have any of you faced such issue before ? What is the workaround/solution for this ?

like image 431
Tany Avatar asked Jun 27 '17 19:06

Tany


1 Answers

You should not be using CloudConfigurationManager in Azure App Service, as that component is designed for Cloud Services (a different Azure offering). You should avoid referencing that assembly entirely.

Instead, simply use ConfigurationManager.AppSettings["YourSetting"] to access your app settings.

like image 52
David Ebbo Avatar answered Sep 22 '22 10:09

David Ebbo