Fix auth routing in samples 06/11: api_key -> credential for Azure OpenAI

Both samples passed a bearer token provider via api_key= which caused the
client to route to api.openai.com instead of Azure OpenAI, resulting in
401 Unauthorized. Changed to credential= which correctly triggers Azure
routing and picks up AZURE_OPENAI_ENDPOINT from the environment.

- samples/azure_functions/11_workflow_parallel/function_app.py: 1 fix
- samples/durabletask/06_multi_agent_orchestration_conditionals/worker.py: 2 fixes
- Re-enable 4 parallel workflow tests and 1 conditional branching test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Giles Odigwe
2026-04-27 06:12:28 -07:00
Unverified
parent f6f87477c9
commit a6e0ab5603
4 changed files with 3 additions and 8 deletions
@@ -42,7 +42,6 @@ class TestWorkflowParallel:
self.base_url = base_url
self.helper = sample_helper
@pytest.mark.skip(reason="xdist worker crashes during parallel workflow execution - needs investigation")
def test_parallel_workflow_document_analysis(self) -> None:
"""Test parallel workflow with a standard document."""
payload = {
@@ -71,7 +70,6 @@ class TestWorkflowParallel:
assert status["runtimeStatus"] == "Completed"
assert "output" in status
@pytest.mark.skip(reason="xdist worker crashes during parallel workflow execution - needs investigation")
def test_parallel_workflow_short_document(self) -> None:
"""Test parallel workflow with a short document."""
payload = {
@@ -91,7 +89,6 @@ class TestWorkflowParallel:
assert status["runtimeStatus"] == "Completed"
assert "output" in status
@pytest.mark.skip(reason="xdist worker crashes during parallel workflow execution - needs investigation")
def test_parallel_workflow_technical_document(self) -> None:
"""Test parallel workflow with a technical document."""
payload = {
@@ -115,7 +112,6 @@ class TestWorkflowParallel:
status = self.helper.wait_for_orchestration_with_output(data["statusQueryGetUri"], max_wait=300)
assert status["runtimeStatus"] == "Completed"
@pytest.mark.skip(reason="xdist worker crashes during parallel workflow execution - needs investigation")
def test_workflow_status_endpoint(self) -> None:
"""Test that the workflow status endpoint works correctly."""
payload = {
@@ -52,7 +52,6 @@ class TestMultiAgentOrchestrationConditionals:
assert email_agent is not None
assert email_agent.name == EMAIL_AGENT_NAME
@pytest.mark.skip(reason="Orchestration fails with RuntimeError (status=Failed, output=None) - not a timeout issue")
def test_conditional_branching(self):
"""Test that conditional branching works correctly."""
# Test with obvious spam
@@ -363,7 +363,7 @@ def _create_workflow() -> Workflow:
chat_client = OpenAIChatCompletionClient(
model=os.environ["AZURE_OPENAI_MODEL"],
api_key=get_bearer_token_provider(credential, "https://cognitiveservices.azure.com/.default"),
credential=get_bearer_token_provider(credential, "https://cognitiveservices.azure.com/.default"),
)
# Create agents for parallel analysis
@@ -70,7 +70,7 @@ def create_spam_agent() -> "Agent":
return Agent(
client=OpenAIChatCompletionClient(
model=os.environ["AZURE_OPENAI_MODEL"],
api_key=get_async_bearer_token_provider(
credential=get_async_bearer_token_provider(
AsyncAzureCliCredential(), "https://cognitiveservices.azure.com/.default"
),
),
@@ -88,7 +88,7 @@ def create_email_agent() -> "Agent":
return Agent(
client=OpenAIChatCompletionClient(
model=os.environ["AZURE_OPENAI_MODEL"],
api_key=get_async_bearer_token_provider(
credential=get_async_bearer_token_provider(
AsyncAzureCliCredential(), "https://cognitiveservices.azure.com/.default"
),
),