Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetCore 2.2 Angular template does not publish to Azure #2125

Closed
andreslon opened this issue Dec 10, 2018 · 32 comments
Closed

NetCore 2.2 Angular template does not publish to Azure #2125

andreslon opened this issue Dec 10, 2018 · 32 comments
Assignees

Comments

@andreslon
Copy link

NetCore 2.2 Angular template does not work to publish in Azure

Steps:

  1. Create a netcore 2.2 angular template project.
  2. Give right click in the project--> Publish
  3. Publish with any azure profile
  4. Launch the browser with the published app

You can see in the browser:
"The page cannot be displayed because an internal server error has occurred."

The Angular versión is not problem, I tried with the 5,6,7 versión.
With the netcore 2.1 angular template correctly does works.

Allow the application on azure log displays the following log:

Log stream in Azure

<title>IIS Detailed Error - 500.21 - Internal Server Error</title> <style type="text/css"> </style>

HTTP Error 500.21 - Internal Server Error

Handler "aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list

Most likely causes:

  • Managed handler is used; however, ASP.NET is not installed or is not installed completely.
  • There is a typographical error in the configuration for the handler module list.
  • During application initialization, either the application initialization feature has set skipManagedModules to true, or a rewrite rule is setting a URL that maps to a managed handler and is also setting SKIP_MANAGED_MODULES=1.

Things you can try:

  • Install ASP.NET if you are using managed handler.
  • Ensure that the handler module's name is specified correctly. Module names are case-sensitive and use the format modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule".
  • Ensure that any application initialization rewrite rules set SKIP_MANAGED_MODULE=0 when setting a URL that maps to a managed handler (such as .aspx, for example.)
  • As an alternative, ensure that application initialization rewrite rules map the request to an unmanaged handler (for example, to an .htm file, which is mapped to the StaticFileHandler.)

Detailed Error Information:

Module   IIS Web Core
Notification   ExecuteRequestHandler
Handler   aspNetCore
Error Code   0x8007000d
Requested URL   https://WebApplication120181209043315:80/favicon.ico
Physical Path   D:\home\site\wwwroot\favicon.ico
Logon Method   Anonymous
Logon User   Anonymous

More Information:

IIS core does not recognize the module.

View more information »

Microsoft Knowledge Base Articles:

@cocoke
Copy link

cocoke commented Dec 10, 2018

I'm facing the same problem 😞

@arnvanhoutte
Copy link

I had the same problem on our local server. We had to upgrade the ASP.NET Core hosting bundle to fix it: https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-2.2.0-windows-hosting-bundle-installer

@fdbva
Copy link

fdbva commented Dec 10, 2018

I had the same problem even with the Self-Contained deploy option. Shouldn't this option not require something external?

@andreslon andreslon reopened this Dec 10, 2018
@krajek
Copy link

krajek commented Dec 10, 2018

I got the same error message when I upgraded my app from 2.1 to 2.2. The error happens only on AppService deployment, locally everything works fine.

If I manually change AspNetCoreModuleV2 to AspNetCoreModule in web.config it starts working again.

@ghost
Copy link

ghost commented Dec 10, 2018

I have the same error. For me, this occurs for any ASP.NET Core app targeting 2.2 when publishing to azure. I have tried both upgrading an existing application and creating a new application targeting 2.2

I've followed the guide here: https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22 and have added <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> but this doesn't solve the problem

As with @krajek, when I change AspNetCoreModuleV2 to AspNetCoreModule the app starts working again.

@MarcoRossignoli
Copy link
Member

MarcoRossignoli commented Dec 10, 2018

Same issue. Confirm @krajek's trick.

@arnvanhoutte
Copy link

@AitroSoftware Adding <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> the Javascript SPA services. https://github.com/aspnet/JavaScriptServices/issues/1786

@MartinZikmund
Copy link

MartinZikmund commented Dec 10, 2018

After long digging, I fixed this by installing the .NET Core 2.2 Runtime extension on Azure (which supports the new AspNetCoreModuleV2) - go to your app service, select Extensions in the left pane and then find the .NET Core 2.2. Runtime in the list and install it.

Update - no, didn't help again... Run for a while, but I guess that was cache

@cocoke
Copy link

cocoke commented Dec 10, 2018

I've followed the guide here: https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22 and have added <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> but this doesn't solve the problem

As with @krajek, when I change AspNetCoreModuleV2 to AspNetCoreModule the app starts working again.

This is working, thanks a lot 😃

@ghost
Copy link

ghost commented Dec 10, 2018

@MartinZikmund

After long digging, I fixed this by installing the .NET Core 2.2 Runtime extension on Azure (which supports the new AspNetCoreModuleV2) - go to your app service, select Extensions in the left pane and then find the .NET Core 2.2. Runtime in the list and install it.

This has worked for me

@krajek
Copy link

krajek commented Dec 10, 2018

Extension worked for me to(x86 version). Thanks a lot, @MartinZikmund.

