microsoft / CloudAdoptionFramework

Code samples and extended documentation to support the guidance provided in the Microsoft Cloud Adoption Framework
https://aka.ms/CAF
Creative Commons Attribution 4.0 International
854 stars 614 forks source link

Assistance with hosting AzNamingTool as standalone in IIS #164

Closed mcdonamw closed 1 year ago

mcdonamw commented 1 year ago

The instructions are quite light in terms of hosting this as a standalone application.

I'm trying to get this running in IIS. I've created a new application under default website. I pulled the AzNamingFolder out of CloudAdoptionFramework-master\ready\ and stored it within inetpub and mapped the application to it. Is this the correct "source" folder? I assume so since it has the .sln/.csproj files.

When I try to access http://localhost/aznamingtool I just get a 403, no default document error page.

So clearly I don't know what I'm doing. Is there any other in depth documentation for how to set this up? Some tutorial videos somewhere? All I can find is using this as a docker container which is not an option for me.

To this point I've installed IIS, with .net 4.5, as well as .net 6 runtime and asp.net 6. Created the .net application. Not sure where else to go from here. Do I need to compile this first?

BryanSoltis commented 1 year ago

Hi @mcdonamw,

Thank you for writing. You just need to publish .NEWT application to run it in IIS. The /ready/AzNamingTool fodler is the correct file to publish from.

This guide should provide the details. Specifically, look at the "Publish and deploy the app" section of the guide.

https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-6.0&tabs=visual-studio

The site is a .NET 6 application so you will likely need to install the .NET Hosting bundle (also documented in the above guide).

Hope this helps!

mcdonamw commented 1 year ago

Appreciate the response. Prior to it I somehow managed to fumble my way through VS Code and noticed it ran when I did a run, so I published the code and pointed IIS to it. Now it appears like something is happening, but the browser is just spinning for over 5 min now.

EDIT: After looking at that link again to double check it appears I have done everything required, but it simply will not load. Guess I'll have to go hit some IIS/.NET boards.

BryanSoltis commented 1 year ago

It's possible there is something out of configuration somewhere. Here is what I just did to test the process:

mcdonamw commented 1 year ago

That's essentially what I did, though I downloaded the .net Core 6 ASP.NET hosting bundle and the Core 6 Runtime. Did you install any additional/non-default options when adding the IIS role? I added the .NET 4.5 and ASP.Net with it.

I was digging into the event logs and noticed .NET/web errors citing "Unable to determine https port". I did not create an https binding as the docker container just ran http so figured would be the same here. With that said, with a packet capture I did see I am getting a 307 temporary redirect to the https version of the site. Any clues where that's coming from? Is that in the code or is that in IIS?

I went ahead and added an https binding, and now I get a prompt regarding the self-signed cert I generated but attempting to continue now leads to a "ERR_HTTP2_PROTOCOL_ERROR" error. Sheesh.

I'm using Windows Server 2022 btw.

mcdonamw commented 1 year ago

So I'm trying this again per your instructions but I cannot build the app. I need the .NET SDK. Are there other pre-reqs not listed above?

mcdonamw commented 1 year ago

Outside of installing the SDK so I can build the project, I completed everything else as outlined above. I'm back to the site just spinning endlessly. The event log again shows the following.

Category: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware
EventId: 3
SpanId: 80a213f3bfb0ba92
TraceId: 1fd2750a2a10c0927cd05df2e243679c
ParentId: 0000000000000000
RequestId: 40000008-0001-fd00-b63f-84710c7967bb
RequestPath: /

Failed to determine the https port for redirect.
mcdonamw commented 1 year ago

I'm probably chasing my tail on the above error. Per the following this could be expected if no HTTPS ports are found in my configuration (none are) and it says while the error will generate, HTTP should continue to process normally.

https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/6.0/middleware-ambiguous-https-ports-exception

There's also an error about the w3wp.exe process crashing.

With that said, it finally stopped spinning and ultimately ended with an error "ERR_CONNECTION_RESET". the global HTTPERR log states

2023-05-25 20:11:32 ::1%0 61840 ::1%0 80 HTTP/1.1 GET / - - - 2 Connection_Abandoned_By_ReqQueue AzureNamingTool TCP

I'm at a loss here. With that said I understand this is likely nothing to do with the ANT but the system itself so this isn't the forum for support. I appreciate your help thus far though.

mcdonamw commented 1 year ago

AHA! It's working. The crash of w3wp.exe/coreclr.dll lead me down a road of permissions for the App Pool on the website directory. I had added it but with read/execute only. I changed it to modify permissions, and the site came up instantly. Ugh, really wish all this was documented LOL.

mcdonamw commented 1 year ago

This can be closed as I was able to work through and get this up and running. Thanks for your help @BryanSoltis

BryanSoltis commented 1 year ago

Glad you got it running! Definitely let us know if you run into any more issues.

Bryan