Deploy to IIS servers with Azure Pipelines and WinRM
Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018
Learn how to use Azure Pipelines and WinRM to set up a continuous delivery pipeline to deploy your ASP.NET, ASP.NET Core, or Node.js web apps to one or more IIS servers.
Prerequisites
- An Azure DevOps Organization. Create an organization, if you don't have one already.
- Build pipeline
- Configure WinRM
- Configure IIS servers
Build pipeline
Set up a build pipeline if you don't have one already.
Configure WinRM
Windows Remote Management (WinRM) requires target servers to be:
- Domain-joined or workgroup-joined.
- Able to communicate using the HTTP or HTTPS protocol.
- Addressed by using a fully qualified domain name (FQDN) or an IP address.
This table shows the supported scenarios for WinRM. Make sure that your IIS servers are set up in one of the following configurations. For example, do not use WinRM over HTTP to communicate with a Workgroup machine. Similarly, do not use an IP address to access the target server(s) when you use HTTP protocol. Instead, use HTTPS for both scenarios.
| Joined to a | Protocol | Addressing mode |
|---|---|---|
| Workgroup | HTTPS | FQDN or IP address |
| Domain | HTTPS | FQDN or IP address |
| Domain | HTTP | FQDN |
Note
If you need to deploy to a server that is not in the same workgroup or domain, add it to the trusted hosts in your WinRM configuration.
Follow these steps to configure each target server.
Enable File and Printer Sharing. Run the following command in an elevated command prompt:
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yesMake sure you have PowerShell v4.0 or above installed on every target machine. To display the current PowerShell version, run the following command in an elevated PowerShell command prompt:
$PSVersionTable.PSVersionMake sure you have the .NET Framework v4.5 or higher installed on every target machine. See How to: Determine Which .NET Framework Versions Are Installed for details.
Download the configuration script and copy them to every target machine. You will use them to configure WinRM in the following steps.
- Windows 10 and Windows Server 2016: ConfigureWinRM.ps1 win10-ser16
- Previous versions of Windows: ConfigureWinRM.ps1
Decide if you want to use HTTP or HTTPS to communicate with the target machine(s).
- If you want to use the HTTP protocol, run the following command in an elevated command prompt to create an HTTP WinRM listener and open port 5985:
ConfigureWinRM.ps1 {FQDN} http- If you want to use the HTTPS protocol, you can use either a FQDN or an IP address to access the target machine(s). To use a FQDN to access the target machine(s), run the following command in an elevated PowerShell command prompt:
ConfigureWinRM.ps1 {FQDN} httpsTo use an IP address to access the target machine(s), run the following command in an elevated PowerShell command prompt:
ConfigureWinRM.ps1 {ipaddress} httpsThe script is using MakeCert.exe to create a test certificate and use it to create an HTTPS WinRM listener and open port 5986. The script will also increase the WinRM MaxEnvelopeSizekb setting to prevent certain errors such as "Request size exceeded the configured MaxEnvelopeSize quota". By default, this value is set to 500 KB in Windows Server machines.
Configure IIS servers
Create a release pipeline
Select Pipelines, and then select Releases. Select New pipeline.
Select Empty job.
Select + Add to add your build artifact, and then select your Project and Source. Select Add when you are done.
Choose the Continuous deployment trigger icon in the Artifacts section, and then enable the Continuous deployment trigger and add a build branch filter to include the main branch.
Select Variables, and create a variable WebServers with a list of IIS servers for its value; for example machine1,machine2,machine3.
Select your stage, and add the following tasks to your pipeline:
Windows Machine File Copy - Copy the Web Deploy package to the IIS servers.Source: Select the Web deploy package path.
Machines: $(WebServers)
Admin Login: The administrator login on the target servers. For workgroup-joined computers, use the format .\username. For domain-joined computers, use the format domain\username.
Password: The administrator password on the target servers.
Destination Folder: The folder on the target machines to which the files will be copied.
WinRM - IIS Web App Deployment - Deploy your package.Machines: $(WebServers)
Admin Login: The administrator login on the target servers. For workgroup-joined computers, use the format .\username. For domain-joined computers, use the format domain\username.
Password: The administrator password on the target servers.
Protocol: Select HTTP or HTTPS (depending on how you configured the target machine earlier). Note that if the target machine is workgroup-joined, you must choose HTTPS. You can use HTTP only if the target machine is domain-joined and configured to use a FQDN.
Web Deploy Package: Fully qualified path of the zip file you copied to the target server in the previous task.
Website Name: Default Web Site (or the name of the website if you configured a different one earlier).
Select Save when you are done and then select OK.
Deploy your app
Select Pipelines > Releases, and then select Create release.
Check that the artifact version you want to use is selected and then select Create.
Select the release link in the information bar message. For example: "Release Release-1 has been queued".
Navigate to your pipeline Logs to see the logs and agent output.
Related articles
Povratne informacije
Pošalјite i prikažite povratne informacije za