This article outlines the steps required to set up an Azure virtual machine to host ASP.NET (Framework) web applications, and to allow websites to be published using WebDeploy.
To get up and running quickly with an Azure VM that's configured for ASP.NET and WebDeploy, use one of the scripts provided in the Quick setup section.
Otherwise, you can follow the Walk-through to create and configure a VM.
We'd love to know how you're using Azure virtual machines. Please fill out the Azure Virtual Machine Survey to help us better understand your goals.
Select the following Create Azure VM button to use this custom Azure Resource Manager template to provision a new VM in Azure that's set up for hosting ASP.NET web apps and publishing from Visual Studio.
The template performs the following actions:
- Provision a new Azure VM (Windows Server 2016 Datacenter)
- Configure components and features on the VM (available as PowerShell script)
- Configure Azure Firewall rules (Ports 80 and 8172)
Provide the minimal input values. The rest is generated for you.
Important
You need to manually configure a DNS name for the VM in order to use the Microsoft Azure Virtual Machines publishing wizard in Visual Studio. For more information, see Set up DNS name for the VM
If you already have an Azure VM, run the following script in PowerShell on the VM to set up the required components.
# Install IIS (with Management Console)
Install-WindowsFeature -name Web-Server -IncludeManagementTools
# Install ASP.NET 4.6
Install-WindowsFeature Web-Asp-Net45
# Install Web Management Service
Install-WindowsFeature -Name Web-Mgmt-Service
# Install Web Deploy 3.6
# Download file from Microsoft Downloads and save to local temp file (%LocalAppData%/Temp/2)
$msiFile = [System.IO.Path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'msi' } -PassThru
Invoke-WebRequest -Uri http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi -OutFile $msiFile
# Prepare a log file
$logFile = [System.IO.Path]::GetTempFileName()
# Prepare the arguments to execute the MSI
$arguments= '/i ' + $msiFile + ' ADDLOCAL=ALL /qn /norestart LicenseAccepted="0" /lv ' + $logFile
# Execute the MSI and wait for it to complete
$proc = (Start-Process -file msiexec -arg $arguments -Passthru)
$proc | Wait-Process
Get-Content $logFile
The script performs the following tasks:
- Install IIS (with Management Console)
- Install ASP.NET 4.6
- Install Web Management Service
- Configure automatic startup
- Start service
- Install WebDeploy 3.6
Important
To complete the setup that enables publishing from Visual Studio, you need to set up Azure firewall rules and configure a DNS name for the VM. Refer to the instructions later in this article.
[!div class="checklist"]
-
Log in to the Azure portal at https://portal.azure.com
-
Click the + New in the top left corner.
-
Select Windows Server 2016 VM in the Get Started category or any Windows Server 2016 in the Compute category, such as Windows Server 2016 Datacenter
-
Complete the required fields to configure the new VM:
Azure template field How to populate the field Virtual Machine Name This is the name of the VM you are creating. Username/Password Create an administrator username and password for the VM.
Remember this username/password. You will need it to access the VM.Subscription Choose your Azure subscription Resource group This is the name of the "virtual folder" that contains all resources created for this VM.
You can delete all the resources created during this process by deleting the resource group.
Consider a name that is similar to the name of the VM you are creating.Location Accept the default or choose a desired region from the list -
Choose a size for the VM; DS1_V2 is sufficient for this tutorial and the size can be changed later.
- If you have Free Azure Credits (for example, as a part of your MSDN Subscription), it might cover the costs.
- Check your Visual Studio subscription. Check for offers for monthly Azure credit.
- Check your Visual Studio subscription. Check for offers for monthly Azure credit.
[!Note] The costs shown in your Azure portal may differ from the values shown here. Cost is different based on Region and is subject to changes over time.
- If you have Free Azure Credits (for example, as a part of your MSDN Subscription), it might cover the costs.
-
Accept the defaults in Step 3: (Settings)
-
Confirm details in Summary and click Purchase.
Provisioning begins and a notification appears once provisioning is complete (about five minutes).
- Open the newly created VM in the Azure portal and select Connect on its top toolbar.
An RDP file is downloaded. Running the RDP file opens a Remote Desktop Connection pointing to the IP address of the new Azure VM. - Accept warning about unknown publisher.
- Enter Credentials
Enter the username and password you used to create the new Azure VM - not your work/home user account.
On Windows 10, choose More choices -> Use a different account. - Accept warning about security certificate
Window opens with remote connection to the Azure VM.- Server Manager - Dashboard opens on first startup
- Open the Server Manager Dashboard
- Choose 2 Add roles and features
- Accept the defaults and press Next three times to progress to the Server Roles section.
- Select Web Server (IIS)
- When prompted, confirm the additional installation of IIS Management Console
- Press Next three times to progress to the Web Server Role (IIS) --> Roles Services section
- Select Management Service, which is required to enable Web Deploy (through port 8172). When prompted, confirm the additional installation of ASP.NET 4.6.
- Select Next to confirm the configuration, then Install to complete IIS setup.
Once installation completes:
- IIS is installed and running with internal firewall rule created for port 80.
- Web Management Service is installed with internal firewall rule created for port 8172.
Note
Corresponding Firewall ports must be opened in the Azure portal before traffic can be routed to this VM.
On a new Azure VM, default security rules prevent executables from being downloaded via Internet Explorer. In order to download the WebDeploy executable, you must first disable IE enhanced security.
- In the Server Manager, open the Local Server section on the left.
- In the main panel, next to "IE Enhanced Security Configuration:", select On.
Launches dialog to configure IE security restrictions
- In the dialog that appears, select Off for Administrators, select On for Users, then select OK.
- Launch Internet Explorer.
- Accept default security settings.
- Download WebDeploy_amd64_en-US.msi from https://www.microsoft.com/en-us/download/details.aspx?id=43717
- Allow pop-ups and Run the downloaded MSI
- Follow installation steps for Web Deploy 3.6
Choose Complete option to install all components
Once Web Deploy is installed, the Web Management Service is started and set to automatic startup.
Now that the VM is set up to receive requests to the Web Server and the Web Management Service, the corresponding ports must be opened in the Azure portal.
- Log in to the Azure portal
- Open the VM and select the Networking section.
- Select Add inbound port rule to create two new firewall entries.
- http - Port 80 (Priority 100)
- WebDeploy - Port 8172 (Priority 1010)
To use the in-built web publishing wizard in Visual Studio, the virtual machine must be configured with a DNS name.
- From the Azure portal, navigate to the Overview page of your virtual machine.
- Under DNS name, click Configure
- Provide a globally unique DNS name. (A green tick appears when the name is validated.)
- Click Save to save the configuration.
There's a separate article that describes the process of publishing a web app from Visual Studio. It is designed to pick up from where this article leads off and includes instructions for configuring the DNS, and troubleshooting tips.