This is my second thread about this issue and I tried every suggestion provided in the last thread about this. The URL to the last thread is here: Bot works in Bot Framework Emulator on local computer, but not after it's deployed to Microsoft Azure - HTTP status code NotFound.
I followed the exact directions at https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-deploy-az-cli?view=azure-bot-service-4.0&tabs=newrg.
After following these instructions involving Azure CLI, I had three resource types that were created under my Azure subscription ID: Bot Channels Registration, App Service, and App Service Plan.
Unfortunately, when I enter a message in the “Test in Web Chat” window under “Bot Management” for the “Bot Channels Registration” resource, I received a message back saying “couldn’t send retry.”
When I go to channels under “Bot Management” for the “Bot Channels Registration” resource, click “Issues” under “Health”, I see this message: "There was an error sending this message to your bot: HTTP status code InternalServerError."
Here are some additional details that were highlighted in the last thread. I definitely took them into consideration as you’ll read below.
Before entering this code, a “.deployment” file was created in the bot’s directory and a zip file was subsequently created that contained the “.deployment” file in it: az webapp deployment source config-zip --resource-group "" --name "" --src "code.zip"
I went to this link, and I saw 21 .dll files listed on that page under the “WWWROOT” section: https:/.scm.azurewebsites.net/dev/wwwroot/
I went to this URL (https://.scm.azurewebsites.net/dev/wwwroot/:vs.output), pressed run and I did not see anything unusual on the right side of the screen under “Output”. It says “200.0 OK” at the last message under “Output” after “Click on http://.azurewebsites.net to open your site 2019-06-27T17:52:04 PID[32228] Information Sending response.” When I click on the “http://.azurewebsites.net” link, a new tab opens and I see this message at the top: " Bot Started."
I also tried publishing from Visual Studio.
When I tried publishing from Visual Studio, I followed the directions at this page: https://docs.microsoft.com/en-us/visualstudio/deployment/deploying-applications-services-and-components?view=vs-2019
I created a new Azure App Service, chose the correct subscription and resource group, turned off Application Insights since that’s not needed right now, and then pressed “Create.”
I then pressed “Publish.”
Next, I created a Bot Channels Registration and added the destination URL from the edit link at the top of “Publish” screen in Visual Studio. That bot did not work when testing in the web chat.
Creating a web app bot in Azure doesn’t help at this stage since a default echo or basic bot template seems required for the creation.
Just to elaborate again, the bot I’m attempting to test in Azure works perfectly in the bot emulator after running it in Visual Studio. Somewhere in the publishing/deployment stage to Azure lies an issue. What can we do to resolve this issue?
UPDATE:
I followed Matt Stannett's advice, who added a comment under this thread.
I went to Monitoring > App Service Logs and enabled Application Logging (Filesystem) as well as Detailed error messages and Failed request tracing.
Next, I went to Monitoring > Log stream tab. I kept this tab opened and loaded up Web Chat in another tab to see real-time logs.
I converted the html code to the pdf format and read the results.
Here is the top-level information regarding the error message:
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.
Most likely causes:
Things you can try:
Detailed Error Information:
Error Code: 0x00000000
Module: AspNetCoreModule
Handler: aspNetCore
Notification: ExecuteRequestHandler
Logon Method: Anonymous
Logon User: Anonymous
More Information:
This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error. View more information »
Just a quick clarification here, since there appears to be two distinct issues:
Your instance of the Bot Framework Emulator seems to have issues - I would recommend uninstalling it then getting the latest version from here.
Your bot does not work in production - in order to debug the production channel locally you will need to ensure that the app id and app password in your app settings are populated with the values from Azure, then you should be able to follow the rest of the instructions below to chat in the production channel (Teams, WebChat, DirectLine etc NOT in the emulator) and have the production channel run against your local code so that you can set breakpoints and inspect variables to debug where the issue is.
Instructions based on guides here and here:
Debugging techniques
- Ensure that ngrok is installed.
- Open the solution in Visual Studio.
- Start debugging in Visual Studio.
- Note down the port in the localhost address for the web page that is opened (this should be 3978).
- Navigate into the directory where you extracted ngrok.
- Type cmd into the address bar and press enter to open a new command prompt window.
- Create a publicly accessible URL that tunnels all http traffic on a specified port to your machine:
- ngrok http 3978 --host-header=localhost
- Copy the https forwarding URL.
- This should be in the form of https://(characters-here).ngrok.io.
- Keep the command prompt window running ngrok open because once it is closed the URL will no longer be accessible.
- Stop debugging.
- In the Azure Portal open the Web App Bot resource.
- Go to Bot management > Settings > Configuration and copy the URL into the description field so that it is saved somewhere.
- Replace the everthing in the endpoint URL textbox before /api/messages with the ngrok URL.
- The final URL should be in the form of https://(ngrok-url)/api/messages.
- Click Save (you have click outside of the text box for the Save button to be enabled).
- Go to App Service > Settings > Configuration and note down the value for MicrosoftAppId and MicrosoftAppPassword.
- In The Azure portal, under the Configuration > Application settings tab of the App Service Visual copy the values for the MicrosoftAppId and MicrosoftAppPassword entries into the matching entries in your appsettings.json file (since you will be running a production endpoint against local code you need to have all of the relevant keys set).
- Save your changes in Visual Studio.
- Start debugging in Visual Studio.
- Open Test in Web Chat in Azure.
- Test the bot functionality.
- You should hit any breakpoints that you've set in the code.
CLEAN UP STEPS - IMPORTANT!!!
- Restore the Messaging endpoint URL for the Web App Bot in Azure to it's original value AND save the change.
- Undo/revert any changes to the appsettings.json file.
- Close the command prompt window running ngrok.
- Close the Bot Framework Emulator
User contributions licensed under CC BY-SA 3.0