Hello Chandana Kaza,
I understand you are hitting a generic 401 RestError (Unauthorized) when testing your Azure Bot, despite verifying that your App ID and Password appear correct.
The volunteer provided an excellent checklist of the most common "credential" errors. I would like to complement their answer by highlighting a configuration mismatch that is increasingly common with modern bots, specifically regarding the Bot Type.
A 401 Unauthorized in the Bot Framework doesn't just mean "wrong password." It often means "wrong identity type."
Recommened workaround steps:
Step 1: Verify "App Type" Configuration (Crucial)
If you created a Single Tenant bot in the Azure Portal (which is the new default), your code must explicitly define the Tenant ID and the App Type. If these are missing, the SDK defaults to "MultiTenant" behavior, which causes a token audience mismatch.
- For C# (.NET): Check your
appsettings.json.
"MicrosoftAppType": "SingleTenant",
"MicrosoftAppTenantId": "<YOUR_TENANT_ID>",
"MicrosoftAppId": "<YOUR_APP_ID>",
"MicrosoftAppPassword": "<YOUR_CLIENT_SECRET>"
- For Node.js / Python: Check your
.env file.
MicrosoftAppType=SingleTenant
MicrosoftAppTenantId=<YOUR_TENANT_ID>
MicrosoftAppId=<YOUR_APP_ID>
MicrosoftAppPassword=<YOUR_CLIENT_SECRET>
Step 2: Check App Service Logs (Diagnostic)
The "Test in Web Chat" UI hides the detailed error. To see the real reason for the 401, check the logs on the hosting server.
- Go to your App Service in the Azure Portal.
- Under Monitoring, select Log Stream.
- Try the "Test in Web Chat" again.
- Watch the logs for a specific error message like
Audience validation failed or The token issuer is incorrect. This confirms the "App Type" mismatch mentioned in Step 1.
Step 3: Validate the Endpoint
Ensure the Messaging Endpoint in your Azure Bot resource settings is exactly https://<your-app-name>.azurewebsites.net/api/messages.
- Common Mistake: Missing the
/api/messages suffix.
- Common Mistake: Using
http instead of https.
Official Documentation References
Please let us know if adding the MicrosoftAppType and TenantId resolves the issue. If this answer helps, kindly "Accept the answer" to support the community.