Search code examples
c#azurebotframeworkazure-language-understandingazure-bot-service

Error (502) Bad Gateway: When trying to access chatbot deployed on Azure using WebChat channel


I am developing a chatbot using Microsoft Botframework. Bot works fine when I run it locally with emulator. How ever when I deploy it on Azure as a bot service and try to access it using webchat channel it start giving 502 error.I am tried following steps to deploy it.

  • Created a resource group in Azure
  • Created a Service Plan in azure
  • open url https://dev.botframework.com/ and under My bots menu item clicked "Create a bot" button

enter image description here

  • "Create a bot" page takes me to Azure Bot Service page

enter image description here

  • On Azure Bot service page I select "Web App Bot"

enter image description here

  • On clicking "Create" Azure ask me few details such as Bot Name, Resource group, App Name etc and creates a Bot
  • In this new Bot when I go to "Test in Web Chat" and type something it gives me a response back.
  • Now I took app id and secret key from Settings and add it to web config file.
  • Now I publish my bot from Visual Studio selecting new bot service as app service
  • Publishing is successful
  • Now when I try to access my bot in Test in Web Chat window in Azure,messages start getting failed enter image description here
  • I have taken the web chat link from channel section and paste it on html page and updated secret key for web chat
  • Now when I send a message I start getting (502) bad gateway error in console. enter image description here

I have deployed bots in the past as well but at that I was using dev.botframework.com for configuring bots.

This is first time I am trying to deploy it on Azure Bot service and don't know what am I missing here.

Can someone help me with this?


Solution

  • The error (HTTP status code 502) indicates that either the bot returned an error or the request timed out. You can go to the bot's Channels blade and click the "Issues" link for the affected channel to check the information about errors, or use Application Insights to trace error details.

    Besides, if possible, you can create a new simple bot application with Bot Builder SDK in visual studio and upgrade the Bot Builder SDK for project, then deploy it to corresponding Azure app service with the following steps&diagrams, and check if new bot application can work with bot service.

    • After you created it, two resources: Web App Bot and App Service are created in your resource group. Something like below:

      enter image description here

    • To deploy your bot application developed by Bot Builder SDK in visual studio, you can choose and publish to that corresponding app service. enter image description here

      enter image description here

      Note: you can check “Remove additional files at destination” option when you deploy the bot application to your Azure web app

      enter image description here