Deploy to a Windows Virtual Machine

VSTS | TFS 2018

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.

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:


IIS configuration

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


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 -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 -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}, navigate to the Build and 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.

    The account under which the agent runs needs Manage permissions for the C:\Windows\system32\inetsrv\ directory. Adding non-admin users to this directory is not recommended. In addition, if you have a custom user identity for the application pools, the identity needs permission to read the crypto-keys. Local service accounts and user accounts must be given read access for this. For more details, see Keyset does not exist error message.

  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 and Release hub in VSTS, open the myIIS deployment group. On the Targets 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. Select the IIS Website Deployment template and choose Apply.

  3. If you created your new release definition from a build summary, check that the build definition and artifact is shown in the Artifacts section on the Pipeline tab. If you created a new release definition from the Releases tab, choose the + Add link and select your build artifact.

    Selecting the build artifact

  4. Choose the Continuous deployment icon in the Artifacts section, check that the continuous deployment trigger is enabled, and add a filter to include the master branch.

    Setting the continuous deployment trigger

  5. Open the Tasks tab and select the IIS Deployment phase. For the Deployment Group, select the deployment group you created earlier (such as myIIS).

    IIS deployment group in release definition

  6. 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. Choose + Release and select Create Release.

  2. Check that the build you just completed is selected and choose Create.

  3. Choose the release link in the popup message. For example: "Release Release-1 has been created".

  4. Open the Logs tab to watch the release console output.

  5. After the release is complete, navigate to your app and verify its contents.

Next steps