How do I manually deploy a .NET MVC app to AWS via Elastic Beanstalk - asp.net-mvc-4

I'm trying to deploy a simple Hello World ASP.NET MVC 4 app to an free tier EC2 instance using elastic beanstalk. I'm using Visual Web Developer Express (2010) which doesn't support the AWS Toolkit extensions, so how do I deploy the site without the extension?
It seems that with the Elastic Beanstalk web console, you can upload a file as a new applicaiton. But I can't figure out what's supposed to be in the file. Is it a zip containing a published mvc app? I tried that, and when navigating to the instance after it loaded it just displayed the IIS 8 logo. There's a sample zip on a walkthrough page, but it's an old ASP.NET page with 3 xml files in the root. I have no idea what to change in those files for MVC, .NET 4, Server 2012, or IIS 8. I can't find this information anywhere.
I tried creating some EC2 instances manually, remoting in and deploying the site myself. However the free Windows Server 2008 images don't have .NET 4. And the free Windows Server 2012 image doesn't have IIS... I couldn't figure out how to actually deploy my site.

The command line tool that's called by the AWS Toolkit extension can be used manually. Here is the documentation I found on deploying using this tool.
You have to publish your site as a Web Deploy Package in Visual Studio. Then use the tool located in Windows by default at
C:\Program Files (x86)\AWS Tools\Deployment Tool>awsdeploy.exe
You have to pass it a text file that contains the deployment configuration. There's a template for the file at
C:\Program Files (x86)\AWS Tools\Deployment Tool\Samples\ElasticBeanstalkDeploymentSample.txt
The first time I used the tool, deploying the package archive generated by Visual Studio, I still got the plain IIS 8 landing page. However, when I did an incremental deployment, which is done via an extracted version of the archive being pushed to the server, it worked fine.

Related

IIS + ASP.NET Core 6 + Hosting Pack resulting in default document/directory listing error

I'm attempting to get IIS to serve our ASP.NET 6 web application, but every time it complains of needing a default document. If I run the exe (kestrel) one it will serve it, but we want it to be hosted by IIS with the other components of the site.
I installed the 6.0.10 runtime w/ hosting package and these are the results when listing runtimes:
When looking at the site modules, I think it should have what is needed (think the AspNetCoreModuleV2 one handles the compiled routing scenario?):
Have rebooted the server and the app pool specifically, set to No Managed Code, and whenever I attempt to load the page at the localhost level, I get:
The views are compiled so I don't think I even need IIS to open views locally in any capacity.
Everything you've posted ticks off the major deployment steps for hosting a .NET 6 project on IIS:
Installed the .NET Core 6.0 Runtime Windows Hosting Bundle
Set up the IIS app pool with "No Managed Code"
Rebooted the server: "Have you turned it off and on again?"
After our exchange in the comments, the only thing that appeared to be missing is to use the .NET publish command; not the build command.
When deploying to IIS, you'll want to run the dotnet publish command and then deploy those artifacts to your IIS server. From the docs:
The dotnet publish command's output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution. It's the only officially supported way to prepare the application for deployment. Depending on the type of deployment that the project specifies, the hosting system may or may not have the .NET shared runtime installed on it.
You also may want to review: Publish .NET apps with the .NET CLI.

Deploy website to IIS from linux build agent

Problem description
I have a jenkins master that uses a linux build agent to build my ASP.NET Core websites using official MS linux docker containers.
I previously used a windows VM with the necessary tooling installed to build these projects and used MSDeploy.exe to deploy the sites to an IIS webserver. For this deployment I created a web package.
In my linux docker container I obviously can't use MSDeploy.exe.
Question
How can I savely deploy an ASP.NET Core website to an IIS webserver from a linux docker container?
MSDeploy.exe connects to the IIS using a local IIS Users credentials, shutsdown the app, replaces all files that are also present in the new package, so it not just replaces the files but also does some safety settings around the actual replacement.
Misc
I've found this question here, but unfortunately no real answer was found there.
Thanks in advance

