{"record":{"id":"92643aca774baec8","repo":"eyaltoledano/claude-task-master","slug":"azure-api-key-is-required","errorCode":null,"errorMessage":"Azure API key is required","messagePattern":"Azure API key is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/ai-providers/azure.js","lineNumber":30,"sourceCode":"\t\tthis.name = 'Azure OpenAI';\n\t}\n\n\t/**\n\t * Returns the environment variable name required for this provider's API key.\n\t * @returns {string} The environment variable name for the Azure OpenAI API key\n\t */\n\tgetRequiredApiKeyName() {\n\t\treturn 'AZURE_OPENAI_API_KEY';\n\t}\n\n\t/**\n\t * Validates Azure-specific authentication parameters\n\t * @param {object} params - Parameters to validate\n\t * @throws {Error} If required parameters are missing\n\t */\n\tvalidateAuth(params) {\n\t\tif (!params.apiKey) {\n\t\t\tthrow new Error('Azure API key is required');\n\t\t}\n\n\t\tif (!params.baseURL) {\n\t\t\tthrow new Error(\n\t\t\t\t'Azure endpoint URL is required. Set it in .taskmasterconfig global.azureBaseURL or models.[role].baseURL'\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Normalizes the base URL to ensure it ends with /openai for proper Azure API routing.\n\t * The Azure API expects paths like /openai/deployments/{model}/chat/completions\n\t * @param {string} baseURL - Original base URL\n\t * @returns {string} Normalized base URL ending with /openai\n\t */\n\tnormalizeBaseURL(baseURL) {\n\t\tif (!baseURL) return baseURL;\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/azure.js#L12-L48","documentation":"AzureProvider.validateAuth() runs before every AI call and requires an Azure API key in params.apiKey. The Azure provider authenticates with a key + endpoint URL pair; without a key the provider cannot build authenticated requests, so it fails fast with a clear message instead of a 401 from the remote API.","triggerScenarios":"Calling generateText/streamText/etc. via the azure provider when AZURE_AZURE_OPENAI_API_KEY (or the configured key source) is unset, or params.apiKey is undefined in direct provider use.","commonSituations":"API key not exported in shell/env; .env not loaded; key set under the wrong env var name; models config maps a role to azure without a key.","solutions":["Set AZURE_AZURE_OPENAI_API_KEY in your environment or .env file","Add the key to the models config so it is injected into params","Verify with `tm models --setup` that the azure role has credentials configured"],"exampleFix":"// before (.env)\n# AZURE_AZURE_OPENAI_API_KEY not set\n// after (.env)\nAZURE_AZURE_OPENAI_API_KEY=your-azure-openai-key","handlingStrategy":"validation","validationCode":"if (!process.env.AZURE_AZURE_OPENAI_API_KEY) throw new Error('Set AZURE_AZURE_OPENAI_API_KEY before using the azure provider');","typeGuard":"function hasAzureAuth(params) { return typeof params?.apiKey === 'string' && params.apiKey.length > 0; }","tryCatchPattern":"try {\n  await provider.generateText(params);\n} catch (err) {\n  if (err.message === 'Azure API key is required') {\n    console.error('Configure the Azure API key via env or `tm models --setup`');\n  } else throw err;\n}","preventionTips":["Keep API keys in .env and confirm it is loaded at startup","Run `tm models --setup` to validate provider credentials","Check key presence once at boot instead of per-request"],"tags":["azure","api-key","authentication","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}