I have an azure function that needs to make an http call, and it retrieves the uri from a configuration variable that I've ensured exists in the function configuration section, in the Azure portal.
When I run my function in Azure, I've noticed that roughly 80% of the time, my function fails to read the value from the function configuration, i.e. the Environment.GetEnvironmentVariable("endpoint_value_from_configuration") method call returns null.
However if I repeatedly test this function (without changing any code or configuration whatsoever) it does sometimes succeed to read the variable. What's going on here? How can I change this function so that this problem does not occur?
[FunctionName("MessageHandler")]
public async Task Run([ServiceBusTrigger("%Topic%", "subname", Connection = "ServiceBusConnection")] string mySbMsg,
ILogger log)
{
var obj = JsonConvert.DeserializeObject<BusinessObject>(mySbMsg);
var endpoint = Environment.GetEnvironmentVariable("endpoint_value_from_configuration");