Deploy to a Windows Virtual Machine

VSTS

We'll show you how to set up continuous deployment of your ASP.NET or Node app to an IIS web server running on Windows using Visual Studio Team Services (VSTS). You can use the steps in this quickstart as long as your continuous integration process publishes a web deployment package.

For example, you can continuously deliver your app to a container hosted in Azure.

A typical release pipeline for web applications

After you commit and push a code change, it is automatically built and then deployed. The results will automatically show up on your site.

Define your CI build process

You'll need a continuous integration (CI) build process that publishes your web deployment package. To set up a CI build process, see:

Prerequisites

IIS configuration

The configuration varies depending on the type of app you are deploying.

ASP.NET app

On your VM, open an Administrator: Windows PowerShell console. Install IIS:

# Install IIS
Install-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features

ASP.NET Core app

Running an ASP.NET Core app on Windows requires some dependencies.

On your VM, open an Administrator: Windows PowerShell console. Install IIS and the required .NET features:

# Install IIS
Install-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features

# Install the .NET Core SDK
Invoke-WebRequest https://go.microsoft.com/fwlink/?linkid=848827 -outfile $env:temp\dotnet-dev-win-x64.1.0.4.exe
Start-Process $env:temp\dotnet-dev-win-x64.1.0.4.exe -ArgumentList '/quiet' -Wait

# Install the .NET Core Windows Server Hosting bundle
Invoke-WebRequest https://go.microsoft.com/fwlink/?LinkId=817246 -outfile $env:temp\DotNetCore.WindowsHosting.exe
Start-Process $env:temp\DotNetCore.WindowsHosting.exe -ArgumentList '/quiet' -Wait

# Restart the web server so that system PATH updates take effect
net stop was /y
net start w3svc

When net start w3svc appears, press Enter to run it.

Node app

Follow the instructions in this topic to install and configure IISnode on IIS servers.

Create a deployment group

Deployment groups in VSTS make it easier to organize the servers that you want to use to host your app. A deployment group is a collection of machines with a VSTS agent on each of them. Each machine interacts with VSTS to coordinate deployment of your app.

  1. Open the VSTS web portal (https://{your-account}.visualstudio.com), navigate to the Build & Release hub, and then click Deployment groups.

  2. Click Add Deployment group (or New if there are already deployment groups in place.

  3. Enter a name for the group, such as myIIS, and then click Create.

  4. In the Register machine section, make sure that Windows is selected, and that Use a personal access token in the script for authentication is also selected. Click Copy script to clipboard.

    Screenshot showing update to code

    The script that you've copied to your clipboard will download and configure an agent on the VM so that it can receive new web deployment packages and apply them to IIS.

  5. On your VM, in an Administrator PowerShell console, paste and run the script.

  6. When you're prompted to configure tags for the agent, press Enter (you don't need any tags).

  7. When you're prompted for the user account, press Enter to accept the defaults.

  8. When the script is done, it displays the message Service vstsagent.account.computername started successfully.

  9. On the Deployment groups page of the Build & Release hub in VSTS, open the myIIS deployment group. On the Machines tab, verify that your VM is listed.

    Screenshot showing update to code

Define your CD release process

Your CD release process picks up the artifacts published by your CI build and then deploys them to your IIS servers.

  1. Do one of the following:

    • If you've just completed a CI build then, in the build's Summary tab under Deployments, choose Create release followed by Yes. This starts a new release definition that's automatically linked to the build definition.

      Creating a new release definition from the build summary

    • Open the Releases tab of the Build & Release hub, open the + drop-down in the list of release definitions, and choose Create release definition.

      Creating a new release definition in the Releases page

  2. In the Create release definition wizard, select IIS Website Deployment template, and then click Apply.

    Screenshot showing IIS website deployment template

  3. Click the Tasks tab, and then click the IIS Deployment phase. For the Deployment Group, click the deployment group you created earlier, such as myIIS.

    iis deployment group in release definition

  4. Save the release definition.

Create a release to deploy your app

You're now ready to create a release, which means to start the process of running the release definition with the artifacts produced by a specific build. This will result in deploying the build:

  1. To test the release definition, click Release and then Create Release.

  2. On the Create new release dialog box, click Queue. Notice that a new release was created. Click the link to navigate to the release.

  3. Click the Logs tab to watch the live logs from the deployment as it happens. Wait for the release to be deployed to the Azure web app.

  4. Once deployment has completed, open your web browser and test your web app: http://<publicIpAddress>, where <publicIpAddress> is the IP address of your web site on your IIS web server.

Next steps