Upgrade to Pro — share decks privately, control downloads, hide ads and more …

February 2021: Repeatable Deployments with Farmer by Isaac Abraham

February 2021: Repeatable Deployments with Farmer by Isaac Abraham

Link to the recording: https://www.youtube.com/watch?v=vXw5u12q0OI

Azure Resource Manager templates have made repeatable deployments on Azure a reality. However, the true cost of these templates is the cost of authoring them, generally involving painstaking and error-prone management of JSON files.

Whilst improvements in tooling have helped ameliorate this problem, there's a need to rethink how we create ARM templates, which is where the Farmer project comes in.

In this session you'll be exposed to the following:

* Learn about the basics of ARM templates and the value proposition behind them
* Understand the cost of working with ARM templates
* See how we can use a .NET domain specific language (DSL) to rapidly author and work with ARM templates.
* See common use cases and cost-benefit of ARM templates
* Look at ways of dealing with elements such as parameterisation and variables through a programming language rather than through JSON and stringly-typed expressions
* Discuss how to deploy ARM templates through repeatable continuous integration and deployment tools

Isaac Abraham is the author of Get Programming with F# and the director of Compositional IT. As a Microsoft MVP and.NET developer since .NET 1.0, he specializes in consultancy, training and development, helping customers adopt high-quality, functional-first solutions on the .NET platform. He is especially interested in cloud computing and distributed compute challenges.

More information about me can be found on https://www.linkedin.com/in/isaacabraham/

Azure Zurich User Group

February 09, 2021

More Decks by Azure Zurich User Group

Other Decks in Programming


  1. About me • Founder of Compositional IT • F# and

    Azure Consultancy, Training and Development • .NET developer since the beginner • F# user for a five-ish years now • From London UK, now lives in Hessen Germany
  2. About you • I can’t easily do a “show of

    hands”  • I imagine some of you are .NET developers • Some of whom know something about F# • Some of whom know something about Azure
  3. Agenda • Creating Infrastructure in Azure today • ARM Templates

    • Farmer – Who, what, why and how? • Automation with Farmer • How do I get started?
  4. 1. Use the portal, Luke • Easy to get started

    • Not repeatable • Doesn’t scale • Time consuming • Doesn’t always apply to code
  5. 2. Right-click, Publish • Relatively easy to start • Infrastructure

    + Code • Not repeatable • Doesn’t scale well • Limited use cases
  6. 3. Code-focused deployments Microsoft •PowerShell •Azure CLI •.NET Fluent SDK

    •REST API •ARM Templates Other •Terraform •Pulumi
  7. Code-focused services Azure REST API PowerShell Azure CLI .NET Fluent

    API State Services Pulumi, Terraform Resource Manager API ARM Template
  8. ARM Templates – The Good Idempotent deployments Support for lots

    of Azure resources Cross platform Cross tool support Deployment recording and auditing
  9. Why not ARM? ARM Experts • It’s working – awesome!

    • But it took ages to get it right  ARM Beginners • This ARM thing looks interesting… • I give up. Back to Azure Portal.
  10. How do people figure out ARM today? • Look up

    a sample for a resource you need • Spend the next hour trying to pull out the bits that you actually need Azure Samples 101 • Read blogs • Check Stack Overflow Community • If it works, try to figure out what is going on Generate manually and reverse-engineer a template • Hope it all makes sense! Official docs
  11. ARM Templates – The Bad Expensive to create & maintain

    Error prone Weakly typed Low level of abstraction Limited capabilities
  12. ARM Templates - The Ugly Lots of documentation required to

    create trivial templates Documentation is outdated, unreliable and poor Inconsistent experience across resources Slow to validate and fix
  13. We can do much better than this VS Code only

    Limited set of outdated schemas Discoverability is lacking Code Snippets? JSON?
  14. This is not the answer! • This kind of tooling

    and code generation is a band-aid • We need to rethink how we work with ARM templates • Quicker to author • Quicker to read and understand • Cheaper to maintain • More powerful
  15. What is Farmer? An easy-to-learn library for rapidly authoring and

    deploying entire Azure architectures via ARM templates and Azure CLI
  16. What does Farmer offer? Rapidly author ARM templates Rapidly deploy

    ARM templates Focus on high- level concepts Escape hatches if you need to “drop down” a level
  17. Features of Farmer Productive Type safe Runs on .NET Core

    Open Source Commercially Supported Extensible Backwards compatible with ARM templates
  18. Farmer Architecture Builders Web Application ARM Resources Server Farm Web

    App App Insights In-memory Template Resources Secure Parameters Outputs Emit Generate ARM template Deploy to Azure Post Deploy Tasks Deploy application code
  19. Example common ARM tasks 1. Create a storage account 2.

    Change the SKU 3. Create a web app 4. Make the web app depend on the storage account 5. Add a setting to the web app 6. “Link” two resources together 7. Parameterise the resource 8. Use a variable to make consistent resource names
  20. Use Cases for Farmer Authoring ARM templates Deploying ARM templates

    As part of a build script (CAKE, FAKE etc.) CI/CD pipelines e.g. DevOps etc. As part of a running application (on-demand deployments etc.)
  21. .NET and Benefits Proper programming language Huge ecosystem – NuGet

    packages Compiler and SDK IDEs, refactorings, Intellisense etc. Flexibility
  22. Yes, Farmer uses F# Farmer is a DSL on top

    of F# It’s REALLY not difficult No, really!
  23. Yes, Farmer uses F# Can be consumed from C# New

    abstractions can be created in C# F# is not hard to learn!
  24. What can’t Farmer do? No arbitrary parameters No variables No

    linked templates (yet?) Doesn’t support every feature of every resource
  25. Future Plans for Farmer Support for more ARM resources •

    Already 75-100 supported Subscription-level resources More typing • Smarter validation • Reduce errors through types • Stay pragmatic Improve API ergonomics Extra modules for “embedded” data • Azure Data Factory (ADF) • Logic Apps (LA) • Azure Active Directory (AAD) B2C “Live” reference data • Live list of VM images from marketplace?
  26. Modelling ARM types – Storage SKU • Kind • General

    Purpose (two version) / Files / Blob / Block Blob • Replication • Local, Zone Redundant, Geo Redundant etc. (5 kinds) • Performance Tier • Standard or Premium • What are the valid combinations?
  27. Farmer is opinionated • We don’t want to support everything

    in ARM • We are targeting (for now!) the 80/20 space • 80% of use cases • 20% of effort
  28. How do I get started? 1. Download .NET Core 2.

    Download VSCode + F# extension / VS2019 / Rider 3. dotnet new –i Farmer.Template 4. dotnet new Farmer 5. Check out the docs
  29. What about Pulumi? • Pulumi is excellent tech • You

    should definitely try it out • Farmer is not a direct compete with it • Single platform (Azure) • Directly coupled to ARM templates • Get all ARM features for free e.g. state management, deployment history, visualisation etc. • Single language (F#) • Hand-crafted, highly practical abstractions vs auto generated
  30. What about Bicep? • Slimmer version of ARM json •

    1:1 mapping between ARM and Bicep abstractions • Supports all resources out of the box • No opportunity for higher level abstractions or simplifications • Definitely looks better than raw ARM • Not Turing-complete • Still alpha (6-12 months till v1?) • Building a completely new ecosystem • Language design, CLI tooling, IDE tooling, compiler, parser etc.
  31. How can you get involved? • Try it out! •

    Contribute to the project • Give feedback • Missing resources that you need • Features of resources that you need • Things that were confusing • Things that simply don’t work! • Documentation • Add new resources or features • Share knowledge of Farmer with others