How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (2024)

In this bonus article I will show how to use Azure DevOps to deploy to an FTP(S) server or Web Deploy in cases where you may not have the Azure agent available.

I will be deploying the same application I built inpart two of the original series to a Standard Package onUmbHost, firstly using FTP and then using Web Deploy.

FTP Deployment

Build Pipeline

The build process requires a few changes to work with the FTP release pipeline, so you can followpart twoup until theAdding the build tasks section. At this point you will want use the MSBuild arguments defined below:

/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem 
/p:DeleteExistingFiles=True /p:publishUrl="$(Build.ArtifactStagingDirectory)\$(Build.BuildId)"
/p:AutoParameterizationWebConfigConnectionStrings=False

You will then need to add theArchive task. To do this click the plus +on theAgent job 1 bar then in the blade enter the following into the search box in the top right "archive files", adding the first result with the same name to the stage.

In this task, configure as follows:

Root folder or file to archive:

$(Build.ArtifactStagingDirectory)/$(Build.BuildId)

Selectzipfrom theArchive typedropdown, and then finally enter the archive name in to the box titledArchive file to create, for example:

$(Build.ArtifactStagingDirectory)/SkriftArticle.Web.zip

Next you will need to add the publish task. Search for this in the same way as the Archive task, instead entering publish build artifacts in the search box and adding the first result to the stage.

Configure this task by settingPath to publishas follows:

$(Build.ArtifactStagingDirectory)/SkriftArticle.Web.zip

That is the build process done with, next up is configuring the release pipeline.

Creating the Release Pipeline

First browse to theReleasesmenu item under thePipelinesmenu.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (1)Once there you will be presented with a message sayingNo release pipelines found. Beneath that will be a button calledNew pipeline; click this to begin the process.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (2)On the next screen selectEmpty job.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (3)

In theStage name text box input your build environment type. This is directly linked to naming of your web.config transforms.

For example, a stage name ofRelease would mean that during the deployment process it would use the Web.Release.configtransformation file.

For the purposes of this walk through I have entered Release.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (4)Now press theXin the right to close this blade.

Linking the artifact

Next the artifact needs linking to the pipeline. To do this click on the Add an artifact button then on the blade which opens up, and select the building pipeline from within the Source (build pipeline)dropdown.

Typically the default values in the rest of the fields should be fine.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (5)Finally click theAddbutton to close the blade.

Configuring the task

The tasks now need to be configured. First we will need to add a task to extract the zip file generated during the build process.

To add the extraction task click on the plus +on the bar entitledAgent job. In the search box on the blade which appears enter Extract filesand add the first result.

Now you need to point the extract task to the artifact created during the build process, press the 3 dots to open the browse blade, and select the *.Web.zip file. Then press Okto close the blade.

You should have something similar to this in the input:

$(System.DefaultWorkingDirectory)/_Skrift Part 2 Build Pipeline/Build-20201227.3/SkriftArticle.Web.zip

This needs modifying to work with each run. The folder name needs to be swapped out at release time by the agent. To do this change the build folder name to a predefined Azure DevOps variable $(Build.BuildNumber)so it looks similar to below:

$(System.DefaultWorkingDirectory)/_Skrift Part 2 Build Pipeline/$(Build.BuildNumber)/SkriftArticle.Web.zip

In the destination folder box enter the text as below:

$(Build.ArtifactStagingDirectory)/Release-$(Build.BuildNumber)/

Next is to setup the file transforms. We need to add a specific task to achieve this, so again click on the plus +then in the search box in the right of the blade enterFile transformthen add the first result.

In the package or folder box enter the text as below:

$(Build.ArtifactStagingDirectory)/Release-$(Build.BuildNumber)/

Tick theXML transformation checkbox, modify the rules as required by your application, and finally choose XMLin the file format drop down.

The final step in the FTP deployment pipeline is to deploy to the server. To do this click on the plus +then in the search box in the right of the blade enterFTP Upload, once again adding the first result to the stage.

Under Authentication Method selectEnter Credentials and then enter your details. Besure to tick thePreserve file pathscheckbox a bit further down underAdvanced.

Now you will want to name each release as something useful. This naming may differ depending on your company rules.

Click on theOptions tab and then in the release name format box paste the following:

Rel-$(date:ddMMyyyy)$(rev:.r)

