The first step in troubleshooting 500 errors is enabling Application Insights.
For basic Application Insights support, consult here https://docs.microsoft.com/en-us/azure/application-insights/app-insights-asp-net). The Bot Framework provides an additional level of Application Insights telemetry, but it will not be required for diagnosing HTTP 500 errors.
For basic Application Insights support, consult here. The Bot Framework provides an additional level of Application Insights telemetry, but it will not be required for diagnosing HTTP 500 errors.
The easiest method of analytizing HTTP staus code 500 errors is to begin with exceptions.
The following queries will tell you the most recent exceptions:
exceptions
| order by timestamp desc
| where type == "System.AccessViolationException"
| project timestamp, operation_Id, appName
From thie first query, select a few operation_Id
's and then look for more information:
let my_operation_id = "d298f1385197fd438b520e617d58f4fb";
let union_all = () {
union
(traces | where operation_Id == my_operation_id),
(customEvents | where operation_Id == my_operation_id),
(requests | where operation_Id == my_operation_id),
(dependencies | where operation_Id == my_operation_id),
(exceptions | where operation_Id == my_operation_id)
};
union_all
| order by timestamp desc
If you have only exceptions
, analyze the details and see if they correspond to anywhere in your code. If you only see exceptions coming from the Channel Connector (Microsoft.Bot.ChannelConnector
) then see Web API or Core to ensure that Application Insights is set up correctly and your code is logging events.
If you are receiving 500 errors and there are no further events within Application Insights from your bot, check the following:
Ensure bot runs locally
Make sure your bot runs locally first with the emulator.
Ensure configuration files are being copied
Make sure your .bot
configuration file and appsettings.json
file are being packaged correctly during the deployment process.
Validate Application Insights assemblies dependencies
During the deployment process, ensure the Application Insights assemblies:
- Microsoft.ApplicationInsights
- Microsoft.ApplicationInsights.TraceListener
- Microsoft.AI.Web
- Microsoft.AI.WebServer
- Microsoft.AI.ServeTelemetryChannel
- Microsoft.AI.PerfCounterCollector
- Microsoft.AI.DependencyCollector
- Microsoft.AI.Agent.Intercept
Verify appsettings.json
Within your appsettings.json
file ensure the Instrumentation Key is set.
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
},
"Console": {
"IncludeScopes": "true"
}
}
}
Verify .bot config file Ensure there's an Application Insights key.
{
"type": "appInsights",
"tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"subscriptionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"resourceGroup": "my resource group",
"name": "my appinsights name",
"serviceName": "my service name",
"instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"apiKeys": {},
"id": ""
},
Check logs ASP.Net contains logs at the server level that can be inspected.
Set up browser to watch logs Using a browser, navigate to the Azure Portal and navigate to your bot. Click on "App Service Settings"/"All App service settings" to expand and see all service settings.
Click on Monitoring/Diagnostics Logs, ensure logging "Application Logging (Filesystem)" is turned on. Be sure to click the "Save" button.
Click on Monitoring/Log Stream. Select "Web server logs" and ensure you see a message you are connected. It should look something like the following:
Connecting...
2018-11-14T17:24:51 Welcome, you are now connected to log-streaming service.
Keep this window open.
Set up browser to restart bot service Using a separate browser, navigate to the Azure Portal and navigate to your bot. Click on "App Service Settings"/"All App service settings" to expand and see all service settings.
Click on "Overview", and then click on the "Restart" button. It will prompt if you are sure, select yes.
Return to the first browser window watching the logs.
Verify that you are receiving new logs. If there is no activity, redeploy your bot. Switch to the "Application logs" and look for any errors.
If you are receiving 500 errors and there are no further events within Application Insights from your bot, check the following:
Ensure bot runs locally
Make sure your bot runs locally first with the emulator.
Ensure configuration files are being copied
Make sure your .bot
configuration file and appsettings.json
file are being packaged correctly during the deployment process.
Ensure Application Insights assemblies copied
During the deployment process, ensure the Application Insights assemblies are being copied. If you right click, publish your project, watch the output window even if it runs locally.
Verify appsettings.json
Within your appsettings.json
file ensure the Instrumentation Key is set.
{
"botFilePath": "mybot.bot",
"botFileSecret": "<my secret>",
"ApplicationInsights": {
"InstrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
Verify .bot config file Ensure there's an Application Insights key.
{
"type": "appInsights",
"tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"subscriptionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"resourceGroup": "my resource group",
"name": "my appinsights name",
"serviceName": "my service name",
"instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"apiKeys": {},
"id": ""
},
Check logs ASP.Net contains logs at the server level that can be inspected.
Set up browser to watch logs Using a browser, navigate to the Azure Portal and navigate to your bot. Click on "App Service Settings"/"All App service settings" to expand and see all service settings.
Click on Monitoring/Diagnostics Logs, ensure logging "Application Logging (Filesystem)" is turned on. Be sure to click the "Save" button.
Click on Monitoring/Log Stream. Select "Web server logs" and ensure you see a message you are connected. It should look something like the following:
Connecting...
2018-11-14T17:24:51 Welcome, you are now connected to log-streaming service.
Keep this window open.
Set up browser to restart bot service Using a separate browser, navigate to the Azure Portal and navigate to your bot. Click on "App Service Settings"/"All App service settings" to expand and see all service settings.
Click on "Overview", and then click on the "Restart" button. It will prompt if you are sure, select yes.
Return to the first browser window watching the logs.
Verify that you are receiving new logs. If there is no activity, redeploy your bot. Switch to the "Application logs" and look for any errors.