{"record":{"id":"580716238de30f62","repo":"microsoft/semantic-kernel","slug":"configuration-not-found-please-setup-the-notebook","errorCode":null,"errorMessage":"Configuration not found, please setup the notebooks first using notebook 0-AI-settings.pynb","messagePattern":"Configuration not found, please setup the notebooks first using notebook 0-AI-settings\\.pynb","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"dotnet/notebooks/config/Settings.cs","lineNumber":138,"sourceCode":"        if (!useAzureOpenAI && string.IsNullOrWhiteSpace(orgId))\n        {\n            orgId = await InteractiveKernel.GetInputAsync(\"Please enter your OpenAI Organization Id (enter 'NONE' to skip)\");\n        }\n\n        WriteSettings(configFile, useAzureOpenAI, model, azureEndpoint, apiKey, orgId);\n\n        return orgId;\n    }\n\n    // Load settings from file\n    public static (bool useAzureOpenAI, string model, string azureEndpoint, string apiKey, string orgId)\n        LoadFromFile(string configFile = DefaultConfigFile)\n    {\n        if (!File.Exists(configFile))\n        {\n            Console.WriteLine(\"Configuration not found: \" + configFile);\n            Console.WriteLine(\"\\nPlease run the Setup Notebook (0-AI-settings.ipynb) to configure your AI backend first.\\n\");\n            throw new Exception(\"Configuration not found, please setup the notebooks first using notebook 0-AI-settings.pynb\");\n        }\n\n        try\n        {\n            var config = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(configFile));\n            bool useAzureOpenAI = config[TypeKey] == \"azure\";\n            string model = config[ModelKey];\n            string azureEndpoint = config[EndpointKey];\n            string apiKey = config[SecretKey];\n            string orgId = config[OrgKey];\n            if (orgId == \"none\") { orgId = \"\"; }\n\n            return (useAzureOpenAI, model, azureEndpoint, apiKey, orgId);\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(\"Something went wrong: \" + e.Message);\n            return (true, \"\", \"\", \"\", \"\");","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/notebooks/config/Settings.cs#L120-L156","documentation":"The Settings.LoadFromFile method in the Semantic Kernel .NET notebooks throws a generic System.Exception when the configuration file at config/settings.json does not exist. This file is generated by running the 0-AI-settings.ipynb setup notebook, which interactively prompts for the AI backend type, model, endpoint, API key, and org ID. The exception message itself contains a typo (\"pynb\" instead of \"ipynb\") and uses the base Exception type rather than a more specific exception like FileNotFoundException.","triggerScenarios":"LoadFromFile() is called (directly or via ReadSettings/AskAzureEndpoint/AskModel/AskApiKey) when config/settings.json is absent. This happens on first run in a fresh notebook environment, after deleting settings, or when the working directory is not the notebooks root so the relative path resolves to a non-existent location.","commonSituations":"Cloning the repo and jumping straight into a sample notebook without running 0-AI-settings first; running notebooks from the wrong working directory (relative path 'config/settings.json' resolves incorrectly); CI/automated runs where the setup notebook was never executed; the settings file was gitignored and not restored after a clean clone.","solutions":["Run the 0-AI-settings.ipynb notebook first to generate config/settings.json with your backend credentials","Verify the working directory is the dotnet/notebooks root so the relative path config/settings.json resolves correctly","Create the file manually: a JSON object with keys \"type\", \"model\", \"endpoint\", \"apikey\", and \"org\" (see Settings.cs constants TypeKey through OrgKey)","Call Settings.LoadFromFile with an explicit absolute configFile path if running from a non-standard directory"],"exampleFix":"// before\nvar config = Settings.LoadFromFile(); // throws if config/settings.json missing\n\n// after — provide explicit path or check first\nstring configPath = Path.Combine(AppContext.BaseDirectory, \"config\", \"settings.json\");\nif (!File.Exists(configPath))\n    throw new FileNotFoundException(\"Run 0-AI-settings.ipynb to generate settings.\", configPath);\nvar config = Settings.LoadFromFile(configPath);","handlingStrategy":"validation","validationCode":"string configPath = Path.Combine(AppContext.BaseDirectory, \"config\", \"settings.json\");\nif (!File.Exists(configPath))\n{\n    Console.Error.WriteLine($\"Config file not found at {configPath}. Run 0-AI-settings.ipynb first.\");\n    return;\n}","typeGuard":"static bool TryGetSettings(string configFile, out (bool useAzureOpenAI, string model, string endpoint, string apiKey, string orgId) settings)\n{\n    settings = default;\n    if (!File.Exists(configFile)) return false;\n    try\n    {\n        var config = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(configFile));\n        if (config == null || !config.ContainsKey(\"type\")) return false;\n        settings = (config[\"type\"] == \"azure\", config[\"model\"], config[\"endpoint\"], config[\"apikey\"], config.GetValueOrDefault(\"org\", \"\"));\n        return true;\n    }\n    catch { return false; }\n}","tryCatchPattern":"try\n{\n    var settings = Settings.LoadFromFile(configPath);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Configuration not found\"))\n{\n    Console.Error.WriteLine(\"Run the 0-AI-settings.ipynb notebook to generate config/settings.json.\");\n    return;\n}","preventionTips":["Run 0-AI-settings.ipynb before any other notebook in the dotnet/notebooks directory","Use an absolute path for configFile instead of the relative default to avoid working-directory issues","Commit a template settings.json (without secrets) to document the expected key structure","Validate the settings file exists and is well-formed in a startup cell before calling LoadFromFile"],"tags":["configuration","csharp","notebooks","semantic-kernel","file-not-found"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}