1
votes

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:

  • IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
  • IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
  • IIS was not able to process configuration for the Web site or application.
  • The authenticated user does not have permission to use this DLL.
  • The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

Things you can try:

  • Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
  • Check the event logs to see if any additional information was logged.
  • Verify the permissions for the DLL.
  • Install the .NET Extensibility feature if the request is mapped to a managed handler.
  • Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

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 »

1
I would recommend turning on Application Insights for your bot because it will help with finding the underlaying error. Alternatively on your App Service you could go to Monitoring > App Service Logs and enable Application Logging (Filesystem) as well as Detailed error messages and Failed request tracing. Then you can go to Monitoring > Log stream tab, once this tab has opened you should load up Web Chat in another tab and you will be able to see real-time logs. Once you get the error message out of there, you should update your question.Matt Stannett
Thank you very much, Matt. I followed those steps and included the details from the error message in the log stream section at the bottom of my original thread.DataExaminer555
Hmmm, no more insight from that. You will have to remotely debug webchat to see what it going on. I have outlined this process in my answer here under the "Debugging techniques" section - the area in yellow is mainly what you're interested in.Matt Stannett
Hi, Matt. Thank you so much for directing me to those steps. i have a question about two of the steps. At the step, "In Visual Studio Copy the appId and appPassword key value pairs from the Production endpoint in the .bot file to the Development endpoint," I would enter the "MicrosoftAppId" and ""MicrosoftAppPassword" in the appsettings.json file and no where else? I'm just trying to make sure. Also at the "Ensure that the endpoint value for the Development endpoint is set to the localhost URL (localhost:3978/api/messages )," where exactly would I change the endpoint value?DataExaminer555
Additionally, as of today, when I run ANY bot in Visual Studio...this is what happens when I try to test the bot in the Bot Emulator using the settings I had before making your suggested configuration changes: A browser tab launches with "localhost:3978" as the URL. I see a text at the top of this tab that says “QnA Prompting Bot Started.” That’s the bot template I deployed to Azure, but I see this message regardless of any bot I run in Visual Studio to test in the bot emulator. Every bot I try to test in the bot emulator is unresponsive—probably because of an endpoint setting.DataExaminer555

1 Answers

1
votes

Just a quick clarification here, since there appears to be two distinct issues:

  1. Your instance of the Bot Framework Emulator seems to have issues - I would recommend uninstalling it then getting the latest version from here.

  2. 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 the bot is working locally.
  • Check the Log stream or log files via Kudu under Development Tools > Advanced tools for your App Service. You can also turn on Application logs under Monitoring App Service logs for your App Service then view the log stream via the Log stream section of your App Service while you test your bot in Web Chat in another tab/window.
  • Check that the App Settings entries exist and are correct (password, app id etc).
  • 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