MicrosoftLearning / MicrosoftLearning/mslearn-ai-language
Lab 03-gen-ai-speech: outdated api_version, and the Target URI step no longer matches the current Foundry portal
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 273
- Forks
- 544
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Lab File Path: Instructions/Exercises/03-gen-ai-speech.md (code duplicated in Labfiles/03-gen-ai-speech/Python/generate-speech/generate-speech.py and Labfiles/03-gen-ai-speech/Python/transcribe-speech/transcribe-speech.py)
Problem 1 - hardcoded api_version goes stale: The lab instructs learners to create the Azure OpenAI client with a hardcoded, dated api_version:
client = AzureOpenAI(
azure_endpoint=endpoint,
azure_ad_token_provider = token_provider,
api_version="2025-03-01-preview"
)
The openai Python package validates api_version against a list baked into that package release. Depending on which openai version pip install -r requirements.txt resolves to, 2025-03-01-preview can be rejected as an unsupported API version, causing the exercise to fail with no clear fix suggested in the instructions. Since Azure OpenAI ships new dated API versions roughly monthly, any hardcoded value like this will keep going stale.
Problem 2 - the "Target URI" step no longer matches the current portal: The lab says that when you view a deployed model's details, "the Target URI ... you'll need ... later" is available there, and to paste it into .env as endpoint. In the current Foundry portal, selecting a deployed model under Build > Deployments instead surfaces the project endpoint, e.g.:
https://<resource-name>.services.ai.azure.com/api/projects/<project-name>
That's the Foundry project endpoint (for the Foundry SDK / agents), not something the AzureOpenAI/OpenAI client's azure_endpoint/base_url can use directly - pasting it in produces broken requests. This was reproduced across two separate deployments/projects, so it looks like a consistent portal behavior rather than a one-off glitch.
The project's home page, however, does expose a ready-made, correct endpoint for the OpenAI SDK (labeled as the OpenAI endpoint), shaped like:
https://<resource-name>.openai.azure.com/openai/v1
This is already the full v1 base URL and can be used as base_url unmodified - no concatenation needed.
Note - region restriction is understated: The lab's callout says gpt-4o-mini-tts is "a recommended model for this exercise, not a required one," but doesn't mention that it currently can only be deployed in East US 2 - the same region the lab already tells learners to pick for the project earlier ("For this exercise some models are only available in this location"). It would help to say explicitly, next to the gpt-4o-mini-tts callout, that this specific model requires East US 2, rather than leaving it as a general "some models" note learners only discover after a failed deployment attempt in another region.
Proposed Solution (tested and verified working): Move the lab to the newer Azure OpenAI v1 API, which drops the api_version parameter entirely (Microsoft's current recommended path since August 2025), and change the "copy the Target URI" step to instead point learners at the ready-made OpenAI v1 endpoint on the project home page:
from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://ai.azure.com/.default"
)
# Use the Azure OpenAI v1 endpoint from the Foundry project home page
client = OpenAI(
base_url=endpoint, # e.g. https://<resource-name>.openai.azure.com/openai/v1
api_key=token_provider,
)
I tested this exact change end-to-end against a live gpt-4o-mini-tts deployment (East US 2): with AzureOpenAI(..., api_version=...) replaced by OpenAI(base_url=..., api_key=...) and .env's endpoint value replaced with the project home page's OpenAI endpoint, client.audio.speech.with_streaming_response.create(...) generates and saves speech successfully. The rest of the calling code is unchanged - just keep passing the deployment name in model.
If the lab needs to stay on the dated AzureOpenAI client for now, at minimum pin openai to a known-good version in requirements.txt, update the endpoint-copying instructions/screenshots to match the current portal, call out the East US 2 requirement explicitly, and/or reference the current list of supported api-version values at https://learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle so learners aren't stuck guessing.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Instructions/Exercises/03-gen-ai-speech.md, then compare the duplicated client code in Labfiles/03-gen-ai-speech/Python/generate-speech/generate-speech.py and transcribe-speech/transcribe-speech.py, plus requirements.txt. Verify the current Foundry endpoint guidance and API usage against the documented working flow; the lab is done when both scripts and instructions work with the current portal and the East US 2 model requirement is explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- ai, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100