Bot在本地计算机上的Bot Framework Emulator中工作,但在将其部署到Microsoft Azure后无法使用:"HTTP状态代码未找到" (第二线程) [英] Bot works in Bot Framework Emulator on local computer, but not after it's deployed to Microsoft Azure: "HTTP status code NotFound" (2nd Thread)

查看:132
本文介绍了Bot在本地计算机上的Bot Framework Emulator中工作,但在将其部署到Microsoft Azure后无法使用:"HTTP状态代码未找到" (第二线程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我关于此问题的第二个话题,我尝试了最后一个话题中提供的所有建议.到最后一个线程的URL在这里:

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.

我在按照涉及Azure CLI的这些说明进行操作后,我在Azure订阅ID下创建了三种资源类型:Bot Channels Registration,App Service和App Service Plan.

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.

不幸的是,当我在"Bot频道注册"资源的"Bot管理"下的在Web聊天中测试"窗口中输入消息时,我收到一条消息,说无法发送重试."

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."

当我转到"Bot管理"下的"Bot频道注册"资源中的频道时,单击运行状况"下的问题",我看到此消息:将此消息发送到您的机器人时出错:HTTP状态代码InternalServerError."

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.

在输入此代码之前,在漫游器目录中创建了一个".deployment"文件,随后创建了一个在其中包含".deployment"文件的zip文件: az webapp部署源config-zip --resource-group" --name" --src"code.zip"

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"

我转到了此链接,并且在该页面的"WWWROOT"部分下看到了21个.dll文件: https:/.scm.azurewebsites.net/dev/wwwroot/

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/

我转到了该URL(https://.scm.azurewebsites.net/dev/wwwroot/:vs.output),按了run键,但在屏幕右侧输出"下没有发现任何异常. .它在单击http://.azurewebsites.net打开您的站点2019-06-27T17:52:04 PID [32228]信息发送响应"之后,在输出"下的最后一条消息中显示"200.0 OK".当我单击"http://.azurewebsites.net"链接时,将打开一个新标签,并且在顶部看到以下消息:机器人启动."

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."

我还尝试了从Visual Studio发布.

I also tried publishing from Visual Studio.

当我尝试从Visual Studio发布时,我遵循了此页面上的指示: https://docs.microsoft.com/zh-CN/visualstudio/deployment/deploying-applications-services-and-components?view=vs-2019

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

我创建了一个新的Azure App Service,选择了正确的订阅和资源组,由于目前不需要,因此关闭了Application Insights,然后按创建".

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."

然后我按下发布".

接下来,我创建了一个Bot频道注册,并从Visual Studio中发布"屏幕顶部的编辑链接中添加了目标URL.在网络聊天中进行测试时,该机器人无法正常工作.

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.

在当前阶段在Azure中创建网络应用程序漫游器无济于事,因为创建时似乎需要默认的回显或基本漫游器模板.

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.

再次详细说明一下,我尝试在Azure中测试的bot在Visual Studio中运行后,可以在该bot模拟器中完美运行.在发布/部署阶段到Azure的某个地方存在问题.我们该怎么做才能解决这个问题?

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?

更新:

我遵循了Matt Stannett的建议,后者在此主题下添加了评论.

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.

接下来,我转到监视">日志流"选项卡.我一直打开此选项卡,并在另一个选项卡中加载了Web Chat,以查看实时日志.

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.

我将html代码转换为pdf格式,并读取了结果.

I converted the html code to the pdf format and read the results.

以下是有关错误消息的顶级信息:

Here is the top-level information regarding the error message:

HTTP错误500.0-内部服务器错误

HTTP Error 500.0 - Internal Server Error

由于发生内部服务器错误,因此无法显示该页面.

The page cannot be displayed because an internal server error has occurred.

最可能的原因:

    IIS已收到请求;但是,在执行过程中发生了内部错误 处理请求.此错误的根本原因取决于 在哪个模块上处理请求以及 发生此错误时的工作进程.
  • IIS无法访问网站的web.config文件或 应用.如果设置了NTFS权限,可能会发生这种情况 错误地.
  • IIS无法处理网站或应用程序的配置.
  • 经过身份验证的用户没有使用此DLL的权限.
  • 该请求已映射到托管处理程序,但.NET可扩展性 功能未安装.
  • 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.

您可以尝试的操作:

  • 确保web.config文件的NTFS权限正确 并允许访问Web服务器的计算机帐户.
  • 检查事件日志以查看是否记录了任何其他信息.
  • 验证DLL的权限.
  • 如果请求已映射到托管处理程序,则安装.NET可扩展性功能.
  • 创建跟踪规则以跟踪对此HTTP状态代码的失败请求.有关为失败的请求创建跟踪规则的更多信息,请单击此处.
  • 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.

详细的错误信息:

错误代码:0x00000000

Error Code: 0x00000000

模块:AspNetCoreModule

Module: AspNetCoreModule

处理程序:aspNetCore

Handler: aspNetCore

通知:ExecuteRequestHandler

Notification: ExecuteRequestHandler

登录方式:匿名

登录用户:匿名

更多信息:

此错误表示处理请求时出现问题. Web服务器已接收到该请求,但是在处理过程中发生了致命错误,导致500错误.

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:

  1. 您的Bot Framework Emulator实例似乎有问题-我建议先将其卸载,然后从此处.

您的机器人无法在生产环境中使用-为了在本地调试生产渠道,您需要确保您的应用程序设置中的应用程序ID和应用程序密码填充了Azure的值,然后您应该能够按照下面的其余说明在生产渠道中进行聊天(模拟器中的团队,WebChat,DirectLine等 NOT ),并使生产渠道针对您的本地代码运行,以便您可以设置断点并检查变量以调试问题所在.

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.

基于指南的说明此处 调试技术

  • 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).
  • 确保已安装ngrok.
  • 在Visual Studio中打开解决方案.
  • 在Visual Studio中开始调试.
  • 记下已打开网页的本地主机地址中的端口(应为3978).
  • 导航到您提取ngrok的目录.
  • 在地址栏中输入cmd,然后按Enter键以打开一个新的命令提示符窗口.
  • 创建一个可公开访问的URL,该URL会将指定端口上的所有http流量通过隧道传输到您的计算机:
  • ngrok http 3978 --host-header = localhost
  • 复制https转发URL.
  • 这应采用 https://(characters-here).ngrok.io .
  • 使运行ngrok的命令提示符窗口保持打开状态,因为一旦关闭,URL将不再可访问.
  • 停止调试.
  • 在Azure门户中,打开Web App Bot资源.
  • 转到Bot管理>设置>配置,然后将该URL复制到说明字段中,以便将其保存在某处.
  • 将/api/messages之前的端点URL文本框中的所有内容替换为ngrok URL.
  • 最终URL的格式应为 https://(ngrok-url)/api/消息.
  • 单击保存"(您已在文本框外单击以启用保存"按钮).
  • 转到应用程序服务">设置">配置",并记下MicrosoftAppId和MicrosoftAppPassword的值.
  • 在Azure门户中,App Service Visual的配置">应用程序设置"选项卡下,将MicrosoftAppId和MicrosoftAppPassword条目的值复制到appsettings.json文件中的匹配条目中(因为您将针对本地运行生产终结点代码,您需要设置所有相关密钥).
  • 在Visual Studio中保存您的更改.
  • 在Visual Studio中开始调试.
  • 在Azure的Web聊天中打开测试.
  • 测试漫游器功能.
  • 应该击中您在代码中设置的任何断点.
  • 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.

清理步骤-重要!

  • 将Azure中Web App Bot的消息传递终结点URL恢复为原始值并保存更改.
  • 撤消/还原对appsettings.json文件的所有更改.
  • 关闭运行ngrok的命令提示符窗口.
  • 关闭Bot Framework仿真器
  • 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

这篇关于Bot在本地计算机上的Bot Framework Emulator中工作,但在将其部署到Microsoft Azure后无法使用:"HTTP状态代码未找到" (第二线程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