Getting error 500.30 when I try to run my asp.net core 3.1 app on azure

0

I have an app that is asp.net core 3.1 connected to a sql server database and a secrets file. I can run this all locally, and it works.

I published my app to Azure, migrated my db there, and created a Key Vault. All of those say they were successful.

When I try to publish my app, it says "Configured" for the db and the Key vault, and the app deploys successfully. However, when it redirects me to the website where my app should be running, I get a 500.30 error.

These are the errors I was getting yesterday: (I'm not sure what I'm getting now, because I cannot seem to find the page on Azure where I found these, and I've spent about 20 minutes looking for it)

Error #1

Application: w3wp.exe
CoreCLR Version: 4.700.20.26901
.NET Core Version: 3.1.6
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'implementationInstance')
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton[TService](IServiceCollection services, TService implementationInstance)
   at RecipeCompendiumTool.Startup.ConfigureServices(IServiceCollection services) in C:\Users\julie\source\repos\RecipeCompendiumTool\Startup.cs:line 44
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at RecipeCompendiumTool.Program.Main(String[] args) in C:\Users\julie\source\repos\RecipeCompendiumTool\Program.cs:line 16

Error #2

Application '/LM/W3SVC/312799001/ROOT' with physical root 'D:\home\site\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'implementationInstance')
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton[TService](IServiceCollection services, TService implementationInstance)
   at RecipeCompendiumTool.Startup.ConfigureServices(IServiceCollection services) in C:\Users\julie\source\repos\RecipeCompendiumTool\Startup.cs:line 44
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at RecipeCompendiumTool.Program.Main(String[] args) in C:\Users\julie\source\repos\RecipeCompendiumTool\Program.cs:line 16

Process Id: 6904.
File Version: 13.1.20169.6. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 62c098bc170f50feca15916e81cb7f321ffc52ff

Error #3

Application '/LM/W3SVC/312799001/ROOT' with physical root 'D:\home\site\wwwroot\' failed to load coreclr. Exception message:
CLR worker thread exited prematurely
Process Id: 6904.
File Version: 13.1.20169.6. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 62c098bc170f50feca15916e81cb7f321ffc52ff

My Startup.cs file

        public IConfiguration Configuration { get; }
        public IWebHostEnvironment Environment { get; }

        public Startup(IConfiguration configuration, IWebHostEnvironment environment)
        {
            Configuration = configuration;
            Environment = environment;
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(IISServerDefaults.AuthenticationScheme);

            services.AddControllersWithViews();
            services.AddRazorPages();

            services.Configure<FormOptions>(x => x.ValueCountLimit = 1000000000);

            services.AddSingleton<IEmailConfiguration>(Configuration.GetSection("EmailConfiguration").Get<EmailConfiguration>());
            services.AddTransient<IEmailService, EmailService>();
            services.AddSingleton<IEmailSender, EmailSender>();

            services.AddControllers().AddNewtonsoftJson(options =>
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            services.AddIdentity<RecipeCompendiumToolUser, IdentityRole>()
                .AddEntityFrameworkStores<RecipeCompendiumToolContext>()
                .AddDefaultTokenProviders();

            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0)
                .AddRazorPagesOptions(options =>
                {
                    options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");
                    options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");
                });


            if (Environment.IsDevelopment())
            {
                services.AddRazorPages().AddRazorRuntimeCompilation();

                services.AddDbContext<RecipeCompendiumToolContext>(options =>
                        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            }
            else if (Environment.IsStaging())
            {
                services.AddRazorPages().AddRazorRuntimeCompilation();

                services.AddDbContext<RecipeCompendiumToolContext>(options =>
                        options.UseSqlServer(Configuration.GetConnectionString("TestConnection")));
            }
            else if (Environment.IsProduction())
            {
                services.AddDbContext<RecipeCompendiumToolContext>(options =>
                        options.UseSqlServer(Configuration.GetConnectionString("ProdConnection")));
            }
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)//, RecipeCompendiumToolSeedData seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // TODO: 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.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            //seeder.InitializeSeedData();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
                endpoints.MapControllers();
            });
        }
    }
asp.net-core
azure-web-app-service
asked on Stack Overflow Aug 21, 2020 by steelerose

1 Answer

0

Fixed - there may have been other issues, but if you're deploying to Azure with a db, make sure your db's firewall settings have "Allow Azure services and resources to access this server" set to YES.

answered on Stack Overflow Aug 23, 2020 by steelerose

User contributions licensed under CC BY-SA 3.0