Tag Archives: azure web app

No comments

Continuous Integration from Visual Studio Team Services to Azure with NodeJs, ASP.NET 5, PHP...

NodeJs, ASP.NET 5, PHP, you name it, it can run on Azure as an App Service (previously known as Web App). But in modern development cycle this simply isn't enough. Things like CD (continuous deployment) and CI (continuous integration) are a must for a modern development process. Azure supports continuous integration of out the box, but you can quickly stumble upon an obstacle if you want to perform custom build/install steps such as NodeJs or ASP.NET 5 package restore, JavaScript bundling and minimisation...

Visual Studio Team Services (VS TS ex - Visual Studio Online) is absolutely awesome at this. It gives you free source control, managing work items and most importantly for me, continuous deployment and integration. But as always, not everything is as good as it seems. Things may quickly complicate when you go outside of Microsoft's waters.

Setting up the build process

My usual build process (bellow is specific for ASP.NET 5 website I used, if you're interested in ASP.NET 5 Build script, take a look at it here):


Note: Azure Web App Deployment is DISABLED, replaced by PowerShell script.

I solved all of my problems with a simple PowerShell script:

param($websiteName, $packOutput)

$website = Get-AzureWebsite -Name $websiteName

# get the scm url to use with MSDeploy.  By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames[1]

$publishProperties = @{'WebPublishMethod'='MSDeploy';

$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"

Stop-AzureWebsite -Name $websiteName
. $publishScript -publishProperties $publishProperties  -packOutput $packOutput
Start-AzureWebsite -Name $websiteName

In short what it does, it connects to Azure, finds required Web App, stops it, syncs only differences to Azure to keep it up to date, and starts the Web App back up.

Usage itself is pretty simple. Add an Azure PowerShell build step in your build process. On the right side in the configurations, specify Azure connection type and subscription. In the path select path to the PowerShell script and provide arguments, which are which Web App and which directories to sync (example below).

My usual configuration is something like:

-websiteName WebsiteName -packOutput $(Build.SourcesDirectory)\bin\output

Don't forget to replace WebsiteName with your actual website name and build variables on msdn.


Enabling continuous integration

Simply go to Triggers tab and check Continuous integration (CI) checkbox to enable it.



I am aware, that Azure also supports Custom Deployment Scripts, but I prefer things described above. That way you keep unnecessary files produced during build or things that don't really need to be deployed away, keeping your production environment clean and also integrating your entire development cycle with unit testing, load tests or building a C++ library if your app needs it.