“Run-From-Zip” with Cake Kudu Client

Written by devlead | Published 2018/02/16
Tech Story Tags: azure | devops | csharp | dotnet | continuous-delivery

TLDRvia the TL;DR App

A new way to deploy your Azure Web Apps and Function Apps

Update! Since this post was written, there’s been some breaking changes to Azure App Services Run-From-Zip feature, this was fixed in Cake.Kudu.Client version 0.6.0 you can read more about that at the post below

Cake.Kudu.Client version 0.6.0 released_This version fixes a breaking change in the Azure App Services Run-From-Zip web app deployment feature._medium.com

A couple of days ago Azure announced that they in preview added a new way to do app services deployments called Run-From-Zip, which lets you deploy using a zip file.

Deploying using a zip file as been possible before, the difference with this new method is that the file isn’t extracted into the “wwwroot” directory, but instead the zip file mounted read only as “wwwroot”.

The zip file can either be hosted externally from the site or in a special folder on the app service itself, and the latter is now what the “Kudu Client” Cake addin now supports — enabling you to use this new method of deployment in your Cake build scripts.

Prerequisites

To enable Run-From-Zip deployments you’ll first need to set an application setting called WEBSITE_USE_ZIP, you either set this to an url when deploying from an external source, or in this case just set it to 1.

ZipRunFromDirectory

Naming things is hard, but the addin now has a method called ZipRunFromDirectory, which will do all the “heavy lifting” and deploy a local directory.

Example usage

So deploying a site using this new method just becomes a couple of lines of code

The file path returned, is the zip file deployed to the app service.

Behind the curtain

So what does actually happen here? In a nutshell the method will:

  1. In memory zip source directory
  2. Push that zip to d:\home\data\SitePackages to a unique date stamped file name
  3. Push the filename of the zip to d:\home\data\SitePackages\siteversion.txt
  4. Via Kudu API call the site to ensure it’s up and right version deployed (a file called KuduClientZipRunFromDirectoryVersion.txt is included in deployed zip for this purpose)
  5. Return the remote path of the deployed zip

Closing thoughts

I’ve tried this for a couple of days now, and have found deployments to be very stable and quick. But really need some more testing to see what the implications of running this in production, how existing apps behave in a read only mode, etc.

This is a shiny new feature still in preview, general guidance and tooling support isn’t quite there yet, but as you seen with this post the primitives are in place to build upon and refine the experience in the future!

Introducing Cake Kudu Client_Ship remotely to Azure App Services using Cake_hackernoon.com


Published by HackerNoon on 2018/02/16