发布到 Azure 的 Bot 出现内部服务器错误
Bot published to Azure getting Internal Server Error
所以我一直在使用 Bot Framework SDK v4 创建聊天机器人。我一直在本地对其进行测试,它与 Bot Emulator 配合使用时效果很好。
我希望能够在 Azure 上托管它并远程访问它,但是当我发布它并且浏览器打开我的 azurewebsites.net 网页时,该页面只显示一条错误消息 An启动应用程序时出错。
当我查看控制台检查错误时,有 2 个资源请求加载失败:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) /favicon.ico:1
Failed to load resource: the server responded with a status of 500 (Internal Server Error) (index):1
这是我第一次使用 Azure 或向 Azure 发布某些东西,所以我对它不是很熟悉。据我所知,我的本地目录中没有这些名称下的任何文件,我不确定如何解决这个问题。
请问这是什么原因造成的?如果需要,我可以提供更多代码。
编辑
我从 Application Insights 和 Kudu 收集了更多信息。
尝试使用 'Test Web App' 向 Azure 中的机器人发送消息时,我抛出了这些异常:
System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\Chatbot.bot'.
File name: 'D:\home\site\wwwroot\Chatbot.bot'
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.File.OpenText(String path)
at Microsoft.Bot.Configuration.BotConfiguration.<LoadAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Configuration.BotConfiguration.Load(String file, String secret)
at ChatBotProject.Startup.<>c__DisplayClass6_0.<ConfigureServices>b__0(BotFrameworkOptions options) in C:\Users\Marko\Documents\Project\ChatBotProject\ChatBotProject\Startup.cs:line 47
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
at Microsoft.Bot.Builder.Integration.AspNet.Core.ApplicationBuilderExtensions.UseBotFramework(IApplicationBuilder applicationBuilder)
at ChatBotProject.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\Users\Marko\Documents\Project\ChatBotProject\ChatBotProject\Startup.cs:line 122
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass3_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
此外,通过检查 Kudu 中的日志,html 描述了可能的原因:
<fieldset>
<h4>Most likely causes:</h4>
<ul>
<li>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.</li>
<li>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.</li>
<li>IIS was not able to process configuration for the Web site or application.</li>
<li>The authenticated user does not have permission to use this DLL.</li>
<li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li>
</ul>
System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\Chatbot.bot'.
您是如何将项目部署到 Azure 的?看起来你的 'Chatbot.bot' 文件没有部署到 wwwroot,这是必需的,可以包括 bot 特定设置,如应用程序 ID 和密码。
相关 Whosebug 问题中的 描述了如何在 Visual Studio 部署后上传 .bot 文件,但您也可以手动将文件上传到 wwwroot。
所以我一直在使用 Bot Framework SDK v4 创建聊天机器人。我一直在本地对其进行测试,它与 Bot Emulator 配合使用时效果很好。
我希望能够在 Azure 上托管它并远程访问它,但是当我发布它并且浏览器打开我的 azurewebsites.net 网页时,该页面只显示一条错误消息 An启动应用程序时出错。
当我查看控制台检查错误时,有 2 个资源请求加载失败:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) /favicon.ico:1
Failed to load resource: the server responded with a status of 500 (Internal Server Error) (index):1
这是我第一次使用 Azure 或向 Azure 发布某些东西,所以我对它不是很熟悉。据我所知,我的本地目录中没有这些名称下的任何文件,我不确定如何解决这个问题。
请问这是什么原因造成的?如果需要,我可以提供更多代码。
编辑 我从 Application Insights 和 Kudu 收集了更多信息。
尝试使用 'Test Web App' 向 Azure 中的机器人发送消息时,我抛出了这些异常:
System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\Chatbot.bot'.
File name: 'D:\home\site\wwwroot\Chatbot.bot'
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.File.OpenText(String path)
at Microsoft.Bot.Configuration.BotConfiguration.<LoadAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Configuration.BotConfiguration.Load(String file, String secret)
at ChatBotProject.Startup.<>c__DisplayClass6_0.<ConfigureServices>b__0(BotFrameworkOptions options) in C:\Users\Marko\Documents\Project\ChatBotProject\ChatBotProject\Startup.cs:line 47
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
at Microsoft.Bot.Builder.Integration.AspNet.Core.ApplicationBuilderExtensions.UseBotFramework(IApplicationBuilder applicationBuilder)
at ChatBotProject.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\Users\Marko\Documents\Project\ChatBotProject\ChatBotProject\Startup.cs:line 122
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass3_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
此外,通过检查 Kudu 中的日志,html 描述了可能的原因:
<fieldset>
<h4>Most likely causes:</h4>
<ul>
<li>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.</li>
<li>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.</li>
<li>IIS was not able to process configuration for the Web site or application.</li>
<li>The authenticated user does not have permission to use this DLL.</li>
<li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li>
</ul>
System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\Chatbot.bot'.
您是如何将项目部署到 Azure 的?看起来你的 'Chatbot.bot' 文件没有部署到 wwwroot,这是必需的,可以包括 bot 特定设置,如应用程序 ID 和密码。
相关 Whosebug 问题中的