microsoft/ailab · critical · SettingsPropertyNotFoundException

[ ] can't be empty.

Error message

[{settingKey}] can't be empty.

What it means

CheckSetting reads a key from ConfigurationManager.AppSettings (app.config / web.config appSettings) and throws SettingsPropertyNotFoundException if the value is null or empty. JFKFiles initialization requires every listed setting to be present, so any missing configuration entry aborts the program at startup via CheckSettings.

Solutions

  1. Open the app/web.config deployed next to JfkWebApiSkills.JfkInitializer.exe and add every required appSettings key with a non-empty value
  2. The message names the exact missing key ([settingKey]); set that specific key first
  3. Verify the config file is copied to the output directory (Copy to Output Directory = Copy always) and transforms applied on publish
  4. Align config with the sample app.config shipped in the repo version you are building

Example fix

// before (app.config)
<appSettings>
  <add key="AzureSearchApiKey" value="" />
</appSettings>
// after
<appSettings>
  <add key="AzureSearchApiKey" value="YOUR_KEY" />
</appSettings>
Defensive patterns

Strategy: validation

Validate before calling

var keys = new[] { "SettingA", "SettingB" }; // required keys
foreach (var k in keys)
{
    if (string.IsNullOrEmpty(ConfigurationManager.AppSettings[k]))
        throw new ConfigurationErrorsException($"[{k}] must be set in appSettings before starting");
}

Try / catch

try
{
    JfkInitializer.CheckSettings();
}
catch (SettingsPropertyNotFoundException ex)
{
    Console.Error.WriteLine($"Missing configuration: {ex.Message}. Update app.config appSettings.");
    Environment.Exit(2);
}

Prevention

When it happens

Trigger: Running JfkInitializer with an app.config that lacks any required appSettings key, or a key present with an empty value (e.g. <add key="X" value=""/>).

Common situations: Deploying the binary without its config file; copying app.config as App.config with wrong casing so it isn't picked up; new required settings added in a newer version while the old config is reused; Azure deployment missing the config transform.

Related errors


AI-assisted analysis of microsoft/ailab@89fe2fc620 (2026-09-13). Data as JSON: /api/errors/47fcc99aed502706. Report an issue: GitHub.

Appendix: source

Thrown at JFKFiles/JfkWebApiSkills/JfkInitializer/Program.cs:315

        private static void CheckSettings()
        {
            CheckSetting("SearchServiceName");
            CheckSetting("SearchServiceApiKey");
            CheckSetting("SearchServiceQueryKey");
            CheckSetting("BlobStorageAccountConnectionString");
            CheckSetting("AzureWebAppSiteName");
            CheckSetting("AzureWebAppUsername");
            CheckSetting("AzureWebAppPassword");
            CheckSetting("AzureFunctionSiteName");
            CheckSetting("AzureFunctionHostKey");
        }

        private static void CheckSetting(string settingKey)
        {
            var value = ConfigurationManager.AppSettings[settingKey];
            if (string.IsNullOrEmpty(value))
            {
                throw new SettingsPropertyNotFoundException($"[{settingKey}] can't be empty.");
            }
        }
    }
}

View on GitHub (pinned to 89fe2fc620)