The will generate something similar to below:

Rel-21012021.1

Finally name your pipeline. In the top left find New release pipelineand change this to your pipeline name, then clickSavein the top right.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (6)Run the Pipeline

So now all the configuration is done you will need to run the pipeline to push the files to the Web App. To do this click theCreate Releasebutton in the top right.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (7)In the blade which opens use the default values, then click Createat the bottom.

On the green bar that shows click the release name to open the information relating to the release.

If you hover over theRelease block the Logs button appears. Here you can view the deployment as it happens.

Once complete, you should have your website deployed via FTP.

Do note that due to the nature of FTP it cannot tell what has changed, so every deployment will deploy every file held within the zip folder.

Web Deploy Deployment

Build Pipeline

You can follow all of the steps inpart twoas this works with Web Deploy.

Creating the release pipeline

First browse to theReleasesmenu item under thePipelinesmenu.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (8)Once there you will be presented with a message sayingNo release pipelines found. Beneath that will be a button calledNew pipeline; click this to begin the process.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (9)On the next screen, selectEmpty job.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (10)In theStage name text box input your build environment type. This is directly linked to naming of your web.config transforms.

For example, a stage name ofRelease would mean that during the deployment process it would use the Web.Release.configtransformation file.

For the purposes of this walk through I have entered Release.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (11)Now press theXin the right to close this blade.

Linking the artifact

Next the artifact needs linking to the pipeline. To do this click on the Add an artifact button then on the blade which opens up select the building pipeline from within the Source (build pipeline)dropdown.

Typically the default values in the rest of the fields should be fine.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (12)Finally click theAddbutton to close the blade.

Configuring the task

The tasks now need to be configured.

First we will need to setup the file transforms. We need to add a specific task to achieve this so again click on the plus +then in the search box in the right of the blade enterFile transformthen add the first result.

In the package or folder box enter the text as below:

$(Build.ArtifactStagingDirectory)/Release-$(Build.BuildNumber)/

Tick theXML transformation checkbox, modify the rules as required by your application, and choose XMLin the file format drop down.

Next you will need to install a task from the Marketplace to use Web Deploy in the same way as the file transforms task. Click the plus +and search for the followingMSDeploy Package Sync. Once you have installed this into your Azure DevOps account add the task to the stage.

This will need configuring as below:

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (13)

The additional arguments should be as follows, changing skriftarticle.co.ukto your website name:

-setParam:'IIS Web Application Name'='skriftarticle.co.uk' -enableRule:AppOffline -enableRule:DoNotDeleteRule

You may also need to add the following argument if you have set any custom parameters at build time:

-setParamFile:"$(System.DefaultWorkingDirectory)/_UmbHost - Live/$(Build.BuildNumber)/SkriftArticle.Web.SetParameters.xml"

You can find a full list of Web Deploy ruleshere.

The most important setting here is the additional argument called IIS Web Application Name. Without this set it can throw an error if your web deploy user is not an administrator account.

Now you will want to name each release as something useful. This naming may differ depending on your company rules.

Click on theOptions tab and then in the release name format box paste the following:

Rel-$(date:ddMMyyyy)$(rev:.r)

The will generate something similar to below:

Rel-21012021.1

Finally name your pipeline. In the top left find New release pipeline and change this to your pipeline name then clickSavein the top right.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (14)Run the pipeline

So now all the configuration is done you will need to run the pipeline to push the files to the Web App. To do this click theCreate Releasebutton in the top right.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (15)

In the blade which opens, use the default values, then clickCreateat the bottom.

On the green bar that shows click the release name to open the information relating to the release.

If you hover over theRelease block the Logs button appears. Here you can view the deployment as it happens.

Once complete you should have your website deployed via FTP.

Wrap up

So that's all there is to it. Using the FTP method will allow you to use Azure DevOps with pretty much every host out there.

If your host offers Web Deploy (UmbHost includes this as standard) then my recommendation would be to use Web Deploy over FTP due to the fact it will only deploy changed files.

If you have any questions leave a comment below. I'll make sure to reply where I can. If you need a more personal response then feel free to drop me a message on Twitteror via mycontact form.

How to Deploy to FTP & Web Deploy using Azure DevOps by Aaron Sadler | Issue 72 (2024)
Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6630

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.