I am following the tutorial for the IIS web deploy pipeline according to the docs on IIS Web App Deploy task
If you see the parameter list, there does not seems to have any deployment group parameter. Therefore, how do I know / control in which server that the result of the deployment goes?
- task: IISWebAppDeploymentOnMachineGroup@0
inputs:
webSiteName:
virtualApplication: # Optional
package: '$(System.DefaultWorkingDirectory)\**\*.zip'
setParametersFile: # Optional
removeAdditionalFilesFlag: false # Optional
excludeFilesFromAppDataFlag: false # Optional
takeAppOfflineFlag: false # Optional
additionalArguments: # Optional
xmlTransformation: # Optional
xmlVariableSubstitution: # Optional
jSONFiles: # Optional
I want it to deploy to my "Dev" group as per screenshot below. If YAML can't deploy to deployment group, where is the default deployment location (ie, which computer?)
Let's say that I want to deploy to my PC , how do I direct the deployment to go to my localbox and put it under C:/publish ?
Web Deploy is an extensible client-server tool for syncing content and configuration to IIS. Web Deploy is used primarily in two scenarios: Developers use it to sync (aka 'publish') a compiled web applications (ASP . Net, PHP etc) from developer tools (Visual Studio, WebMatrix, etc) to IIS.
As at June 2020 the YAML-based multistage pipeline does not support deployment groups. However, the YAML-based pipeline has an alternative: Environments.
You can create an Environment manually, under Azure Pipelines > Environments. Once you have created the Environment you can add Resources underneath it. At the moment there are only two types of resources supported: Kubernetes and Virtual Machines. The Virtual Machine resource type is a bit misleading: It can be a virtual machine but it can also be an on-prem physical server. If you're deploying to IIS you'll need to create a Virtual Machine resource.
Creating a Virtual Machine resource under an Environment is very much like adding a target to a Deployment Group: When you add the Virtual Machine resource to the Environment it will generate a PowerShell script that you copy to the target server and run there as administrator. Running that script will create a self-hosted agent on the target server and will register that agent as a Resource under the Environment.
This process is almost identical to the process of adding a target to a Deployment Group.
In the YAML file specify the environment under the deployment job. It's not enough to specify the environment by name. You have to also specify the resourceType for the Environment as well as the name.
Here is my YAML for the build and deployment stages:
trigger:
- master
stages:
- stage: 'Build'
displayName: 'Build the web application'
jobs:
- job: 'Build'
displayName: 'Build job'
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: 'Deploy'
displayName: 'Deploy the web application'
dependsOn: Build
jobs:
- deployment: 'DeployToDev'
displayName: 'Deploy the web application to dev environment'
variables:
Parameters.IISDeploymentType: 'IISWebsite'
Parameters.ActionIISWebsite: 'CreateOrUpdateWebsite'
Parameters.WebsiteName: 'Default Web Site'
Parameters.WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\AspNetDemo'
Parameters.AddBinding: false
Parameters.VirtualPathForApplication: '/AspNetDemo'
Parameters.AppPoolName: ''
Parameters.VirtualApplication: 'AspNetDemo'
Parameters.Package: '$(Pipeline.Workspace)\drop\*.zip'
Parameters.RemoveAdditionalFilesFlag: true
Parameters.TakeAppOfflineFlag: true
Parameters.XmlTransformation: true
Parameters.XmlVariableSubstitution: true
environment:
name: Dev
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: IISWebAppManagementOnMachineGroup@0
displayName: 'IIS Web App Manage'
inputs:
IISDeploymentType: '$(Parameters.IISDeploymentType)'
ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
WebsiteName: '$(Parameters.WebsiteName)'
WebsitePhysicalPath: '$(Parameters.WebsitePhysicalPath)'
AddBinding: $(Parameters.AddBinding)
ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
AppPoolName: '$(Parameters.AppPoolName)'
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
VirtualApplication: '$(Parameters.VirtualApplication)'
Package: '$(Parameters.Package)'
RemoveAdditionalFilesFlag: $(Parameters.RemoveAdditionalFilesFlag)
TakeAppOfflineFlag: $(Parameters.TakeAppOfflineFlag)
XmlTransformation: $(Parameters.XmlTransformation)
XmlVariableSubstitution: $(Parameters.XmlVariableSubstitution)
Note the environment information in the deployment stage, specifying the name (Dev) and the resourceType (VirtualMachine):
environment:
name: Dev
resourceType: VirtualMachine
YAML does not support deployment groups. If you want to use deployment groups, you can't use YAML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With