Search code examples
c#azurevisual-studio-2017botframework

Test in Web Chat typing message returns "Not found" HTTP status code after deploying bot to Azure


I created a Web App Bot service in azure portal, downloaded it, modified it, tested it on Bot emulator which works, and deployed it back to Azure. A Bot Channels Registration and a App Service are created in Azure. I expected the original Web App Bot's behavior to update but when I tested in Web Chat it still the default bot with the flight booking example. When I typed a message in Test in Web Chat for the Bot Channels Registration resource I get "couldn't send retry" and "There was an error sending this message to your bot. HTTP status code: not found"

I have tried changing the Microsoft App ID and password and messaging endpoint to match the ones I have used when I tested locally. I also tried publishing via Visual Studio instead of using Azure CLI with this link https://www.c-sharpcorner.com/article/publish-your-bot-to-microsoft-azure/ but the application they used is not .net core and it does not deploy in my project. I have exhausted every link and still have not found a solution.


Solution

  • Deploying via Visual Studio

    The basics of that tutorial are fine, despite being super out-of-date and not an official tutorial/doc. Since you downloaded your bot from Azure, the only thing you need to do Publish is:

    1. Right-click your Project in Visual Studio, Select Publish
    2. Click New
    3. App Service > Select Existing
    4. Select Your App Service
    5. Hit OK and it will Publish

    Deploying via Azure CLI

    Follow the Deployment Docs

    Troubleshooting Your Deployment

    Honestly, when a deployment fails, I find it best to start a new deployment from scratch, ensuring that I follow each step exactly. This is often quicker than trying to troubleshoot and fix a failed deployment. That being said, here's what's likely wrong with each issue you mentioned:

    I expected the original Web App Bot's behavior to update but when I tested in Web Chat it still the default bot with the flight booking example

    Possible issues:

    1. The deployment wasn't actually successful
    2. You deployed to the wrong Resource Group

    Ensure you're on the latest Azure CLI and try again.

    Sometimes, if you're publishing via Visual Studio, you right-click the Project, select Publish, edit, Settings, then under "File Publish Options", check "Remove additional files at destination". Note, this is likely not the issue you're having as you're using a newer bot.

    When I typed a message in Test in Web Chat for the Bot Channels Registration resource I get "couldn't send retry" and "There was an error sending this message to your bot. HTTP status code: not found"

    This usually means that the endpoint is wrong. In your Web App Bot > Settings, ensure the Messaging Endpoint is:

    https://<yourAppService>.azurewebsites.net/api/messages

    I answered a similar question where the user tried to deploy via AZ CLI and they were missing this step:

    az bot prepare-deploy --lang Csharp --code-dir "." --proj-file-path "MyBot.csproj"

    I have tried changing the Microsoft App ID and password and messaging endpoint to match the ones I have used when I tested locally.

    The correct MicrosoftAppId and MicrosoftAppPassword are found in your app in the App Registration Panel. If you need a new MicrosoftAppPassword, open your App Registration, go to Certificates and secrets, and click New Client Secret. Be sure to copy it, because if you leave the page, you cannot view it again.

    These need to be set in three places:

    1. The appsettings.json file (or .env for Node).
    2. Azure Portal > Resource Group > App Service > Configuration
    3. In Emulator when testing