microsoft/autogen · error · FileNotFoundException

Configuration not found: {configFile}

Error message

Configuration not found: {configFile}

What it means

KernelSettings.FromFile throws FileNotFoundException when the specified settings JSON (default appsettings.json / config file) does not exist on disk at the given path. The seed-memory tool loads its Azure/OpenAI kernel configuration from this file, and the error is the first of three escalating guards (file missing -> file invalid -> user secrets invalid).

Source

Thrown at dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs:71

        }
        catch (InvalidDataException ide)
        {
            Console.Error.WriteLine(
                "Unable to load semantic kernel settings, please provide configuration settings using instructions in the README.\n" +
                "Please refer to: https://github.com/microsoft/semantic-kernel-starters/blob/main/sk-csharp-hello-world/README.md#configuring-the-starter"
            );
            throw new InvalidOperationException(ide.Message);
        }
    }

    /// <summary>
    /// Load the kernel settings from the specified configuration file if it exists.
    /// </summary>
    internal static KernelSettings FromFile(string configFile = DefaultConfigFile)
    {
        if (!File.Exists(configFile))
        {
            throw new FileNotFoundException($"Configuration not found: {configFile}");
        }

        var configuration = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile(configFile, optional: true, reloadOnChange: true)
            .AddEnvironmentVariables()
            .Build();

        return configuration.Get<KernelSettings>()
               ?? throw new InvalidDataException($"Invalid semantic kernel settings in '{configFile}', please provide configuration settings using instructions in the README.");
    }

    /// <summary>
    /// Load the kernel settings from user secrets.
    /// </summary>
    internal static KernelSettings FromUserSecrets()
    {
        var configuration = new ConfigurationBuilder()

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Create the settings JSON at the expected path using the README template (embedding endpoint, key, deployment names).
  2. Set the file to copy to output in the csproj: <None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" />.
  3. Pass an absolute path to FromFile, or make the path relative to AppContext.BaseDirectory rather than the current directory.
  4. Alternatively skip the file entirely and use user secrets: KernelSettings.FromUserSecrets().

Example fix

// before
internal static KernelSettings FromFile(string configFile = DefaultConfigFile)
{
    if (!File.Exists(configFile)) { throw new FileNotFoundException($"Configuration not found: {configFile}"); }

// after (resolve relative to the app binary, not the CWD)
var resolved = Path.IsPathRooted(configFile) ? configFile : Path.Combine(AppContext.BaseDirectory, configFile);
if (!File.Exists(resolved)) { throw new FileNotFoundException($"Configuration not found: {resolved}"); }
Defensive patterns

Strategy: validation

Validate before calling

var resolved = Path.IsPathRooted(configFile) ? configFile : Path.Combine(AppContext.BaseDirectory, configFile);
if (!File.Exists(resolved))
{
    Console.Error.WriteLine($"Config file not found at {resolved}. Copy the README template and fill in your Azure OpenAI settings.");
    return;
}

Try / catch

try { settings = KernelSettings.FromFile(configFile); } catch (FileNotFoundException) { settings = KernelSettings.FromUserSecrets(); } // fall back to user secrets when the file is absent

Prevention

When it happens

Trigger: Calling KernelSettings.FromFile("appsettings.json"), or any custom configFile path, when the file is absent; running seed-memory from a directory other than the project output directory where the JSON was not copied.

Common situations: Fresh clone without creating the config file per the dev-team README; file exists in the repo root but the exe runs from bin/Debug without CopyToOutputDirectory; passing a relative path while Directory.GetCurrentDirectory() differs from the expected folder.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/502d0563524d837b. Report an issue: GitHub.