Deploying a Site to an Azure VM using Web Deploy
Deploying to an Azure VM is a seemingly simple and easy process, but there are many steps, and thus many places to make mistakes. Recently I discovered that many, if not all, of the online resources detailing this process are either incomplete or severely outdated. Here I will outline the configuration and deployment process with up to date information, including instructions pertaining to the new Microsoft Azure Portal.
To get started, you will need a few things that this tutorial does not cover. This tutorial assumes that your Azure VM is already provisioned, deployed, and running IIS (Internet Information Services). The VM should be running Windows Server 2012 R2 or later. This also assumes that you have administrator access to the Azure Subscription associated with the VM.
Configuring IIS on the Virtual Machine:
First, we’re going to need to install some IIS features. To assist in doing that, we are going to use Web Platform Installer (WPI). Once you have WPI downloaded and installed, run it and use the search feature to add “IIS Management Service,” “Web Deploy 3.6 without bundled SQL support,” and “IIS: ASP.NET 4.5.” Once those items have been added, click “Install” on the bottom right. You should see a window showing the items added. Click “I Accept” and the items will be installed.
Double click this icon. Here we can update the management settings. To edit settings, the IIS service will need to be stopped, so stop it now. Check the box on the top labeled “Enable Remote Connections.” Note that under the Connections section, port 8172 is specified. This is the default port that IIS will use, and to keep things simple, this tutorial will use the default port.
Now click “Apply” on the right side of the window to Apply the change and restart the service.
Note that this process should have automatically created this inbound rule on your VM’s firewall.
This rule will allow traffic on port 8172, the port we will be using for deployments.
Now that IIS is configured for Web Deploy, we can make the appropriate changes to the VM through the Azure portal.
Creating Network Security Rules for Azure:
Navigate to the Azure Portal and sign in then locate your VM. Once your VM is selected, click on “Network Interfaces” under the Settings section and select your VM’s network interface.
From the network interface, select “Network Security Group” and navigate to your security group.
Here we can edit our network security rules. We need to create a rule that will allow web deployments. To do so, click on “Inbound Security Rules” and then click the Add button. For our new rule, we want to allow action on port 8172.
One the rule has been created, we are ready to create our publish profiles and deploy.
Web Deploy via Visual Studio
Start by opening your solution containing the web project you wish to deploy in Visual Studio. Right click on your project and select “Publish.” When asked to select a publish target, click on Custom and give your publish profile a name. You should now be at a window where you can fill in the details for your deployment.
In the Server field, enter the address of you VM, but note that it must be accessed with https not http. Web Deploy is a secure process and must be done using the secure protocol.
For the Site Name, enter the name of the site that you would like to publish to in IIS.
Username and Password should be valid login credentials to your VM.
Finally, Destination URL will be the address of your VM again, but this time https is not required.
If validating the connection succeeds, you can now click “Publish” to deploy the code to your target machine.
The final steps are complete and you have now successfully published your site. It should now be up and running on the VM. If you would like to confirm this, you can remote onto the VM and navigate to the directory for the IIS Site. Here you should see the newly deployed files for your site. Publishing the code once will save all of the settings in a Publish Profile, so in the future you will be able to reuse this profile and deploy anytime with just one click.
To learn more on how Tallan’s Cloud technologists can help your organization enhance productivity, streamline costs, while optimizing data security to modernize your business, CLICK HERE.