Cake add-in to help with Kudu deployments using C#
C# PowerShell Batchfile
Latest commit 6a7cf52 Jan 13, 2017 @devlead devlead Fix MyGet issue

Cake Kudu

Cake add-in to help with Kudu deployments using C# This is still early & experimental, but feedback is welcome. Cake Kudu Azure Portal


Kudu is the engine behind git deployments in Azure Web Sites. It can also run outside of Azure.


Cake (C# Make) is a cross platform build automation system.

The Add-in

The Cake Kudu add-in parses the Kudu environment and exposed and easy accessible object model for your Cake C# build scripts.

This enables more advanced deployment scenarios like i.e. a single repository could contain multiple projects and based on the Azure web environment choose which project is built and deployed. An excellent use case for this is when you want to publish frontend and api web at the same time, just just commit once and both are deployed.

It will also enable to adjust build process/output based on configuration and not code.

Documentation for the Cake.Kudu addin can be found here:


The addin exposes 4 key areas of the Kudu environment


Exposes paths & tools used for deployment.


Exposes source countrol properties like commit id, branch, etc.


Exposed paths to tools that can be used in the Kudu environment.


Exposed environmental information about running website, like hostname, compute mode, sku, etc.

App Settings

Exposes web site app settings.

Connection strings

Exposes web connection strings.


Complete API/DSL reference can be found here

The addin is loaded in Cake via the #addin directive

#addin "Cake.Kudu"

This will give you a global Kudu property, to check if your running under Kudu or not you can use the IsRunningOnKudu property.

if (Kudu.IsRunningOnKudu)
    //Deployment code

You can get a hold that the deployment target directory and check it's existens via the Kudu.Deployment.Target property.

var deploymentPath = Kudu.Deployment.Target;
if (!DirectoryExists(deploymentPath))
    throw new DirectoryNotFoundException(
            "Deployment target directory not found {0}",

The Kudu sync command is exposed via a convinent Sync method.

Information("Deploying web from {0} to {1}", websitePath, deploymentPath);

AppSettings can be accessed via the IDictionary<string, string> AppSettings property.

foreach(var appSetting in Kudu.AppSettings)
        "Key: {0}Value: \"{1}\"",

Connection strings can be accessed IDictionary<string, string> AppSettings property.

foreach(var conectionString in Kudu.ConnectionStrings)
        "Key: {0}Value: \"{1}\"",

An complete deployment script can be found here