Very unfortunate that the migration guide does not mention it (https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio) :-(.

@andreslon
Copy link
Author

I got the same error message when I upgraded my app from 2.1 to 2.2. The error happens only on AppService deployment, locally everything works fine.

If I manually change AspNetCoreModuleV2 to AspNetCoreModule in web.config it starts working again.

How do you changed the web.config, if this does not exists in the net core project?

@MartinZikmund
Copy link

MartinZikmund commented Dec 10, 2018

I think the problems have to do with what is mentioned in the ASP.NET Core 2.2 announcement post:

The .NET Core 2.2 SDK, runtime, and updated ASP.NET Core IIS Module are in the process of being deployed to Azure App Service regions around the world. We expect this to be completed before the end of December 2018.
Some regions may receive the updated runtime before the updated ASP.NET Core IIS Module (ANCM), which is required by default for projects targeting ASP.NET Core 2.2. It’s also a requirement for the new in-process hosting feature. If you receive startup errors after deploying to Azure App Service, try configuring your project to use the existing version of ANCM by setting the AspNetCoreModule property to the value “AspNetCoreModule”, e.g.:

<PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

Once the target region has been updated with the latest ANCM version, you can remove that property altogether and redeploy the application to have it switch to using the new ANCM.

So any erros will probably be connected with the fact that either the new module is not yet available in the region or the new runtime is not there yet.

@viktors-telle
Copy link

viktors-telle commented Dec 11, 2018

@MartinZikmund

After long digging, I fixed this by installing the .NET Core 2.2 Runtime extension on Azure (which supports the new AspNetCoreModuleV2) - go to your app service, select Extensions in the left pane and then find the .NET Core 2.2. Runtime in the list and install it.

Thanks! I have installed x64 extension and it helped. I have also added the following two lines to the .csproj file:

  <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
  <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

@ghost
Copy link

ghost commented Dec 11, 2018

@MartinZikmund
Thanks
I figured it had to be something to do with 2.2 not being available in certain regions, but I couldn't find the announcement anywhere

Can confirm that adding the following two lines to the .csproj file has worked

<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

@Eilon
Copy link
Member

Eilon commented Dec 13, 2018

@muratg / @shirhatti - do you know the latest on 2.2 running in Azure App Services?

@muratg
Copy link

muratg commented Dec 13, 2018

@Eilon We do not know the current status, but last I heard from App Service folks is that they expect to be done on all public regions by the end of next week.

@karelz
Copy link
Member

karelz commented Dec 13, 2018

See #2120 (comment)

@DrakeLambert
Copy link

Extension worked for me to(x86 version). Thanks a lot, @MartinZikmund.

Very unfortunate that the migration guide does not mention it (https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio) :-(.

I had to do the same, use the x86 version. Now it's working

@MarcoRossignoli
Copy link
Member

@karelz
Copy link
Member

karelz commented Dec 26, 2018

Thanks @MarcoRossignoli!
Closing as I assume it answers all the questions. If not, please let me know what remains and I can reopen. Thanks!

@karelz karelz closed this as completed Dec 26, 2018
@fdbva
Copy link

fdbva commented Dec 26, 2018

Thanks @MarcoRossignoli!
Closing as I assume it answers all the questions. If not, please let me know what remains and I can reopen. Thanks!

I think it doesn't answer this question:

I had the same problem even with the Self-Contained deploy option. Shouldn't this option not require something external?

Changing the AspNetCoreModuleV2 in web.config seems like an work around and not the root of the problem if I want to use the Self-Contained option. Does it have any unintended effect? Am I using an old version of AspNetCoreModule by doing that?

Thanks!

@karelz
Copy link
Member

karelz commented Dec 26, 2018

@fdbva looks like there is multiple questions - I have harder time to understand what your remaining question is about (as I am not expert on ASP.NET Core). Would it be more appropariate to ask the question on ASP.NET Core repo, or am I missing something?

@fdbva
Copy link

fdbva commented Dec 27, 2018

@karelz
I don't know how to answer that. The question makes sense, but the whole issue from the beginning was ASP.NET Core, I think.
I didn't check, but I think the Self-Contained option exists for .NET Core as well. I could deploy as Self-Contained in ASP.NET Core 2.1, but in 2.2 it doesn't work.
We had to decide to not use the Self-Contained because of our deadlines, so I probably won't create a new issue, but I think the root of the problem still exists.

@MarcoRossignoli
Copy link
Member

@fdbva are you getting same issue?Can you share your detailed error log?

@fdbva
Copy link

fdbva commented Dec 27, 2018

I get the same error from the first post. Now we have the 2.2 Hosting Bundle installed and it'll be hard to recreate because we need the IT team to change things like that here.

<title>IIS Detailed Error - 500.21 - Internal Server Error</title> <style type="text/css"> </style>

HTTP Error 500.21 - Internal Server Error

Handler "aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list

This solution by krajek worked:

If I manually change AspNetCoreModuleV2 to AspNetCoreModule in web.config it starts working again.

But it feels like a work around, I suppose that when it's fixed, I wouldn't need to do something like that. I could just deploy with the Self-Contained option without having the Hosting Bundle installed.

I'll explain the scenario so it'll make more sense, maybe I understood something wrong. We wanted the Self-Contained option because we will give our deploy files to our client and we didn't want to have to ask them to install a new ASP.NET Core Hosting Bundle every time the version was upgraded, we wanted that independence from their IT team.

@MarcoRossignoli
Copy link
Member

MarcoRossignoli commented Dec 27, 2018

@fdbva I try to explain better, sorry for my poor english.

I'll explain the scenario so it'll make more sense, maybe I understood something wrong. We wanted the Self-Contained option because we will give our deploy files to our client and we didn't want to have to ask them to install a new ASP.NET Core Hosting Bundle every time the version was upgraded, we wanted that independence from their IT team.

AFIK you cannot run asp.net core inside IIS without "ASP.NET Core Hosting Bundle". This bundle allows asp.net core to run with/inside IIS, it implements so called handlers, IIS receive http request from network and "forward" these to asp.net engine (https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2)

The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either:

* Host an ASP.NET Core app inside of the IIS worker process (w3wp.exe), called the in-process hosting model.
* Forward web requests to a backend ASP.NET Core app running the Kestrel server, called the out-of-process hosting model.

"ASP.NET Core Module" is inside "ASP.NET Core Hosting Bundle".
Until 2.1 version asp.net core uses reverse proxy with kestrel https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/?view=aspnetcore-2.2&tabs=windows#kestrel to communicate with IIS(second point of above statements)
Since 2.2 version we have new type of "hosting" called In-Process(for performance reason), now our asp.net core app can run inside IIS "standard hosting process" called w3wp.exe.
aspNetCoreModuleV2 is the new handler that allow In-Process hosting and it's installed with new "ASP.NET Core Hosting Bundle"(not rolled on all Azure sites, see announcement I linked above).
And this is the asp.net core+IIS part.
Now Self-Contained is unrelated to asp.net core+iis but it's a way to build/deploy every .net app(console, winforms, wpf, asp). I mean it's a runtime features. Self-Contained allows to deploy .net app without install "runtime" machine wide(under classic program files folders), with Self-Contained we have all useful binaries in "publish" folder and we can run it https://docs.microsoft.com/en-us/dotnet/core/deploying/#self-contained-deployments-scd, basically you deploy "your lib code+full runtime".
To run asp.net core Self-Contained app you need a new aspNetCoreModuleV2 at least for guide https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2&WT.mc_id=-blog-scottha#configuration-with-webconfig.

We wanted the Self-Contained option because we will give our deploy files to our client and we didn't want to have to ask them to install a new ASP.NET Core Hosting Bundle every time the version was upgraded, we wanted that independence from their IT team.

In conclusion you depend on hosting bundle to run app inside IIS, Self-Contained is used for other purposes.

But it feels like a work around

It's not a bug workaround, the "issue" is that publish .net 2.2 asp.net core app generates web.config that uses new handler aspNetCoreModuleV2, but not all servers on Azure are up-to-date. So move to aspNetCoreModule until rolling is finished it's ok to me.

Extra: https://blogs.msdn.microsoft.com/webdev/2018/12/04/asp-net-core-2-2-available-today/ check "Availability in Azure App Service" paragraph Some regions may receive the updated runtime before the updated ASP.NET Core IIS Module (ANCM), which is required by default for projects targeting ASP.NET Core 2.2. It’s also a requirement for the new in-process hosting feature.

@fdbva
Copy link

fdbva commented Dec 27, 2018

@MarcoRossignoli
Thanks for explaining, I think I understand now. I thought the Self-Contained option would work on ASP.NET Core, but it's .NET Core only if you don't want any external dependencies because IIS still need the Hosting Bundle installed.

ps.: my english is not very good either hehehe

@MarcoRossignoli
Copy link
Member

Self-Contained option would work on ASP.NET Core, but it's .NET Core

Yes, asp.net core is composed by some simple assemblies that run on .NET Core runtime. The same of ASP.NET MVC for .NET Desktop(i.e. classic 4.7.2). But web site needs a server and we've IIS that is "decoupled" from runtimes it hosts, so this "bundle" is the bridge between environments. Self-Contained works for asp.net core(it's .net core) but we need iis to expose our web site.

@fdbva
Copy link

fdbva commented Dec 27, 2018

And with the In process option, would that paired with Self-Contained void the necessity of the Hosting Bundle? Or at least in the future, would that be possible or make sense?

ps.: is it ok to discuss like this in an issue? And again, thanks for the explanations =D

@MarcoRossignoli
Copy link
Member

MarcoRossignoli commented Dec 27, 2018

And with the In process option, would that paired with Self-Contained void the necessity of the Hosting Bundle? Or at least in the future, would that be possible or make sense?

No Self-Contained is a runtime features not tied up with asp.net core hosting scenarios(at least today FWIK), I mean .Net runtime lives without asp.net core libs. Hosting Bundle is the piece of code that allow IIS to "launch and run" our asp.net core app. You could ask on asp.net channel on gitter aspnet/home for infos.
Info: https://docs.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-2.2?view=aspnetcore-2.2#iis-in-process-hosting In-process hosting provides performance and diagnostic gains when running with IIS.

@MarcoRossignoli
Copy link
Member

FYI aspnet/Announcements#339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests