Deploying ASP.NET Classic Framework Apps Using Azure DevOps Release Manager
Hence, in today's post I will show how to deploy a site to an on-prem Windows 2016 server running IIS from a cloud hosted instance of Azure DevOps.
In my last post, I showed you how to create a simple YAML based build configuration that can be utilized in Azure Pipelines. Now, it would be nice to deploy the site to a server and take the next leap in the process. Hence, in today's post I will show how to deploy the previous sample site to an on-prem Windows 2016 server running IIS from a cloud hosted instance of Azure DevOps.
Requirements
Before you get started, you should make sure that you have the latest version of the following server and framework configuration:
- Windows Server 2016 Standard (https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016)
- .NET Framework 4.7.2 installed on the 2016 server, in order to run the ASP.NET Web App (https://dotnet.microsoft.com/download/dotnet-framework-runtime)
You can setup a lab on a virtual machine and follow along.
The Project Code
I will use the same code sample from last time, to keep things simple. That is, the code is a very simple front end website (ASP.NET 4.7.2) that will run in IIS. Here is the website launched from Visual Studio and running locally:
Setup Deployment Group With Agent
The first step will be to head over to the Azure DevOps project where the source code is hosted and then locate the build. There are a few ways that an initial release can be set up, I chose to setup the new release by navigating to the source code to more clearly demonstrate the connection from a built to a release configuration. To start, click on the succeeded link which displays a new prompt with the option to Set up release, then click on that button and move on to the next step:
Create A Release Pipeline
You now have the initial screen for the release pipeline where you can choose a template to design your release:
Type 'iis' on the Search textbox and locate the IIS website deployment template:

Click Apply, then rename the Stage name to something more meaningful, in my case Development, then click on the X to exit the Stage side window and save the Stage:
Now you should see the Development stage where you will add release tasks. Hover over the 1 job, 2 tasks link and click on it to bring up the tasks screen:
You will notice that under IIS Deployment there is a message that Some settings need attention, click on that bar and you will see that you need to first add a Deployment group. Therefore, click on the gear next to the text box to bring up a new browser tab for the Deployment groups setup screen:

The deployment groups screen tab will open up, now you can Add a deployment group from an on-prem server:
On the Deployment Groups screen you fill out the Deployment group name, a Description and then click on Create to move to the next step:

Consequently you should see a PowerShell auto generated script that you can copy and paste on your target server in order to install the self-hosted agent. Make sure you also check the option to Use a personal access token in the script for authentication. This is convenient because it allows you to run the PowerShell scripts as-is without you having to type in you credentials on the target server. For more information on how the agents communicate with Azure DevOps see the official documentation:

Now you will logon to your Windows server 2016 target server, launch a new PowerShell window session as Administrator, and run the PowerShell script you just copied to your clipboard from the Deployment groups screen:
Once you run the PowerShell script you can configure options such as tags and you can also use a Service Account to run the release agent deployments. Once you successfully install the release agent you should see something similar to this:
Notice that the script installed the release agent as a Windows service, which is now listening for Azure DevOps to send a release job its way:
Now you should see that the Development Deployment Group is online:
Back in the Development Deployment process tasks browser tab, you can now set the Deployment Group setting to Development and the respective website tag:

Click on the IIS Web App Manage task next, and set the following settings:
- Add a checkmark on Enable IIS
- Add a checkmark on Create or update app pool
- Under IIS Application Pool/Name set the value to something like SampleSite.


On the IIS Web App Deploy task, set the Virtual Application setting to a sample value, in my case I will simply name it SampleApp:

You can now Save your configuration, you will link your artifacts to your release pipeline next. Just click on the Artifacts box, choose the default values for this sample app and then click Add and then Save your new release configuration:

Kick Off A New Release
Once you have designed your release pipeline, you can create a new release:

In the Create a new release screen you can select Development for the stage, the version of the build you want to release, and then click Create. Which will prepare the job for the server release agent to pick up and start the deployment to IIS whenever it gets the signal to Deploy:
You can then click on the Release-1 link to go and see the results of your newly minted release plan:
Since we set the release to deploy manually, you will have to start it up by hovering over the Development stage and then clicking on Deploy:
As the deployment to the target server starts, you should see the Deployment process summary page:
You can also inspect the logs and watch the release in 'real time' by clicking on the blue play button in the summary page shown above, which will bring you to the following screen:
Note that the first time you deploy to a new server, the process might be a little longer since the release agent is conducting an initial configuration of IIS during the IIS Web App Manage step of the release. After a few minutes you should see a successful release screen:
Validating On-Prem Deployment
Now if you log onto your on-prem server and launch IIS, you should see the new SampleApp web application deployed under the Default Web Site:
And you can quickly validate that things are running as expected by launching a browser from the SampleApp application in IIS:
Epilogue
In this post I showed you how you can deploy a simple website that targets the Classic .NET Framework onto an on-prem Windows Server 2016 instance. As you can see Azure DevOps provides all of the necessary features to make on-prem deployments as frictionless as possible. Having the option to deploy on-prem is a great feature to leverage in Azure DevOps, as your organization continues to build a Hybrid Cloud strategy and maximizes your current data center investment.
Until next time, happy deploying. :)