Deploy to a Windows Virtual Machine
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018
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.
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:
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 https://go.microsoft.com/fwlink/?linkid=848827 -outfile $env:temp\dotnet-dev-win-x220.127.116.11.exe Start-Process $env:temp\dotnet-dev-win-x18.104.22.168.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 Stop-Service was -Force Start-Service w3svc
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.
Open the Azure Pipelines web portal and choose Deployment groups.
Click Add Deployment group (or New if there are already deployment groups in place).
Enter a name for the group, such as myIIS, and then click Create.
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.
On your VM, in an Administrator PowerShell console, paste and run the script.
When you're prompted to configure tags for the agent, press Enter (you don't need any tags).
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.
When the script is done, it displays the message Service vstsagent.account.computername started successfully.
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.
If you haven't already done so, install the IIS Web App Deployment Using WinRM extension from Marketplace. This extension contains the tasks required for this example.
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.
Select the IIS Website Deployment template and choose Apply.
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.
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.
Open the Tasks tab and select the IIS Deployment job. For the Deployment Group, select the deployment group you created earlier (such as myIIS).
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:
Choose + Release and select Create a release.
In the Create a new release panel, check that the artifact version you want to use is selected and choose Create.
Choose the release link in the information bar message. For example: "Release Release-1 has been created".
In the pipeline view, choose the status link in the stages of the pipeline to see the logs and agent output.
After the release is complete, navigate to your app and verify its contents.