2

So I've been creating a chatbot using the Bot Framework SDK v4. I've been testing it locally and it works fine with the Bot Emulator.

I want to be able to host it on Azure and access it remotely but when I publish it and the browser opens up my azurewebsites.net webpage, the page just displays an error saying An error occurred while starting the application.

When I look at the console to inspect the error, there are 2 requests for resources that fail to load:

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

This is my first time using or publishing something to Azure so I'm not overly familiar with it. As far as I know, there aren't any files in my local directory under those names, and I'm not sure how to rectify the issue.

And idea's as to whats causing this? I can provide more code if needed.

EDIT More information I've gathered from Application Insights and Kudu.

When trying to send a message to the bot in Azure using the 'Test Web App​', I'm getting these exceptions thrown:

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()

Furthermore, from checking the logs in Kudu, the html has a description of what the cause might be:

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

Mark O'Hare
  • 147
  • 1
  • 3
  • 17
  • Are you using Node.js or .NET? Could you have a look at the error logs using Kudu. (App Service -> Advanced Tools in Azure or just go to [webapp-name].scm.azurewebsites.net. – Mick Dec 02 '18 at 10:15
  • If you are running a Node.js bot, have a look at your current Node version in Kudu. If you want to upgrade your Node version add a new application setting 'WEBSITE_NODE_DEFAULT_VERSION' with the value 8.5.0 for example. – Mick Dec 02 '18 at 10:16
  • I'm using .NET. Are the error logs under 'Log Streaming' in Kudu? – Mark O'Hare Dec 02 '18 at 10:42
  • Have a look at [Enable diagnostics logging for web apps in Azure App Service](https://learn.microsoft.com/en-us/azure/app-service/web-sites-enable-diagnostic-log) – Mick Dec 02 '18 at 10:44
  • I have diagnostic logging enabled and I'm currently installing the azure cli to download the logs. Is there anything specific I should be looking for or should I just check the http errors? – Mark O'Hare Dec 02 '18 at 11:08
  • 1
    I've updated my question with more information if that helps – Mark O'Hare Dec 02 '18 at 11:31

1 Answers1

2
System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\Chatbot.bot'.

How did you deploy your project to Azure? It looks like your 'Chatbot.bot' file didn't get deployed to the wwwroot, which is required and can include bot specific settings like Application ID and password.

The answer in a related StackOverflow question describes how to upload the .bot file after a deployment in Visual Studio, but you could also just upload the file manually to the wwwroot.

Mick
  • 2,946
  • 14
  • 19
  • I published it through Visual Studio by just right clicking my project and selecting the 'Publish' option, which walks you through setting services up on azure. I'll try uploading it manually – Mark O'Hare Dec 02 '18 at 11:41
  • This is [a known 'bug'](https://github.com/Microsoft/botbuilder-dotnet/issues/1004) / configuration mistake in some bot samples, which should be fixed in next release of the Azure portal. You can fix this manually by having a look at the answer linked above. No need to upload it manually. – Mick Dec 02 '18 at 11:43
  • 1
    Ok, thank you for the help! I just checked the properties of my .bot file and they were set to 'Do not copy' so this may be the issue that was raised in the answer you linked. I let you know if it works – Mark O'Hare Dec 02 '18 at 11:45
  • 3
    That sorted it out! Thank you for the help Mick, you've made my day! Also found out I hadn't put settings in for my production environment either.. but I fixed that. Thanks again! – Mark O'Hare Dec 02 '18 at 11:56