United Kingdom: +44 (0)208 088 8978

Deploying code and infrastructure through Farmer

A challenge with Infrastructure as code

Something that developers new to cloud development and infrastructure often find challenging is realising that there are two stages to repeatable deployments in Azure:

  • Creating infrastructure that can host your web application
  • Creating your application and then deploying it into that infrastructure

There are a myriad of ways to achieve both of these in Microsoft Azure and the choices can sometimes be overwhelming. Do you use the Azure Powershell Cmdlets for one and the Azure CLI for another? In my experience, many developers give up and fall back to creating infrastructure manually and deploying via "right-click publish".

Treating Infrastructure and Applications as one

When we started the Farmer project we quickly realised that we only solved half of the problem - creating infrastructure becomes much easier, but we hadn't addressed the problem of then deploying your code after the infrastructure has been created. Now, with the 0.8.0 release of Farmer you can also deploy code as well as infrastructure as part of your templates.

open Farmer
open Farmer.Resources

// Create a web application
let myFirstApp = webApp {
    name "farmervideo"
    zip_deploy @"C:\Code\MyWebApp\publish"

// Attach it to a deployment
let deployment = arm {
    location NorthEurope
    add_resource myFirstApp

// Push out to Azure
|> Deploy.quick "farmer-video-rg"

The key part to observe here is the zip_deploy command, which signals that Farmer should zip and upload the contents of the specified folder automatically, once the infrastructure itself has been deployed. This allows you to unify your application deployment of infrastructure and code as one.

This short video shows you step-by-step how to do this.


We're excited at the direction that Farmer is going in and are looking forward to pushing more changes in the future in this vein.

Have (fun () -> ())!