Question

iamthegalthatyouknow on Wed, 09 Aug 2017 22:40:29


How do I read the application settings on my azure function?

I've tried adding ConfigurationManager.AppSettings but the value it pick up is the one from local.settings.json. Is ConfigurationManager will automatically read the application settings in azure when the function deploy to the cloud?


Sponsored



Replies

Alexey Rodionov (msft) on Wed, 09 Aug 2017 23:51:46


public static void Run(TimerInfo myTimer, TraceWriter log)
{
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
    log.Info(GetEnvironmentVariable("AzureWebJobsStorage"));
    log.Info(GetEnvironmentVariable("WEBSITE_SITE_NAME"));
}

public static string GetEnvironmentVariable(string name)
{
    return name + ": " + 
        System.Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process);
}

Details: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#environment-variables