将机器人部署到 Azure 后,在 Web Chat 中测试键入消息 returns "Not found" HTTP 状态代码

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

我在 azure 门户中创建了一个 Web App Bot 服务,下载它,修改它,在 Bot 模拟器上测试它,它可以工作,然后将它部署回 Azure。 Bot Channels Registration 和 App Service 在 Azure 中创建。我预计原始 Web App Bot 的行为会更新,但当我在 Web Chat 中测试时,它仍然是带有航班预订示例的默认机器人。当我在“网络聊天测试”中为 Bot Channels Registration 资源键入消息时,我得到 "couldn't send retry" 和 "There was an error sending this message to your bot. HTTP status code: not found"

我尝试更改 Microsoft App ID 和密码以及消息传递端点以匹配我在本地测试时使用的那些。我还尝试通过 Visual Studio 发布,而不是将 Azure CLI 与 link https://www.c-sharpcorner.com/article/publish-your-bot-to-microsoft-azure/ 一起使用,但他们使用的应用程序不是 .net 核心,它没有部署在我的项目中。我用尽了所有 link 仍然没有找到解决方案。

通过Visual Studio

部署

that tutorial 的基础很好,尽管超级 out-of-date 而不是官方 tutorial/doc。由于你是从 Azure 下载你的机器人,你唯一需要做的发布是:

  1. Right-click 您的项目 Visual Studio,Select 发布
  2. 点击新建
  3. 应用服务 > Select 现有
  4. Select 您的应用服务
  5. 点击确定,它将发布

通过 Azure CLI 部署

关注the Deployment Docs

部署故障排除

老实说,当部署失败时,我发现最好从头开始新的部署,确保我完全按照每个步骤进行操作。这通常比尝试排除故障和修复失败的部署更快。话虽这么说,以下是您提到的每个问题可能存在的问题:

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

可能的问题:

  1. 部署实际上并不成功
  2. 您部署到错误的资源组

确保您在 latest Azure CLI 上,然后重试。

有时,如果您通过 Visual Studio 发布,您 right-click 项目,select 发布,编辑,设置,然后在 "File Publish Options" 下,勾选 "Remove additional files at destination"。请注意,这可能不是您遇到的问题,因为您使用的是较新的机器人。

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"

这通常意味着端点错误。在您的 Web App Bot > Settings 中,确保 Messaging Endpoint 是:

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

用户尝试通过 AZ CLI 进行部署但他们缺少此步骤:

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.

App Registration Panel 中的应用程序中找到正确的 MicrosoftAppId 和 MicrosoftAppPassword。如果您需要新的 MicrosoftAppPassword,请打开您的应用程序注册,转到证书和机密,然后单击新建客户端机密。一定要复制它,因为如果你离开页面,你将无法再次查看。

这些需要在三个地方设置:

  1. appsettings.json 文件(或 .env 节点)。
  2. Azure 门户 > 资源组 > 应用服务 > 配置
  3. 测试时在模拟器中

我已经在这里回答了:

但为了方便起见,我也会将答案粘贴在这里。

What solved my problem was changing the Protocol Setting of the App Service. IF you've deployed your bot using Bot Composer, in the resource group you will find 2 App Services -- one with a 'qna' suffix and the other without. Choose the one without the 'qna' suffix.

Select the App Service --> TLS/SSL settings --> HTTPS Only --> On

pic rel below: Image for reference