The Error
You’re calling Azure OpenAI and getting one of these:
Azure.RequestFailedException: The API deployment for this resource does not exist.
Status: 404 (Not Found)
ErrorCode: DeploymentNotFound
Or:
Azure.RequestFailedException: Resource not found.
Status: 404 (Not Found)
ErrorCode: ResourceNotFound
Both mean the same thing: the SDK can’t find the deployment you specified.
Fixes at a Glance
- Use the deployment name, not the model name — in the Azure portal, your deployment has a custom label (e.g.
my-gpt4o-prod); that is what your code must pass — notgpt-4o - Verify the deployment exists in your resource — open Azure OpenAI Studio and confirm the deployment is listed and its status is
Succeeded - Check for region mismatches — your endpoint URL encodes the Azure region; a deployment in East US cannot be called via a West Europe endpoint URL
The Root Cause: Deployment Name vs Model Name
This is the #1 configuration mistake with Azure OpenAI. It trips up everyone coming from the OpenAI API, where you just specify model="gpt-4o".
In Azure OpenAI, there’s an extra layer:
OpenAI API: model="gpt-4o" ← model name directly
Azure OpenAI: deployment="your-custom-name" ← YOUR chosen name for the deployment
When you create a deployment in the Azure Portal, you choose:
- The model (gpt-4o, gpt-4-turbo, etc.) — what runs behind the scenes
- The deployment name — a unique identifier you pick
Your code must use the deployment name, not the model name.
The Common Mistake
// Wrong — using the model name
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
deploymentName: "gpt-5", // ← This is the MODEL name, not your deployment name
endpoint: "https://my-resource.openai.azure.com/",
apiKey: "key")
.Build();
// Correct — using the actual deployment name from Azure Portal
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
deploymentName: "my-gpt4o-deployment", // ← Your deployment name
endpoint: "https://my-resource.openai.azure.com/",
apiKey: "key")
.Build();
How to Find Your Deployment Name
- Go to the Azure Portal
- Navigate to your Azure OpenAI resource
- Click Model deployments → Manage Deployments
- Find the Deployment name column
That string — exactly as shown — is what goes in your code.
You can also check via Azure CLI:
az cognitiveservices account deployment list \
--name your-resource-name \
--resource-group your-rg \
--output table
Other Causes
Wrong Region in Endpoint
Your endpoint URL must match the region where your resource is deployed:
// Wrong — resource is in East US but URL says West Europe
var endpoint = "https://my-resource.openai.azure.com/"; // ← correct domain?
// The resource name in the URL must match your actual Azure resource name exactly
Verify in the Azure Portal: go to your resource → Keys and Endpoint → copy the endpoint URL directly.
API Version Mismatch
Some models require a minimum API version. If you’re manually specifying the API version:
var options = new AzureOpenAIClientOptions(
AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview);
Ensure the version supports your model type. GPT-4o works with most versions, but newer features (structured outputs, specific tool calling modes) may require recent API versions.
Deployment Still Provisioning
If you just created the deployment, it needs 1–3 minutes to become available. The Azure Portal shows the deployment as “Succeeded” before the inference endpoint is fully live. Wait and retry.
Diagnostic Snippet
Use this to verify your configuration:
using Azure.AI.OpenAI;
using Azure;
var endpoint = "https://your-resource.openai.azure.com/";
var key = "your-key";
var deploymentName = "your-deployment-name";
Console.WriteLine($"Endpoint: {endpoint}");
Console.WriteLine($"Deployment: {deploymentName}");
Console.WriteLine($"Key starts with: {key[..8]}...");
try
{
var client = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(key));
var chatClient = client.GetChatClient(deploymentName);
var response = await chatClient.CompleteChatAsync("Say hello");
Console.WriteLine($"✓ Success: {response.Value.Content[0].Text}");
}
catch (RequestFailedException ex) when (ex.ErrorCode == "DeploymentNotFound")
{
Console.WriteLine($"✗ Deployment '{deploymentName}' not found.");
Console.WriteLine(" Check: Azure Portal → Your Resource → Model Deployments");
Console.WriteLine(" Make sure you're using the deployment name, not the model name.");
}
catch (RequestFailedException ex) when (ex.Status == 401)
{
Console.WriteLine($"✗ Authentication failed. Check your API key.");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"✗ Error {ex.Status}: {ex.Message}");
}
Configuration Best Practice
Don’t hardcode deployment names. Use configuration:
// appsettings.json
{
"AzureOpenAI": {
"Endpoint": "https://your-resource.openai.azure.com/",
"DeploymentName": "my-gpt4o-deployment",
"EmbeddingDeploymentName": "my-embedding-deployment"
}
}
var config = builder.Configuration.GetSection("AzureOpenAI");
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
deploymentName: config["DeploymentName"]!,
endpoint: config["Endpoint"]!,
apiKey: Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY")!)
.Build();
This way, changing deployments (model upgrades, capacity changes) requires a config update, not a code change.
Related Errors
- Fix 401 Unauthorized Azure OpenAI — API key issues
- Fix 429 Rate Limit Exceeded — Throttling issues
- Fix 503 Service Unavailable — Service overload
- Fix Model Not Found Errors — Related endpoint errors