Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
At the root of an application is a metadata file that describes the global configuration of the host serving the different functions.
Accessing environment variables
You may need to store custom settings for your Azure function. One available option is to use environment variables. You can manage these settings in the Application settings section of your function app in the Azure portal.
[FunctionName("CustomSettings")]
public static Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "GET")]HttpRequestMessage req, TraceWriter log)
{
log.Info("101 Azure Function Demo - Accessing Environment variables");
var customSetting = Environment.GetEnvironmentVariable("CustomSetting", EnvironmentVariableTarget.Process);
return Task.FromResult(req.CreateResponse(HttpStatusCode.OK, new { setting= customSetting }));
}
Takeaways
- Environment variables are configured in the
Application Settingssection - Use the static
GetEnvironmentVariablemethod of theEnvironmenttype access them