microsoft/semantic-kernel · error · ServiceInitializationError

The Azure OpenAI embedding deployment name is required.

Error message

The Azure OpenAI embedding deployment name is required.

What it means

Raised by AzureTextEmbedding.__init__ after settings creation succeeds but embedding_deployment_name is empty or None. This field comes from the deployment_name constructor argument or the AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME environment variable. The embedding service requires a specific deployment name to target the correct model.

Source

Thrown at python/semantic_kernel/connectors/ai/open_ai/services/azure_text_embedding.py:79

        async_client (Optional[AsyncAzureOpenAI]): An existing client to use. (Optional)
        env_file_path (str | None): Use the environment settings file as a fallback to
            environment variables. (Optional)
        credential (TokenCredential): The credential to use for authentication.
        """
        try:
            azure_openai_settings = AzureOpenAISettings(
                env_file_path=env_file_path,
                api_key=api_key,
                embedding_deployment_name=deployment_name,
                endpoint=endpoint,
                base_url=base_url,
                api_version=api_version,
                token_endpoint=token_endpoint,
            )
        except ValidationError as exc:
            raise ServiceInitializationError(f"Invalid settings: {exc}") from exc
        if not azure_openai_settings.embedding_deployment_name:
            raise ServiceInitializationError("The Azure OpenAI embedding deployment name is required.")

        super().__init__(
            deployment_name=azure_openai_settings.embedding_deployment_name,
            endpoint=azure_openai_settings.endpoint,
            base_url=azure_openai_settings.base_url,
            api_version=azure_openai_settings.api_version,
            service_id=service_id,
            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,
            ad_token=ad_token,
            ad_token_provider=ad_token_provider,
            token_endpoint=azure_openai_settings.token_endpoint,
            default_headers=default_headers,
            ai_model_type=OpenAIModelTypes.EMBEDDING,
            client=async_client,
            credential=credential,
        )

    @classmethod

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass deployment_name= explicitly: AzureTextEmbedding(deployment_name='text-embedding-3-large', ...).
  2. Set AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME in your environment or .env file.
  3. Verify the deployment exists in Azure Portal under Resource Management > Deployments and the name matches exactly.

Example fix

# before
service = AzureTextEmbedding(
    endpoint='https://myresource.openai.azure.com',
    api_key='...',
)
# after
service = AzureTextEmbedding(
    deployment_name='text-embedding-3-large',
    endpoint='https://myresource.openai.azure.com',
    api_key='...',
)
Defensive patterns

Strategy: validation

Validate before calling

import os

deployment_name = os.environ.get('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME')
if not deployment_name:
    raise ValueError(
        'AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME is not set. '
        'Set it in your environment or .env file, or pass deployment_name= to the constructor.'
    )

Try / catch

from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError

try:
    service = AzureTextEmbedding(
        deployment_name=os.environ.get('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME'),
        endpoint='https://myresource.openai.azure.com',
        api_key='...',
    )
except ServiceInitializationError as e:
    if 'embedding deployment name is required' in str(e):
        print('Set AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME or pass deployment_name=')
    raise

Prevention

When it happens

Trigger: Constructing AzureTextEmbedding without deployment_name= and without AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME set in the environment or .env file. Endpoint and auth resolved successfully, but the deployment identifier is missing.

Common situations: Using a generic AZURE_OPENAI_DEPLOYMENT_NAME instead of the embedding-specific variable; embedding model deployment created in Azure but the variable not added to config; .env file present but embedding line commented out; running in a fresh environment without the deployment env var.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/aaa5a7b50512d834. Report an issue: GitHub.