From a6e0ab5603998d7bb9181ecb1c2bc017c75c5d32 Mon Sep 17 00:00:00 2001 From: Giles Odigwe Date: Mon, 27 Apr 2026 06:12:28 -0700 Subject: [PATCH] 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> --- .../tests/integration_tests/test_11_workflow_parallel.py | 4 ---- .../test_06_dt_multi_agent_orchestration_conditionals.py | 1 - .../azure_functions/11_workflow_parallel/function_app.py | 2 +- .../06_multi_agent_orchestration_conditionals/worker.py | 4 ++-- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/python/packages/azurefunctions/tests/integration_tests/test_11_workflow_parallel.py b/python/packages/azurefunctions/tests/integration_tests/test_11_workflow_parallel.py index 1c82f8c245..683ab7e0be 100644 --- a/python/packages/azurefunctions/tests/integration_tests/test_11_workflow_parallel.py +++ b/python/packages/azurefunctions/tests/integration_tests/test_11_workflow_parallel.py @@ -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 = { diff --git a/python/packages/durabletask/tests/integration_tests/test_06_dt_multi_agent_orchestration_conditionals.py b/python/packages/durabletask/tests/integration_tests/test_06_dt_multi_agent_orchestration_conditionals.py index 949028d743..177f4ca5f4 100644 --- a/python/packages/durabletask/tests/integration_tests/test_06_dt_multi_agent_orchestration_conditionals.py +++ b/python/packages/durabletask/tests/integration_tests/test_06_dt_multi_agent_orchestration_conditionals.py @@ -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 diff --git a/python/samples/04-hosting/azure_functions/11_workflow_parallel/function_app.py b/python/samples/04-hosting/azure_functions/11_workflow_parallel/function_app.py index 7deea4211c..0669d95e7b 100644 --- a/python/samples/04-hosting/azure_functions/11_workflow_parallel/function_app.py +++ b/python/samples/04-hosting/azure_functions/11_workflow_parallel/function_app.py @@ -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 diff --git a/python/samples/04-hosting/durabletask/06_multi_agent_orchestration_conditionals/worker.py b/python/samples/04-hosting/durabletask/06_multi_agent_orchestration_conditionals/worker.py index 0b5f014873..2b1af9d441 100644 --- a/python/samples/04-hosting/durabletask/06_multi_agent_orchestration_conditionals/worker.py +++ b/python/samples/04-hosting/durabletask/06_multi_agent_orchestration_conditionals/worker.py @@ -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" ), ),