{"record":{"id":"743be0657d078683","repo":"Mintplex-Labs/anything-llm","slug":"no-azure-api-key-was-set-743be0","errorCode":null,"errorMessage":"No Azure API key was set.","messagePattern":"No Azure API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/azureOpenAi/index.js","lineNumber":9,"sourceCode":"const { toChunks, reportEmbeddingProgress } = require(\"../../helpers\");\n\nclass AzureOpenAiEmbedder {\n  constructor() {\n    const { AzureOpenAI } = require(\"openai\");\n    if (!process.env.AZURE_OPENAI_ENDPOINT)\n      throw new Error(\"No Azure API endpoint was set.\");\n    if (!process.env.AZURE_OPENAI_KEY)\n      throw new Error(\"No Azure API key was set.\");\n\n    this.className = \"AzureOpenAiEmbedder\";\n    this.apiVersion = \"2024-12-01-preview\";\n    const openai = new AzureOpenAI({\n      apiKey: process.env.AZURE_OPENAI_KEY,\n      endpoint: process.env.AZURE_OPENAI_ENDPOINT,\n      apiVersion: this.apiVersion,\n    });\n\n    // We cannot assume the model fallback since the model is based on the deployment name\n    // and not the model name - so this will throw on embedding if the model is not defined.\n    this.model = process.env.EMBEDDING_MODEL_PREF;\n    this.openai = openai;\n\n    // Limit of how many strings we can process in a single pass to stay with resource or network limits\n    // https://learn.microsoft.com/en-us/azure/ai-services/openai/faq#i-am-trying-to-use-embeddings-and-received-the-error--invalidrequesterror--too-many-inputs--the-max-number-of-inputs-is-1---how-do-i-fix-this-:~:text=consisting%20of%20up%20to%2016%20inputs%20per%20API%20request\n    this.maxConcurrentChunks = 16;\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/azureOpenAi/index.js#L1-L27","documentation":"Thrown in the AzureOpenAiEmbedder constructor when AZURE_OPENAI_KEY is falsy, immediately after the endpoint check passes. Without the key the AzureOpenAI client cannot authenticate to the embeddings deployment.","triggerScenarios":"AZURE_OPENAI_ENDPOINT is set but AZURE_OPENAI_KEY is missing/empty; key stored under a different env name; key rotated in Azure but not redeployed.","commonSituations":"Copying the endpoint from the portal but not the key; using KEY_VAULT/managed identity without updating this constructor; AAD/Microsoft Entra auth intended but the code still requires the static key.","solutions":["Set AZURE_OPENAI_KEY to a valid key from the Azure OpenAI resource (Keys and Endpoint pane).","Ensure AZURE_OPENAI_ENDPOINT is also set (the prior check).","Restart the server after setting the var.","If using keyless/Entra auth, note this embedder path requires the static key; switch to the appropriate provider or supply the key."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertAzureEmbedKey() {\n  if (!process.env.AZURE_OPENAI_KEY) {\n    throw new Error('Missing env AZURE_OPENAI_KEY');\n  }\n}\nassertAzureEmbedKey();","typeGuard":null,"tryCatchPattern":"try {\n  new AzureOpenAiEmbedder();\n} catch (e) {\n  if (/key/i.test(e.message) && /azure/i.test(e.message)) { /* prompt for AZURE_OPENAI_KEY */ }\n  throw e;\n}","preventionTips":["Copy both Key1/Key2 from the Azure resource, not just the endpoint.","This embedder requires a static key — Entra/managed identity is not supported here.","Restart after rotating the key."],"tags":["azure","openai","embeddings","config","env","auth","startup"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}