{"record":{"id":"b582a26daee7e420","repo":"n8n-io/n8n","slug":"failed-to-initialize-azure-openai-client-error","errorCode":null,"errorMessage":"Failed to initialize Azure OpenAI client: ${error.message}","messagePattern":"Failed to initialize Azure OpenAI client: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts","lineNumber":147,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\t});\n\n\t\t\tthis.logger.info(`Azure OpenAI client initialized for deployment: ${modelName}`);\n\n\t\t\treturn {\n\t\t\t\tresponse: model,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Error in LmChatAzureOpenAi.supplyData: ${error.message}`, error);\n\n\t\t\t// Re-throw NodeOperationError directly, wrap others\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`Failed to initialize Azure OpenAI client: ${error.message}`,\n\t\t\t\terror,\n\t\t\t);\n\t\t}\n\t}\n}\n","sourceCodeStart":129,"sourceCodeEnd":155,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts#L129-L155","documentation":"Top-level catch in LmChatAzureOpenAi.supplyData(). It re-throws NodeOperationError as-is so inner messages (e.g. error 694, 696-699) survive, and wraps any other exception in a NodeOperationError whose message is 'Failed to initialize Azure OpenAI client: ' + error.message, passing the original as the cause. It logs the error first for diagnostics.","triggerScenarios":"Any non-NodeOperationError thrown during Azure client construction — network error instantiating AzureChatOpenAI, missing env, malformed endpoint, SDK type error, or an unhandled configuration issue — bubbles into this catch.","commonSituations":"Endpoint URL malformed; resourceName empty; apiVersion unsupported by the SDK; proxy/network issue on first request; SDK version mismatch; Entra token credential throwing an unexpected shape.","solutions":["Read the wrapped error.message/cause — it identifies the underlying failure; fix that root cause.","Verify endpoint, resourceName, apiVersion, and deployment id in the credential.","For Entra OAuth2, confirm the token credential can fetch a token (see error 696/697).","Check network/proxy and Azure OpenAI quota/access from the n8n host."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate config before constructing AzureChatOpenAI\nif (!configCredentials.resourceName && !configCredentials.endpoint) {\n  throw new Error('Azure OpenAI resourceName or endpoint is required');\n}","typeGuard":"const isNodeOperationError = (e: unknown): e is NodeOperationError =>\n  e instanceof NodeOperationError;","tryCatchPattern":"try {\n  return { response: model };\n} catch (e) {\n  if (e instanceof NodeOperationError) throw e; // preserve specific messages\n  logger.error(e);\n  throw new NodeOperationError(this.getNode(), `Failed to initialize Azure OpenAI client: ${(e as Error).message}`, e as Error);\n}","preventionTips":["Pre-validate endpoint, resourceName, apiVersion before client construction.","Keep specific NodeOperationError checks above the generic wrapper.","Log the original error for diagnostics, then re-throw wrapped."],"tags":["azure","openai","llm","client-init","wrapping"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}