Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

Latest commit

 

History

History
271 lines (216 loc) · 14.7 KB

create-asp-net-vm-with-webdeploy.md

File metadata and controls

271 lines (216 loc) · 14.7 KB

Create an ASP.NET VM with WebDeploy

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.

How do you use Azure VMs?

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.

Quick setup

Create a new VM

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.

Create ASP.NET VM in Azure

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

Patch an existing 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.

Walk-through: Create a new Azure VM for hosting your web app

[!div class="checklist"]

Provision a new VM using Azure portal

  1. Log in to the Azure portal at https://portal.azure.com

  2. Click the + New in the top left corner.

  3. 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
    Create New VM

  4. Complete the required fields to configure the new VM:
    New VM Step 1

    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
  5. Choose a size for the VM; DS1_V2 is sufficient for this tutorial and the size can be changed later.

    [!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.

  6. Accept the defaults in Step 3: (Settings)

  7. Confirm details in Summary and click Purchase.
    New VM Step 4
    Provisioning begins and a notification appears once provisioning is complete (about five minutes).

Connect to the VM (Remote Desktop Connection)

  1. Open the newly created VM in the Azure portal and select Connect on its top toolbar. Connect To VM
    An RDP file is downloaded. Running the RDP file opens a Remote Desktop Connection pointing to the IP address of the new Azure VM.
  2. Accept warning about unknown publisher.
    Warning Unknown Publisher
  3. 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.
  4. Accept warning about security certificate
    Window opens with remote connection to the Azure VM.
    • Server Manager - Dashboard opens on first startup

Install IIS (Web Server) plus Web Management Service and ASP.NET 4.6

  1. Open the Server Manager Dashboard
  2. Choose 2 Add roles and features Roles and Features
  3. Accept the defaults and press Next three times to progress to the Server Roles section.
  4. Select Web Server (IIS)
    Web Server Role
    • When prompted, confirm the additional installation of IIS Management Console
  5. Press Next three times to progress to the Web Server Role (IIS) --> Roles Services section
  6. 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 Feature Management Service
  7. Select Next to confirm the configuration, then Install to complete IIS setup.
    Confirm Config Change

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.

Install Web Deploy 3.6

Configure IE Enhanced Security (Off)

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.

  1. In the Server Manager, open the Local Server section on the left.
  2. In the main panel, next to "IE Enhanced Security Configuration:", select On.
    Launches dialog to configure IE security restrictions
    Disable IE Enhanced Security
  3. In the dialog that appears, select Off for Administrators, select On for Users, then select OK.

Download and Install Web Deploy 3.6

  1. Launch Internet Explorer.
  2. Accept default security settings.
  3. Download WebDeploy_amd64_en-US.msi from https://www.microsoft.com/en-us/download/details.aspx?id=43717
  4. Allow pop-ups and Run the downloaded MSI
  5. 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.

Configure inbound firewall rules in the Azure portal

  1. Log in to the Azure portal
  2. Open the VM and select the Networking section.
  3. Select Add inbound port rule to create two new firewall entries.
    • http - Port 80 (Priority 100)
    • WebDeploy - Port 8172 (Priority 1010)

Set up DNS name for the VM

To use the in-built web publishing wizard in Visual Studio, the virtual machine must be configured with a DNS name.

  1. From the Azure portal, navigate to the Overview page of your virtual machine.
  2. Under DNS name, click Configure
  3. Provide a globally unique DNS name. (A green tick appears when the name is validated.)
  4. Click Save to save the configuration.

Next steps

Publish a web application from Visual Studio

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.