Deploy to a Windows Virtual Machine

Azure Pipelines | TFS 2018

Note

Build and release pipelines are called definitions in TFS 2018 and in older versions. Service connections are called service endpoints in TFS 2018 and in older versions.

We'll show you how to set up continuous deployment of your ASP.NET or Node.js app to an IIS web server running on Windows using Azure Pipelines. You can use the steps in this quickstart as long as your continuous integration pipeline 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 pipeline

You'll need a continuous integration (CI) build pipeline that publishes your web deployment package. To set up a CI build pipeline, 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.js app

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

Create a deployment group

Deployment groups in Azure Pipelines 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 an Azure Pipelines agent on each of them. Each machine interacts with Azure Pipelines to coordinate deployment of your app.

  1. Open the Azure Pipelines web portal and choose 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.

    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 in Azure Pipelines, open the myIIS deployment group. On the Targets tab, verify that your VM is listed.

Define your CD release pipeline

Your CD release pipeline 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 choose Release. This creates a new release pipeline that's automatically linked to the build pipeline.

    • Open the Releases tab of Azure Pipelines, open the + drop-down in the list of release pipelines, and choose Create release pipeline.

  2. Select the IIS Website Deployment template and choose Apply.

  3. If you created your new release pipeline from a build summary, check that the build pipeline and artifact is shown in the Artifacts section on the Pipeline tab. If you created a new release pipeline from the Releases tab, choose the + Add link and select your 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.

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

  6. Save the release pipeline.

Create a release to deploy your app

You're now ready to create a release, which means to run the release pipeline 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