Hotswap DLL issue to update ASP.NET Zero dotnet core based webapp using Azure DevOps CD

We are building a webapp for our clients using ASP.NETZero template built on dotnet core 3.1.x
I am trying to create release pipeline in Azure DevOps and facing issues while publishing the changes of build pipeline to IIS similar way I did for traditional MVC5 or MVC6 .NET Framework based webapps.
The self-hosted devops agent is running on a different machine than production server where the webapp is published and the agent service account has access of the shared path of the \\server\inetpub-sharedhostingdir only.
Traditoinally, Copy Files task could replace app DLLs and all other files but in .NETCore there is an error like below:
Then I found out that this is because of changes how .NET Core 3.1.x hosting works.
I also tried to use 'OutOfProcess' in the web.config in the webapp but still getting same error and then I found this SO post and DLL hotswap info given by #MindingData.
So, my current bat to overcome this issue is using remote powershell in CD; I can stop the webapp and publish the new artifact. But there is cost for this step, I have to stop the site and replace all the DLLs which may roughly takes 30 seconds.
The remote Azure DevOps agent does not have access to do so right now and yet we have to add firewall exceptions to do so.
I am wondering if there is any other efficient alternative to publish .NETCore 3.1.x webapp using AzureDevOps agent running on a remote server? (as access of production server is restricted and we cannot deploy the azure agent on production machine.)
Because of these issues currently I need to move all the DLLs in 'backup' directory manually to make the hosting directory empty and then if I run the pipeline of first image, the 'Copy Files To' runs successfully and publishes the app well.
Any suggestions for improving the CD in current environment?
You may try using 'app_offline.htm' file for graceful shutdown of your running application and after deployment you can easily remove that file using powershell command task.
This approach should work as you have access of the deployment directory of the remote server. Steps are mentioned on the SO post.

How to start a released Asp.net Core project?

I'm an asp.net developer and recently trying to archive asp.net-core.
Since it's quite new, I would like to ask, how do you launch a asp.net-core project in a Windows machine?
For normal asp.net, my approach is publishing the project using Visual Studio, bring everything to a Windows machine, use IIS to create a website and point the directory to my physical file.
How about a website that created by asp.net-core?
Do I need to install asp.net-core in server machine? (i don't prefer this)
What should I do with the published file? There are two folders generated after publishing the project:
netcoreapp1.0
PublishOutput
Well, you still can use the file system mechanism to publish an ASP.NET Core project from Visual Studio. But VS uses the dotnet CLI under the hood to do the same stuff. Usually you configure your deployment depending upon your hosting environment such as Windows Server and Linux Server.
For Windows Server
You have to install ASP.NET Core Module in order to publish on IIS successfully. This will also install .NET Core SDK. You can than have the advantages of SSL Terminations and others provided by IIS on Windows Server.
For Linux
You have to use the .NET Core SDK here as well for a published app to acquire the .NET Core runtime (This is why you get those 2 folders). You use Nginx or HAProxy to get all SSL Terminations, Port-Forwarding etc.

Using WebDeploy to create a server or site package

Using Web Deploy I am having problems creating a import server or site package. There appears to be no documentation on this. I am using Windows 7 and IIS 7.5, Web Deploy 2.0.
I want to be able to create a deployment package to include the App Pool and Website information so can be installed at the root of IIS without having to manually create anything.
The article Synchronizing by using Packages details the basic Web Deploy steps for creating a site or server package and then importing it on another server. If you want to package and deploy an IIS 7 Web server, you'd use the webServer provider. If you want to package and deploy an IIS 7 website, you'd use the appHostConfig provider.
To include the app pool in the operation, you'll need to use the -enableLink:AppPoolExtension switch, like this:
msdeploy -verb:sync -source:appHostConfig="Default Web Site" -dest:appHostConfig="Default Web Site",computerName=Server2 -enableLink:AppPoolExtension
For more on the enableLink setting, see Web Deploy Operation Settings. For more on link extensions, see the Web Deploy Link Extensions page.