Azure multiple sites in virtual directories - azure

I have 3 asp.net core sites I need to deploy on the same domain (subdomains will not work with my SSL certificate).
https://my-site.com (Single page app)
https://my-site.com/api (Web api)
https://my-site.com/identity (Identity server)
When I deploy the api and identity projects, they work fine. However, when deploying the single page app, api and identity stop working.
The page cannot be displayed because an internal server error has occurred.
The error appears instantly so it's probably failing early on from startup I guess.
The single page app is working ok.
It seems the spa is interfering, I tried solutions from here to ignore the routes, but I get the same error.
I have tried the solution here to get a more descriptive error but to no avail.
Not sure where to go from here

The cause of the problem is that both the root application and the child app add the aspNetCore handler, causing the config system to blow up. You can see this by turning on Detailed error messages in the Azure Portal, and then finding the error page under D:\home\LogFiles\DetailedErrors. You'll see this error:
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'aspNetCore'
There are two approaches to solving this.
The first is to use a location tag to prevent inheritance. Specifically, change your root app's web.config from something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</configuration>
to something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</location>
</configuration>
The second approach is to remove the <handlers> section from the sub-application to avoid the duplication (as suggested in the doc under Configuration of sub-applications):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<aspNetCore processPath="dotnet" arguments=".\mySubApp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</configuration>

Related

ASP.NET Core 2.2 Site Warmup

I've migrated a .NET Framework 4.6 WebApi to .NETCore 2.2 and am having trouble getting the IIS ApplicationInitialization module to call my endpoints on a startup/slot swap/scale out.
I added a Web.Config like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\FR911.Api.Core.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="api/Warmup>
<add initializationPage="/" />
</applicationInitialization>
</system.webServer>
</location>
</configuration>
But if I keep the default hosting model of "inprocess" my warmup never gets called. If I change to "outofprocess" hosting, my warmup does get called before the swap is completed.
I think the issue below is likely related:
https://github.com/aspnet/AspNetCore/issues/8057
I'm not looking to just manually ping or otherwise hit my endpoint because I want the existing feature in the module that IIS is Azure won't actually swap the endpoints until the warmup requests have finished (thus initing EFCore etc.)
Has anyone had any luck getting this to work with the inprocess hosting model?

How can I resolve 500.19 on all my application?

I create .Net Core web application, I have to download .NET Core Runtime & Hosting Bundle but when I do that all my application get this error.
Even if I uninstall it, I still have the error.
When I try to run it in the command prompt with dotnet command it works but it doesn't work on IIS 10.
UPDATE :
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>

Can't publish ASP.NET Core anything to IIS Host

First I will like to disclose that this is my first attempt at publishing a .net core app to a live server. Everything I have done on the past has been on a local Host Server.
The problem I am having is that I can't get any kind of application even the temple created in VS2017 V15.7.2 to return anything other than 500 server error. I can't even get it to produce log files so I can try to figure out what is going on.
Here is my web.config file from the published server.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\BareBones.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
I can connect via FTP and see all of the files but, that is about it. Of course everything works great locally.
Any and all help is greatly appreciated.

Asp.Net core MVC application Windows Authentication in IIS

My Asp.Net Core mvc web application requires Windows Authentication. In developpement, on IIS Express, everything works fine thanks to this setting
launchSettings.json
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:61545/",
"sslPort": 0
}
}
When deploying to IIS, I get a blank page. The Request to my site get a 500 error code.
I tried to add this configuration to Startup.cs, as explained here , without success.
services.Configure<IISOptions>(options => {
options.ForwardWindowsAuthentication = true;
});
When I look into the authentication parameters directly in IIS, Windows Authentication is activated.
I found some post talking about a package called Microsoft.AspNetCore.Server.WebListener, others about implementing a custom Middleware. I can't imagine this basic feature needs that much effort to work. Am I missing something ?
launchSettings.json file is only used by VS. When you publish your app (or run without VS) launchSettings.json is not being used. When you run with IIS/IISExpress you just need to make sure that your web.config has correct settings. In your case the forwardWindowsAuthToken attribute in the web.config is missing or is set to false. It must be set to true for Windows Authentication to work. A sample web.config before publishing would look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/>
</system.webServer>
</configuration>
For me I had to add the line
services.AddAuthentication(IISDefaults.AuthenticationScheme);
in the method ConfigureServices in Startup.cs
My app allows both Windows and Anonymous users.
https://learn.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x#windows-authentication-httpsys--iisintegration
You need check web.config in your project dir. This settings was help me.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</configuration>

Run go web application on IIS

Is there a way to run Go web application on IIS?
I found a setting for azure but its not working on my dev machine
this is a web config for azure :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="d:\home\site\wwwroot\go\bin\go.exe"
arguments="run d:\home\site\wwwroot\server.go"
startupTimeLimit="60">
<environmentVariables>
<environmentVariable name="GOROOT" value="d:\home\site\wwwroot\go" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Your local IIS does not work simply because you need to install a separate component, called HttpPlatformHandler module,
https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-httpplatformhandler-module-for-iis-8/
http://www.iis.net/downloads/microsoft/httpplatformhandler
Reverse proxy or FastCGI were the older approaches which are no longer necessary with this new approach.
HttpPlatformHandler module doesn't work for me. I found this post by Sutean Rutjanalard on Medium very helpful, which use ASP.NET Core Module instead.
Basically, you need to create Application pool with "No Managed Code" as you do with a .net core app. And the following is the web.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\YourGoApp.exe" />
</system.webServer>
</configuration>

Resources