-
Notifications
You must be signed in to change notification settings - Fork 278
Description
Describe the bug
When creating and provisioning a Python agent using the Microsoft 365 Agents Toolkit (v6.4.1), the generated root .env file is missing the required TENANT_ID variable.
Without TENANT_ID, the Python Teams SDK defaults to the /common authority (multi-tenant). Since the provisioned Entra app is single-tenant, token acquisition succeeds but is rejected by the Bot Framework service, causing all outbound bot replies to fail with:
[ERROR] @teams/app.HttpPlugin Activity 1765446490692 failed: Client error '401 Unauthorized' for url 'https://smba.trafficmanager.net/emea/<TENANT-ID>//v3/conversations/a:1mR7WlV5ReKiqO5bKlTyk5x7j8znA3xcbnWE44rTYEM3vq2XGCSWpM7q1_ywk5SJk-XZPgNqzwQGgK3Uan2UbTuboKnHAEKzHNSSLxnxffeNI3OQIy60jOiDGVHlMEH5a/activities'
[ERROR] @teams/app.HttpPlugin For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
[ERROR] @teams/app.HttpPlugin Unexpected error during token validation: Client error '401 Unauthorized' for url 'https://smba.trafficmanager.net/emea/<TENANT-ID>//v3/conversations/a:1mR7WlV5ReKiqO5bKlTyk5x7j8znA3xcbnWE44rTYEM3vq2XGCSWpM7q1_ywk5SJk-XZPgNqzwQGgK3Uan2UbTuboKnHAEKzHNSSLxnxffeNI3OQIy60jOiDGVHlMEH5a/activities'
[ERROR] @teams/app.HttpPlugin For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
INFO: 52.123.134.92:0 - "POST /api/messages HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI applicationManually adding TENANT_ID= to .env immediately resolves the issue.
To Reproduce
Steps to reproduce the behavior:
- Create a new Python Quote Agent using the Microsoft 365 Agents Toolkit (v6.4.1) in VS Code.
- Sign in to Azure and Microsoft 365.
- Run Local Debug (Edge) to trigger provisioning.
- Inspect the generated root
.envfile → it containsCLIENT_ID,CLIENT_SECRET, andPORT, but noTENANT_ID. - Open Teams (via debug) and send a message to the bot.
- The bot receives the incoming activity but fails to send a reply.
- Terminal shows a 401 error from
smba.trafficmanager.net. - Add
TENANT_ID=<tenant-guid>manually to.env, restart debugging → bot replies successfully.
Expected behavior
The provisioning process should populate .env with all required identity fields for single-tenant authentication:
CLIENT_ID=<app-id>
CLIENT_SECRET=<secret-value>
TENANT_ID=<tenant-guid>
The bot should authenticate correctly and reply to messages without 401 errors during local debugging.
VS Code Extension Information (please complete the following information):
- OS: Win 11
- Extension Version: 6.4.1
CLI Information (please complete the following information):
- OS: Win 11
- Version 2.0.5
Additional context
The generated Entra app is single-tenant.
The Python SDK logs:
TENANT_ID is not set, assuming multi-tenant app
As soon as TENANT_ID is defined, the bot authenticates successfully and replies work.
This appears to be specific to the Python agent template environment provisioning