question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Application settings occasionally not accessible

See original GitHub issue

Hello,

every once in a while we are experiencing a problem getting the application settings. Everything runs nice, but sometimes returned value is null.

First we tried getting the value using the configuration manager:

string apiKey = System.Configuration.ConfigurationManager.AppSettings["AzureSearchServiceApiKey"];

then we thought configuration manager might be the problem and changed to cloud configuration manager:

string apiKey = CloudConfigurationManager.GetSetting("AzureSearchServiceApiKey");

and still experiencing the same issue.

For example today from midnight till 9 AM value was returned successfully 46 times and 4 times null was returned.

Our problem seems similar to https://github.com/Azure/azure-webjobs-sdk-script/issues/1481 but npiasecki fixed it by fixing the memory leak. I don’t think we have a memory leak, but who knows 😃

Any idea how to fix or investigate this issue would be appreciated.

Thanks.

Tin

P.S. if anyone wants to take a look function app is the one with statisticprocess in name on the same account with sa-v4-reference and last errors occurred (UTC): June 5th 22:03:59.322 June 6th 00:33:46.085 June 6th 05:47:23.887 June 6th 05:47:24.157

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:31 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
pragnagopacommented, Apr 13, 2018

We have another CRI. Here is the Scenario (from the logs) Function had service bus trigger and when under load i.e multiple executions with in a short span of time sometimes, reading AppSettings returns null.

Moving it to triaged as we have multiple customer reports. We need to spend sometime to create a repro.

1reaction
npiaseckicommented, Jun 6, 2017

Hi @thusnjak

It turns out it wasn’t the memory leak, but I forgot to reopen the issue. I noticed the same thing with AppSettings in Azure Functions, all I could figure out is that the host starts running your function before the configuration wizardry gets merged somehow, or runs your function after the environment has been torn down. I worked around it by using environment variables instead.

I ended up using a helper class I wrote to work around the issue. Basically I look in AppSettings, and if it’s not there I try the environment variable instead. The environment variable always seems to be there.

public static class FunctionConfiguration
{
    public static string GetAppSetting(string name)
    {
        if (string.IsNullOrWhiteSpace(name))
        {
            throw new ArgumentException($"The parameter '{nameof(name)}' cannot be null or blank.");
        }

        var value = ConfigurationManager.AppSettings[name];

        if (string.IsNullOrWhiteSpace(value))
        {
            value = Environment.GetEnvironmentVariable($"APPSETTING_{name}");
        }

        return value;
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Fixes to Try if You Can't Open Windows Settings
Fortunately, there are some quick fixes you can use to regain access to the Settings app. 1. Try Alternate Ways to Open Settings....
Read more >
What to Do When Windows 10/11 Settings App Is Not ...
To let the app open and work normally, you can try the Windows Update Troubleshooter. Open Control Panel, view all items by large...
Read more >
Settings App Not Working in Windows? Here Are the Fixes
A lot of people can't access the Settings app in Windows 10. This article shows some fixes for the Settings app not working...
Read more >
Barely any apps opening, including settings
1. Open command prompt with administrator access · 2. Type each command below and wait until scan is completed. SFC /scannow. DISM /Online...
Read more >
10 Best Ways to Fix Settings App Not Opening or Working ...
Type in Settings and select the App settings option. Modify Settings App on Windows. Step 2: Scroll down to the Reset section and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found