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

Abstract:
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

Bio:
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/

0754d30f3acc99a940aebdcd49d5af97?s=128

Azure Zurich User Group

February 09, 2021
Tweet

Transcript

  1. ARM Templates made easy

  2. 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
  3. 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
  4. Agenda • Creating Infrastructure in Azure today • ARM Templates

    • Farmer – Who, what, why and how? • Automation with Farmer • How do I get started?
  5. Azure Deployment Today

  6. Why don’t we automate infrastructure? People often do software CI/CD

    People rarely do infrastructure CI/CD
  7. Why not?

  8. Azure Infrastructure options today

  9. 1. Use the portal, Luke • Easy to get started

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

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

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

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

    of Azure resources Cross platform Cross tool support Deployment recording and auditing
  15. Why not ARM? Already using ARM templates Deployment experience: positive

    Authoring experience: not positive
  16. 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.
  17. 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
  18. ARM Templates – The Bad Expensive to create & maintain

    Error prone Weakly typed Low level of abstraction Limited capabilities
  19. 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
  20. Tooling to the rescue! Language Server! Code Completion! Snippets! Schema

    Verification!
  21. We can do much better than this VS Code only

    Limited set of outdated schemas Discoverability is lacking Code Snippets? JSON?
  22. 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
  23. What is Farmer? A library that makes repeatable Azure deployments

    easy
  24. What is Farmer? An easy-to-learn library for rapidly authoring and

    deploying entire Azure architectures via ARM templates and Azure CLI
  25. 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
  26. Who is Farmer aimed at? Azure Newcomers Teams using ARM

    templates Dynamic Deploy
  27. Features of Farmer Productive Type safe Runs on .NET Core

    Open Source Commercially Supported Extensible Backwards compatible with ARM templates
  28. 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
  29. 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
  30. DEMO TIME!

  31. 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.)
  32. .NET and Benefits Proper programming language Huge ecosystem – NuGet

    packages Compiler and SDK IDEs, refactorings, Intellisense etc. Flexibility
  33. ARM Ecosystem and Benefits Azure CLI Portal Visualisation Tools Deployment

  34. Yes, Farmer uses F# Farmer is a DSL on top

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

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

    linked templates (yet?) Doesn’t support every feature of every resource
  37. 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?
  38. 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?
  39. Modelling ARM types

  40. Modelling ARM types

  41. Modelling ARM types

  42. Modelling ARM types

  43. Modelling ARM types

  44. Modelling ARM types

  45. Modelling ARM types

  46. Modelling ARM types

  47. 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
  48. 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
  49. 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
  50. 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.
  51. 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
  52. None
  53. Useful Links • https://compositionalit.github.io/farmer/ • https://github.com/compositionalit/farmer • https://www.compositional-it.com/consultancy/farmer/ • https://docs.microsoft.com/en-us/dotnet/fsharp/

  54. Thank you ☺ • Questions? • Email me isaac@compositional-it.com •

    Twitter @isaac_abraham