SharePoint Online Continuous Delivery with Visual Studio Team Services (part 2)

This post is about setting-up a continuous delivery pipeline for SharePoint Online with Visual Studio Team Services.

Link to part 1/3:
Link to part 3/3:

As seen in step one, I used the PowerShell's "SharePointPnPPowerShellOnline" extension to write a script to upload files to my SharePoint Online site. Unfortunately it cannot be installed on the hosted Team Services Agent so the easiest way here is to setup a private agent. In this post I will show how to setup a private Team Service Agent using a virtual machine hosted on Azure.

Preparing a virtual machine with Azure

Note : I choosed to use Azure but you can reproduce this what ever you want as long as it has internet access to connect to Team Services.

Create a DevTest Lab (I plan to use the auto start and shutdown to match work hours).

In the lab add a new machine

Here are the settings I used, template Visual Studio Community 2015 on Windows 2012 R2, size A2_v2 and artefact 7-zip.
Note : there is an artefact to automatically setup de TS Agent, but I didn't manage to get it to work so I'll do it manually.

Once the machine is created connect to it. Then open a browser and go to your Team Services. Go to "Agent Pools" in the settings and click "Download agent".
Then follow the instructions to download the bits.

To setup the agent you will need a personal access token (PAT), to generate one go to your profil under "Security".
Once created copy the token value for later use.

Once the agent download is complete unzip it and open a command prompt to the unzipped folder. Run "config.cmd".
Provide the URL to your team services account. When asked for "PAT" paste the token generated earlier.
When asked for "run agent as a service" say yes. For the rest you can use default values exept for the service account, provide the machine administrator account don't use the "NT AUTHORITY\Network Service" or the agent will remain Offline for Team Services.

If this works you should have the agent listed in the default pool:

Installing the SharePointPnPPowerShellOnline extension

On the agent open a PowerShell windows as administrator and run :
Install-Module SharePointPnPPowerShellOnline -AllowClobber
For more details about install go to the official page :

Ok it's all I have time for right now, in the next post I'll show how to setup Team Services Build & Release definitions to take advantage of the deployement pnp script.