{
  "$type": "site.standard.document",
  "canonicalUrl": "https://johnnyreilly.com/posts/hello-world-bicep",
  "description": "Bicep simplifies Azure Resource Management through concise syntax. The \"Hello World\" example highlights how Bicep outperforms ARM templates.",
  "path": "/posts/hello-world-bicep",
  "publishedAt": "2021-04-10T00:00:00.000Z",
  "site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
  "tags": [
    "bicep",
    "azure"
  ],
  "textContent": "Bicep makes Azure Resource Management a great deal simpler than ARM templates. The selling point here is grokkability. This post takes a look at the \"Hello World\" example recently added to the Bicep repo to appreciate quite what a difference it makes.\n\n\n\nMore than configuration\n\nThe \"Hello World\" added to the Bicep repo by Chris Lewis illustrates the simplest usage of Bicep:\n\n> This bicep file takes a yourName parameter and adds that to a hello variable and returns the concatenated string as an ARM output.\n\nThis is, when you consider it, the very essence of a computer program. Taking an input, doing some computation and providing an output. When I think about ARM templates, (and because Bicep is transpiled into ARM templates I mentally bracket the two together) I tend to think about resources being deployed. I focus on _configuration_, not _computation_\n\nThis is an imperfect mental model. ARM templates can do so much more than deploy by slinging strings and numbers. Thanks to the wealth of template functions that exist they have much more power. They can do computation.\n\nThe Hello World example focuses just on computation.\n\nFrom terse to verbose\n\nThe Hello World example is made up of two significant files:\n\n1. main.bicep - the bicep code\n2. main.json - the ARM template compiled from the Bicep file\n\nThe main.bicep file amounts to 3 lines of code (I have omitted the comment line):\n\n- the first line takes the _input_ of yourName\n- the second line declares a hello variable\n- the third line _computes_ the new value of helloWorld based upon hello and yourName, then passes it as _output_\n\nGosh is it ever simple. It's easy to read and it's simple to understand. Even if you don't know Bicep, if you've experience in another language you can likely guess what's happening.\n\nLet's compare this with the main.json that main.bicep is transpiled into:\n\nThe above ARM template expresses exactly the same thing as the Bicep alternative. But that 3 lines of logic has become 27 lines of JSON. We've lost something in the transition. Intent is no longer clear. We've gone from something easy to reason about, to something that is hard to reason about. You need to think a lot less to write the Bicep alternative and that's a _good_ thing.\n\nI was chatting to someone recently who expressed it well by saying:\n\n> ARM is the format that the resource providers understand, so really it’s the Azure equivalent of Assembler – and I don’t know anyone who enjoys coding in Assembler.\n\nThis is a great example of the value that Bicep provides. If you'd like to play with the Hello World a little, why not take it for a spin in the Bicep playground.",
  "title": "Hello World Bicep"
}