0

How can I use Azure Function app settings to fetch a non-string value? I use :

var resourceGroupName = System.Configuration.ConfigurationManager.AppSettings["resourceGroupName"];
var dataFactoryName = System.Configuration.ConfigurationManager.AppSettings["dataFactoryName"];

But I can't do this for int/double variables. What is the way around?

das
  • 201
  • 1
  • 3
  • 10

1 Answers1

3

You could parse the string value into either a double or an int:

double val;
if (double.TryParse(System.Configuration.ConfigurationManager.AppSettings["setting"], out val))
{
    //use val
}

double.TryParse and int.TryParse will return false if the configuration value cannot be converted to a double or an int respectively.

mm8
  • 163,881
  • 10
  • 57
  • 88
  • For Azure Functions, you could use double val; double.TryParse(Environment.GetEnvironmentVariable("YourAppConfigKey", EnvironmentVariableTarget.Process), out val); – Ashokan Sivapragasam Jul 16 '18 at 12:54