High severity HTTP 404 beginner · Fix: 2-5 min

ResourceNotFound

azure.core.exceptions.ResourceNotFoundError

What this error means
Azure OpenAI returns ResourceNotFound when the specified deployment name does not exist or is misconfigured in your Azure resource.

Stack trace

traceback
azure.core.exceptions.ResourceNotFoundError: (404) ResourceNotFound
Message: Deployment 'my-deployment' not found in Azure OpenAI resource.

During handling of the above exception, the following error occurred:

Traceback (most recent call last):
  File "app.py", line 25, in <module>
    response = client.chat.completions.create(
  File "/usr/local/lib/python3.9/site-packages/azure/ai/openai/_client.py", line 150, in create
    raise ResourceNotFoundError(message)
azure.core.exceptions.ResourceNotFoundError: Deployment 'my-deployment' not found in Azure OpenAI resource.
QUICK FIX
Double-check and correct the deployment_name parameter in your Azure OpenAI client to match an existing deployment exactly.

Why it happens

This error occurs because the deployment name provided in your Azure OpenAI client configuration does not match any deployment configured in your Azure OpenAI resource. The Azure service cannot find the requested deployment to route your request.

Detection

Check for ResourceNotFoundError exceptions when calling Azure OpenAI APIs and verify the deployment name against your Azure portal deployments before making requests.

Causes & fixes

1

The deployment name specified in the client does not exist in the Azure OpenAI resource.

✓ Fix

Verify and use the exact deployment name as configured in the Azure portal under your OpenAI resource deployments.

2

Using the wrong Azure OpenAI resource endpoint or subscription that does not contain the deployment.

✓ Fix

Ensure your client is configured with the correct Azure OpenAI resource endpoint and subscription matching the deployment.

3

Deployment was deleted or not yet created in the Azure portal.

✓ Fix

Create the deployment in the Azure portal or confirm it exists before calling the API.

Code: broken vs fixed

Broken - triggers the error
python
import os
from azure.ai.openai import OpenAIClient

client = OpenAIClient(
    endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    credential=os.environ["AZURE_OPENAI_KEY"]
)

response = client.chat.completions.create(
    deployment_name="wrong-deployment",  # This causes ResourceNotFound error
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
Fixed - works correctly
python
import os
from azure.ai.openai import OpenAIClient

client = OpenAIClient(
    endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    credential=os.environ["AZURE_OPENAI_KEY"]
)

# Fixed: Use the correct deployment name as configured in Azure portal
response = client.chat.completions.create(
    deployment_name=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
Changed deployment_name to use the correct existing deployment from environment variable to avoid ResourceNotFound error.

Workaround

Catch ResourceNotFoundError exceptions and log the deployment name and endpoint used; optionally fallback to a default deployment if available.

Prevention

Automate deployment name validation by fetching available deployments from Azure API or maintain deployment names in a centralized config to avoid typos and mismatches.

Python 3.9+ · azure-ai-openai >=1.0.0 · tested on 1.1.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.