{"record":{"id":"31ba72fc1c6be27e","repo":"mastra-ai/mastra","slug":"azure-deployments-fetch-error","errorCode":"AZURE_DEPLOYMENTS_FETCH_ERROR","errorMessage":"Failed to fetch Azure deployments: ${response.status} ${error}","messagePattern":"Failed to fetch Azure deployments: (.+?) (.+?)","errorType":"http","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/llm/model/gateways/azure.ts","lineNumber":436,"sourceCode":"  ): Promise<AzureDeployment[]> {\n    const { subscriptionId, resourceGroup, resourceName } = credentials;\n\n    let url: string | undefined =\n      `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.CognitiveServices/accounts/${resourceName}/deployments?api-version=2024-10-01`;\n\n    const allDeployments: AzureDeployment[] = [];\n\n    while (url) {\n      const response = await fetch(url, {\n        headers: {\n          Authorization: `Bearer ${token}`,\n          'Content-Type': 'application/json',\n        },\n      });\n\n      if (!response.ok) {\n        const error = await response.text();\n        throw new MastraError({\n          id: 'AZURE_DEPLOYMENTS_FETCH_ERROR',\n          domain: 'LLM',\n          category: 'UNKNOWN',\n          text: `Failed to fetch Azure deployments: ${response.status} ${error}`,\n        });\n      }\n\n      const data = (await response.json()) as AzureDeploymentsResponse;\n\n      allDeployments.push(...data.value);\n\n      url = data.nextLink;\n    }\n\n    const successfulDeployments = allDeployments.filter(d => d.properties.provisioningState === 'Succeeded');\n\n    return successfulDeployments;\n  }","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/llm/model/gateways/azure.ts#L418-L454","documentation":"The Azure model gateway failed to fetch the list of available deployments from the Azure OpenAI management endpoint. The HTTP response was not ok, and the error includes the status code plus the raw response body for diagnosis. This MastraError surfaces network/auth/config problems with the Azure resource itself.","triggerScenarios":"Calling fetchDeployments() (via deployments()) when the Azure API returns a non-2xx response: invalid endpoint/apiVersion, missing or invalid API key, wrong resource name, rate limiting, or network failure reaching the Azure endpoint.","commonSituations":"Wrong AZURE endpoint hostname or missing deployment resource; expired/rotated API key; using a resource in a region that's down; blocked corporate network; wrong api-version query param.","solutions":["Check the status code and body in the error message to identify the cause (401/403 = credentials, 404 = wrong endpoint/resource, 429 = throttling).","Verify the Azure endpoint URL and apiVersion configured on the gateway are correct for your resource.","Verify the Azure OpenAI API key is valid and has access to the resource.","Retry after backoff if status is 429 or 5xx (transient Azure issue)."],"exampleFix":"// before\nconst gw = new MastraAzureGateway({ resource: 'wrong-resource', apiKey: process.env.AZURE_KEY });\nawait gw.deployments();\n// after\nconst gw = new MastraAzureGateway({ resource: 'my-openai-resource', apiKey: process.env.AZURE_OPENAI_API_KEY });\ntry {\n  await gw.deployments();\n} catch (e) {\n  console.error('Azure deployments fetch failed:', e); // inspect status in message\n}","handlingStrategy":"try-catch","validationCode":"if (!process.env.AZURE_OPENAI_API_KEY || !gw.config?.resource) throw new Error('Azure gateway needs resource + API key before fetching deployments');","typeGuard":null,"tryCatchPattern":"try {\n  const deployments = await gw.deployments();\n} catch (e) {\n  const m = /Failed to fetch Azure deployments: (\\d+)/.exec(e.message);\n  if (m && (m[1] === '429' || m[1].startsWith('5'))) await retryWithBackoff(() => gw.deployments());\n  else throw e;\n}","preventionTips":["Validate resource name and API key at startup before network calls.","Log status code and response body from the error message for triage.","Retry only on 429/5xx with exponential backoff.","Pin a supported apiVersion for your resource."],"tags":["azure","http","network","gateway"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}