{"record":{"id":"7c9154d8a6a953d6","repo":"microsoft/semantic-kernel","slug":"the-azure-text-deployment-name-is-required","errorCode":null,"errorMessage":"The Azure Text deployment name is required.","messagePattern":"The Azure Text deployment name is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py","lineNumber":89,"sourceCode":"            async_client (Optional[AsyncAzureOpenAI]): An existing client to use. (Optional)\n            env_file_path (str | None): Use the environment settings file as a fallback to\n                environment variables. (Optional)\n            credential (TokenCredential): The credential to use for authentication. (Optional)\n        \"\"\"\n        try:\n            azure_openai_settings = AzureOpenAISettings(\n                env_file_path=env_file_path,\n                text_deployment_name=deployment_name,\n                endpoint=endpoint,\n                base_url=base_url,\n                api_key=api_key,\n                api_version=api_version,\n                token_endpoint=token_endpoint,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(f\"Invalid settings: {ex}\") from ex\n        if not azure_openai_settings.text_deployment_name:\n            raise ServiceInitializationError(\"The Azure Text deployment name is required.\")\n\n        super().__init__(\n            deployment_name=azure_openai_settings.text_deployment_name,\n            endpoint=azure_openai_settings.endpoint,\n            base_url=azure_openai_settings.base_url,\n            api_version=azure_openai_settings.api_version,\n            service_id=service_id,\n            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,\n            ad_token=ad_token,\n            ad_token_provider=ad_token_provider,\n            token_endpoint=azure_openai_settings.token_endpoint,\n            default_headers=default_headers,\n            ai_model_type=OpenAIModelTypes.TEXT,\n            client=async_client,\n            credential=credential,\n        )\n\n    @classmethod","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py#L71-L107","documentation":"Raised by AzureTextCompletion.__init__ after settings creation succeeds but the text_deployment_name field is empty or None. This field is sourced from the deployment_name constructor argument or the AZURE_OPENAI_TEXT_DEPLOYMENT_NAME environment variable. Without it, the service cannot target a specific model deployment. Note: AzureTextCompletion is deprecated — all Azure OpenAI text completion models have been retired.","triggerScenarios":"Constructing AzureTextCompletion without deployment_name= and without AZURE_OPENAI_TEXT_DEPLOYMENT_NAME in the environment or .env file. Settings otherwise validated (endpoint, auth resolved) but the deployment name is absent.","commonSituations":"Using AZURE_OPENAI_CHAT_DEPLOYMENT_NAME (chat-specific) instead of the text-specific variable; deployment was never configured in Azure Portal; .env file missing the text deployment line. The underlying issue may be moot since text completion models are retired.","solutions":["Migrate to AzureChatCompletion and use AZURE_OPENAI_CHAT_DEPLOYMENT_NAME — text completion models are retired on Azure.","If required, pass deployment_name= explicitly in the constructor.","Set AZURE_OPENAI_TEXT_DEPLOYMENT_NAME in your environment or .env file."],"exampleFix":"# before\nservice = AzureTextCompletion(\n    endpoint='https://myresource.openai.azure.com',\n    api_key='...',\n)\n# after (migrate to chat completion)\nservice = AzureChatCompletion(\n    deployment_name='gpt-4o',\n    endpoint='https://myresource.openai.azure.com',\n    api_key='...',\n)","handlingStrategy":"validation","validationCode":"import os\n\ndeployment_name = os.environ.get('AZURE_OPENAI_TEXT_DEPLOYMENT_NAME')\nif not deployment_name:\n    raise ValueError(\n        'AZURE_OPENAI_TEXT_DEPLOYMENT_NAME is not set. Note: Azure text completion models are retired — '\n        'consider migrating to AzureChatCompletion with AZURE_OPENAI_CHAT_DEPLOYMENT_NAME.'\n    )","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    service = AzureTextCompletion(\n        deployment_name=os.environ.get('AZURE_OPENAI_TEXT_DEPLOYMENT_NAME'),\n        endpoint='https://myresource.openai.azure.com',\n        api_key='...',\n    )\nexcept ServiceInitializationError as e:\n    if 'deployment name is required' in str(e):\n        print('Set AZURE_OPENAI_TEXT_DEPLOYMENT_NAME or migrate to AzureChatCompletion')\n    raise","preventionTips":["Migrate to AzureChatCompletion — Azure text completion models are retired.","If still needed, pass deployment_name= explicitly or set AZURE_OPENAI_TEXT_DEPLOYMENT_NAME.","Verify the deployment name in Azure Portal matches exactly.","Do not use a generic AZURE_OPENAI_DEPLOYMENT_NAME — each service has its own deployment variable."],"tags":["azure-openai","text-completion","deprecated","deployment-name","env-vars"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}