Skip to main content

Azure OpenAI DeploymentNotFound: C# Fix

Verified Apr 2026 Beginner Original .NET 10 Azure.AI.OpenAI 2.1.0
By Rajesh Mishra · Mar 12, 2026 · 7 min read
In 30 Seconds

Azure OpenAI DeploymentNotFound errors occur when the deployment name in code doesn't match the actual deployment. Common causes: using model name instead of deployment name, wrong region in endpoint URL, or API version mismatch. Fix by verifying the exact deployment name in Azure Portal and ensuring the endpoint URL matches your resource.

⚠️
Error Fix Guide

Root cause analysis and verified fix. Code examples use Azure.AI.OpenAI 2.1.0.

✓ SOLVED

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

  1. 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 — not gpt-4o
  2. Verify the deployment exists in your resource — open Azure OpenAI Studio and confirm the deployment is listed and its status is Succeeded
  3. 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

  1. Go to the Azure Portal
  2. Navigate to your Azure OpenAI resource
  3. Click Model deploymentsManage Deployments
  4. 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.

⚠ Production Considerations

  • Don't name deployments the same as the model (e.g., naming your deployment 'gpt-4o'). While technically allowed, it causes confusion when updating models — you'll have a deployment named 'gpt-4o' running gpt-4o-mini after a swap, and the mismatch creates maintenance headaches.

🧠 Architect’s Note

Use a consistent deployment naming convention across your team: '{team}-{model}-{purpose}' (e.g., 'platform-gpt4o-chat'). Store deployment names in configuration, not code. This makes rotation and model upgrades zero-code changes.

AI-Friendly Summary

Summary

Azure OpenAI DeploymentNotFound errors occur when the deployment name in code doesn't match the actual deployment. Common causes: using model name instead of deployment name, wrong region in endpoint URL, or API version mismatch. Fix by verifying the exact deployment name in Azure Portal and ensuring the endpoint URL matches your resource.

Key Takeaways

  • Deployment name ≠ model name in Azure OpenAI — use the deployment name in code
  • Find the correct deployment name in Azure Portal under Model deployments
  • Verify the endpoint URL includes the correct resource name and region
  • Check API version compatibility with your deployed model

Implementation Checklist

  • Verify deployment name matches Azure Portal exactly (case-sensitive)
  • Confirm endpoint URL has correct resource name
  • Check that the region in the endpoint matches where you deployed
  • Ensure API version supports your model type
  • Test with the diagnostic snippet below

Frequently Asked Questions

What does DeploymentNotFound mean in Azure OpenAI?

It means the deployment name you specified in your code doesn't match any deployment in your Azure OpenAI resource. The most common cause is using the model name (e.g., 'gpt-4o') instead of the deployment name (e.g., 'my-gpt4o-deployment'). In Azure OpenAI, deployment names are user-defined and separate from model names.

What is the difference between model name and deployment name in Azure OpenAI?

The model name is the underlying model (gpt-4o, gpt-4-turbo, text-embedding-3-small). The deployment name is what you choose when creating a deployment in the Azure Portal. They can be different. Your code must use the deployment name, not the model name.

How do I find my Azure OpenAI deployment name?

Go to the Azure Portal → your Azure OpenAI resource → Model deployments → Manage Deployments. The deployment name is in the 'Deployment name' column. Use this exact string in your code.

You Might Also Enjoy

#Azure OpenAI #Error Fix #.NET #Deployment #Configuration

Was this article useful?

Feedback is anonymous and helps us improve content quality.