{"record":{"id":"81cd6b24a1d93cba","repo":"microsoft/semantic-kernel","slug":"please-provide-an-azure-openai-deployment-name","errorCode":null,"errorMessage":"Please provide an Azure OpenAI deployment name","messagePattern":"Please provide an Azure OpenAI deployment name","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/azure_assistant_agent.py","lineNumber":127,"sourceCode":"\n        # If we still have no credentials, we can't proceed\n        if not azure_openai_settings.api_key and not ad_token and not ad_token_provider and not credential:\n            raise AgentInitializationException(\n                \"Please provide either an api_key, ad_token, ad_token_provider or credential for authentication.\"\n            )\n\n        merged_headers = dict(copy(default_headers)) if default_headers else {}\n        if default_headers:\n            merged_headers.update(default_headers)\n        if APP_INFO:\n            merged_headers.update(APP_INFO)\n            merged_headers = prepend_semantic_kernel_to_user_agent(merged_headers)\n\n        if not azure_openai_settings.endpoint:\n            raise AgentInitializationException(\"Please provide an Azure OpenAI endpoint\")\n\n        if not azure_openai_settings.chat_deployment_name:\n            raise AgentInitializationException(\"Please provide an Azure OpenAI deployment name\")\n\n        client = AsyncAzureOpenAI(\n            azure_endpoint=str(azure_openai_settings.endpoint),\n            api_version=azure_openai_settings.api_version,\n            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,\n            azure_ad_token=ad_token,\n            azure_ad_token_provider=ad_token_provider,\n            default_headers=merged_headers,\n            **kwargs,\n        )\n\n        return client, azure_openai_settings.chat_deployment_name\n\n    @staticmethod\n    def create_client(\n        *,\n        ad_token: str | None = None,\n        ad_token_provider: Callable[[], str | Awaitable[str]] | None = None,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/azure_assistant_agent.py#L109-L145","documentation":"The final factory check requires azure_openai_settings.chat_deployment_name (sourced from deployment_name arg or env). Without a deployment name the client cannot be tied to a deployed model, so AgentInitializationException(\"Please provide an Azure OpenAI deployment name\") is raised.","triggerScenarios":"Instantiating the Azure assistant without a deployment_name argument and without AZURE_OPENAI_CHAT_DEPLOYMENT_NAME in the environment, or with an empty deployment name.","commonSituations":"Forgetting the deployment_name kwarg; env var typo (e.g. AZURE_OPENAI_DEPLOYMENT_NAME instead of AZURE_OPENAI_CHAT_DEPLOYMENT_NAME); deployment not yet created in Azure; .env not loaded.","solutions":["Pass deployment_name explicitly, e.g. deployment_name='gpt-4o'.","Set AZURE_OPENAI_CHAT_DEPLOYMENT_NAME in env/.env (note the exact variable name).","Verify the deployment exists in the Azure OpenAI resource and matches the name you supply."],"exampleFix":"// before\nAzureOpenAIAssistantAgent(..., api_key=k, endpoint=e)  # no deployment\n# -> Please provide an Azure OpenAI deployment name\n\n// after\nAzureOpenAIAssistantAgent(..., api_key=k, endpoint=e, deployment_name='gpt-4o')","handlingStrategy":"validation","validationCode":"def has_deployment(settings) -> bool:\n    return bool(settings.chat_deployment_name)","typeGuard":"def has_azure_deployment(settings) -> bool:\n    return getattr(settings, 'chat_deployment_name', None) not in (None, \"\")","tryCatchPattern":null,"preventionTips":["Pass deployment_name or set AZURE_OPENAI_CHAT_DEPLOYMENT_NAME (exact name).","Verify the deployment exists in the Azure resource.","Double-check the env var spelling."],"tags":["azure","config","initialization","deployment","agentinit"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}