openai-chat-app-quickstart icon indicating copy to clipboard operation
openai-chat-app-quickstart copied to clipboard

Migrate from deprecated AzureOpenAI to standard OpenAI client constructors

Open Copilot opened this issue 2 months ago • 0 comments

This PR migrates the repository from the deprecated Azure-specific OpenAI client constructors (AsyncAzureOpenAI) to the standard OpenAI client constructors (AsyncOpenAI) to maintain compatibility with current and future OpenAI SDK versions.

Changes Made

Core Application Updates

  • Updated src/quartapp/chat.py:
    • Changed import from AsyncAzureOpenAI to AsyncOpenAI
    • Updated client constructor parameters:
      • azure_endpointbase_url
      • azure_ad_token_providerapi_key
      • Removed api_version parameter entirely

Infrastructure Updates

  • Updated infra/main.bicep: Removed openAiApiVersion parameter and related output
  • Updated infra/aca.bicep: Removed AZURE_OPENAI_API_VERSION environment variable
  • Updated .env.sample: Removed AZURE_OPENAI_API_VERSION configuration

Dependencies

  • Updated src/pyproject.toml: Changed OpenAI requirement from "openai" to "openai>=1.108.1"
  • Regenerated src/requirements.txt: Now uses OpenAI 1.109.0

Testing

  • Updated tests/test_app.py: Modified test assertion to check api_key property instead of the deprecated _azure_ad_token_provider

Migration Example

Before:

bp.openai_client = AsyncAzureOpenAI(
    api_version=os.getenv("AZURE_OPENAI_API_VERSION") or "2024-02-15-preview",
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    azure_ad_token_provider=token_provider,
)

After:

bp.openai_client = AsyncOpenAI(
    base_url=os.getenv("AZURE_OPENAI_ENDPOINT"),
    api_key=token_provider,
)

Validation

  • All existing tests continue to pass
  • Application functionality remains unchanged
  • Code passes linting checks
  • Dependencies resolve correctly

This migration ensures the codebase uses the supported OpenAI SDK API surface while maintaining full compatibility with Azure OpenAI services.

Fixes #339.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Sep 23 '25 21:09 Copilot