Yesterday I spent a bit of time working with the new Release Management components on VSTS (http://www.visualstudio.com - essentially Microsoft's hosted TFS implementation) in the knowledge that this will be (almost) what appears in the TFS 2015 Update 2 builds.
The first thing I noticed was the distinct lack of support for pushing environment configuration into the SetParameters files used by WebDeploy; essentially all you could change was the connection string if you were willing to try and work out the advanced parameters to pass in. This just wouldn't be enough for most of the projects I was involved in, and I found it pretty bizarre considering the way the existing on-premise Release Management works with WebDeploy.
So I extended the Azure Web Deploy action to add in tokenisation. And heres how.
First step - extend the Azure PowerShell Publish-AzureWebsiteProject.
Ultimately speaking, this is what VSTS is firing off in the background and so this is where we need to start.
A quick branch of the GitHub code for Azure-Powershell (thank you Microsoft for making this all Open Source!), and a dive into the code in src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs. It's pretty clear that this function would need to accept an additional set of arguments, and then carry out the tokenisation (i.e. replacement) in the SetParameters.xml file.
With that done, a compile and overwrite the existing copy on my machine (in %ProgramFiles%\Microsoft SDKs\Azure\PowerShell) and then a test in an Azure PowerShell and time to move on.
Second step - clone the existing VSTS Deploy to Azure Website task
Ironically, this step took more work.
In order to create a task for Build or Release pipelines on VSTS, you need to get you environment setup first. Microsoft have gone down the cross-platform route here, which makes a lot of sense given the direction VSTS is taking.
Download and install NodeJS for your platform (https://nodejs.org/en/).
Install the tfx-cli tooling using npm (https://www.npmjs.com/package/tfx-cli).
First step is to authenticate with the service; you do this by issuing a tfx login command. You will be prompted for you VSTS url as well as your personal access token.
After you have done that, you need to create a task: issue a tfx build tasks create and you will be prompted for:
TFS Cross Platform Command Line Interface v0.3.9
Copyright Microsoft Corporation
> Task Name: Antask
> Friendly Task Name: Testing
> Task Description: Testing
> Task Author: Andy
created task @ C:\Users\Andy\Antask
id : ----
A temporary task icon was created. Replace with a 32x32 png with transparencies
"name": "Tokens", "type": "string", "label": "Tokens to replace", "defaultValue": "", "helpMarkDown": "Tokens to replace in the SetParameters.xml as used by Web Deploy.", "required": false },</pre><p>Then its the PowerShell script that needs modified; the new parameter needs to be added to the param block, then the actual call to $azureCommandArguments. And thats essentially all the modifications needed.</p><p>Uploading the action is a simple matter of issuing a <span style="font-weight: bold;">tfx build tasks upload --task-path ./ANTest</span></p><p>And that is it!</p><p>I have repo's on <a href="https://github.com/aneillans" target="_blank">GitHub</a> for modified versions of both azure-powershell and vso-agent-tasks; hopefully I can get a couple of Pull Requests accepted with some work!</p>