locked
ASP.NET Core 3 Web Application, Azure App Service, and a ANCM In-Process Handler Load Failure RRS feed

  • Question

  • User-143167003 posted

    I am really new to working with all of these different technologies so pardon me if I am missing some knowledge. In any event, I have a bit of ASP.NET MVC architecture under my belt but I have yet to really grasp the framework, tooling, or what the scaffolding of any given ASP-type web application is doing.

    tl;dr;

    At the moment, I am working on hosting an ASP.NET CORE (3) web application with Azure and I have setup a plan for the App Service. The project is very simplistic and I just want to get it to run from Azure so it can field requests. The problem, is that it builds fine on my machine but when I publish it to Azure I am met with an HTTP Error 500.0 denoting that I am probably missing one of these requirements:

    • The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
    • The in process request handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the application.
    • ANCM could not find dotnet.

    I think the issue boils down to that I am not doing something with IIS properly either on my local machine or in the cloud.
    I will change the logging level of the application as suggested in error message I am getting when I hit the web page AND I have configured a service for Application Insights on Azure so hopefully that will help my case. I have tried a number of StackOverflow suggestions regarding web configs and such but those just regenerate on build.

    Any help would be so, so, greatly appreciated as this is a portfolio piece for me and I spent a fair amount of time working on it - I think I may have just missed something basic. Thank you.


    Friday, February 15, 2019 3:19 AM

All replies

  • User1289604957 posted

    Hello,

    .NET Core 3 is not available yet for Azure App Service. It is compatible with .NET Core <g class="gr_ gr_131 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="131" data-gr-id="131">2.2 :</g> https://github.com/Azure/app-service-announcements/issues/151

    Best Regards,

    Maher Jendoubi

    Friday, February 15, 2019 11:12 AM
  • User-143167003 posted

    Excellent, thank you Maher!!

    Friday, February 15, 2019 3:08 PM
  • User-143167003 posted

    I configured some extensions for the App Service in Azure and I was able to find the .NET core runtime for 3.0 for both 32 and 64-bit architectures. I have those installed in the App Service...shouldn't that be resolving this matter? I think the problem is actually stemming from an incorrect configuration of IIS.

    https://imgur.com/a/7M146vq

    Friday, February 15, 2019 3:50 PM
  • User1289604957 posted

    Would you please share your Startup.cs?

    Best Regards,

    Maher

    Friday, February 15, 2019 7:02 PM
  • User1289604957 posted

    Assuming the Azure App Service extension is working.

    If the app calls UseKestrel by calling CreateDefaultBuilder in the CreateWebHostBuilder method of the Programclass, call ConfigureKestrel to configure Kestrel server instead of UseKestrel in order to avoid conflicts with the IIS in-process hosting model:

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .ConfigureKestrel((context, options) =>
            {
                // Set properties and call methods on options
            });

    If the app doesn't call CreateDefaultBuilder and builds the host manually in the Program class, call UseKestrel before calling ConfigureKestrel:

    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseKestrel()
            .UseIISIntegration()
            .UseStartup<Startup>()
            .ConfigureKestrel((context, options) =>
            {
                // Set properties and call methods on options
            })
            .Build();
    
        host.Run();
    }

    Best Regards,

    Maher

    Saturday, February 16, 2019 8:18 AM
  • User-143167003 posted
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.CookiePolicy;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Http;
    using Microsoft.AspNetCore.HttpsPolicy;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.FileProviders;
    using Microsoft.Extensions.Logging;
    
    namespace RazorPortfolio
    {
    
        public class Startup
        {
            public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args);
    
            private readonly ILogger<Startup> _logger;
    
            public Startup(IConfiguration configuration,
                           ILogger<Startup> logger, IHostingEnvironment env)
            {
                _logger = logger;
    
                //Configuration = configuration;
    
                var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: false)
            .AddEnvironmentVariables();
                Configuration = builder.Build();
    
    
                // configuration.GetSection()
            }
    
    
            public IConfiguration Configuration { get; }
    
            // This method gets called by the runtime. Use this method to add services to the container.
            public void ConfigureServices(IServiceCollection services)
            {
                services.Configure<CookiePolicyOptions>(options =>
                {
                    // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                    options.CheckConsentNeeded = context => false;
                    options.MinimumSameSitePolicy = SameSiteMode.None;
                    //options.AutomaticAuthentication = false;
    
    
                    // options.HttpOnly = HttpOnlyPolicy.None;
                    // var security = options.Secure == CookieSecurePolicy.SameAsRequest;
    
                });
    
                //services.AddDirectoryBrowser();
    
    
                services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app,
                                  IHostingEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                    _logger.LogInformation("This should be visible...somewhere?");
    
                  
                    // app.
                    // env.WebRootFileProvider.GetDirectoryContents("")  
    
                    /*System.Diagnostics.Debug.WriteLine(env.WebRootPath.Length);*/
    
                    app.UseDirectoryBrowser(new DirectoryBrowserOptions
                    {
                        FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "images")),
                        RequestPath = "/MyImages"
                    });
                }
    
                else
                {
                    app.UseExceptionHandler("/Error");
    
                    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                    app.UseHsts();
                }
    
                app.Build();
    
                //Redirects unsecure HTTP requests to HTTPs
                app.UseHttpsRedirection();
    app.UseStaticFiles(); //This is our own implementation for files underneath the Programming and Art folders, respectively app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "Pages", "Programming")), RequestPath = "/Programming" }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "Pages", "Art")), RequestPath = "/Art" }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "Pages", "CurrentEvents")), RequestPath = "/CurrentEvents" });
    app.UseCookiePolicy(); app.UseMvc(); } } }

    Here is the entirety of my Startup.cs file...I must be missing something here with an IIS configuration.

    Tuesday, February 19, 2019 7:44 PM
  • User283571144 posted

    Hi evanricard,

    As far as I know, if you want to deploy ASP.NET Core preview versions in Azure app service, you should modify the publish settings to self-contained, then your application could work well.

    More details ,you could refer to below steps:

    1.Install the preview site extension for X86

    2.Deploy the app self-contained.

    At last, you could click the publish button, it will host the asp.net core 3.0 application well.

    Best Regards,

    Brando

    Monday, February 25, 2019 5:52 AM