how to configure a single-tenant Azure Bot with a single-tenant App Registration using Python Bot Framework SDK

Jaspreet Singh 0 Reputation points
2025-12-04T06:09:59.62+00:00

I created a new single-tenant Azure AD app and a single-tenant bot because multi-tenant support is being removed/deprecated. But when I try to connect the bot using the Python Bot Framework SDK, I always get the same error:

“The application does not exist in your tenant.”

I tried adding auth_tenant_id in the Bot Adapter settings, but the SDK throws:

“undefined parameter: auth_tenant_id”

It seems like the Python Bot Framework SDK does not support this parameter.

Can you please help me understand how to correctly configure a single-tenant bot with a single-tenant app registration in Python so that authentication works?
code

import os
import asyncio
from flask import Flask, request, Response
from botbuilder.core import BotFrameworkAdapterSettings, BotFrameworkAdapter, TurnContext
from botbuilder.schema import Activity
from botframework.connector.auth import MicrosoftAppCredentials

# Get credentials from environment
APP_ID = os.environ.get("MicrosoftAppId")
APP_PASSWORD = os.environ.get("MicrosoftAppPassword")


# Configure adapter for multi-tenant authentication
settings = BotFrameworkAdapterSettings(
    app_id=APP_ID,
    app_password=APP_PASSWORD
)
adapter = BotFrameworkAdapter(settings)

# Create Flask app
app = Flask(__name__)


async def on_turn(turn_context: TurnContext):
    """Handle incoming activities"""
    if turn_context.activity.type == "message":
        await turn_context.send_activity(f"You said: {turn_context.activity.text}")
    elif turn_context.activity.type == "conversationUpdate":
        await turn_context.send_activity("👋 Bot connected successfully!")


@app.route("/api/messages", methods=["POST"])
def messages():
    """Handle messages endpoint"""
    if "application/json" not in request.headers.get("Content-Type", ""):
        return Response("Unsupported Media Type", status=415)

    activity = Activity().deserialize(request.json)
    auth_header = request.headers.get("Authorization", "")

    async def process():
        await adapter.process_activity(activity, auth_header, on_turn)

    # Run async function in event loop
    asyncio.run(process())
    return Response(status=200)


@app.route("/", methods=["GET"])
def health_check():
    """Health check endpoint"""
    return "Bot is running."


if __name__ == "__main__":
    port = int(os.environ.get("PORT", 3978))
    app.run(host="0.0.0.0", port=port)

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-04T06:10:13.9133333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To configure a single-tenant Azure Bot with a single-tenant App Registration using the Python Bot Framework SDK, you need to ensure that your bot's configuration aligns with the requirements for single-tenant applications. Here are the steps you should follow:

    1. App Registration: Make sure your Azure AD app registration is set to single-tenant. You can verify this in the Azure portal under the app registration settings.
    2. Configuration Values: In your bot's configuration, you need to set the following values:
      • MicrosoftAppType: Set this to SingleTenant.
      • MicrosoftAppId: This should be the Application (client) ID of your Azure AD app.
      • MicrosoftAppPassword: This is the client secret generated for your app.
      • MicrosoftAppTenantId: Set this to your Azure AD tenant ID.
    3. Update Your Code: In your Python code, ensure you are using the correct environment variables for the app ID and password. You can set the tenant ID in the BotFrameworkAdapterSettings if needed, but it seems you are encountering issues with auth_tenant_id. The Python SDK might not support this parameter directly, so you should focus on ensuring that your app registration is properly configured as a single-tenant app.
    4. Error Handling: If you encounter the error "The application does not exist in your tenant," it typically indicates that the app ID being used does not match the app registered in your Azure AD tenant. Double-check that the MicrosoftAppId in your environment variables matches the Application ID of your registered app.
    5. Testing: After making these changes, test your bot again to see if the authentication works correctly. If you continue to face issues, ensure that the bot is properly registered in the Azure Bot Service and that the necessary permissions are granted in Azure AD.

    By following these steps, you should be able to configure your single-tenant bot correctly and resolve the authentication issues you are facing.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.