IaaC: Bicep Intro

The Microsoft Azure team on Aug 29, 2020 released the Bicep V0.1.1 alpha release, which is a domain-specific language (programming language with a higher level of abstraction optimized for a specific class of problems). Bicep purpose is to simplify the creation of Resource Manager templates

Why not manually through Azure Portal?

  • More confidence to deploy. Some scripts to re-deploy all your cloud resources if needed
  • Deploy to DTAP (DEV->TST-> ACC-> PRD) in a structure way
  • Better digest how Azure resources work & connect together

Imperative vs Declarative code
[Execute a sequence of commands in a specific order, to reach an end] vs [Specify only the end configuration].
During your development with the imperative way, the commands may be updated or deprecated. So that would imply you need to plan a review of that code in often periods of time. When using the declarative way, you don’t specify how to deploy an Azure resource. You declare how the resource needs to look. Azure decides the steps needed to be executed behind the scenes.

“Azure Resource Manager” Control Room
The service used to deploy and manage resources in Azure, which is used to create – update – delete resources in your Azure subscription. The resource manager receives a request from any of Azure tools, APIs, or SDKs and then forwards it to the Azure resource provider.

In the below example, we follow some steps to create an Azure storage account:
a-Set tag, so I can get later insights on my Azure resources.
b-Set variables, so I can re-use a logic based on a name prefix.
c-Create a storage account, based on the storageaccount variable, location of the deployed resourcegroup and the tagValues parameter.

// Set tags
param tagValues object = {
Owner:’John@wizardbi.nl’
State:’Active’
Createdby: ‘George@wizardbi.nl’
Purpose:’ProjectX’
Department:’DigitalImprovement’ }

// set variables
var namePrefix = ‘wizardbidev01’
var storageaccount= ‘sa${namePrefix}’

// Create storage account
resource sasqlbits2023dev01 ‘Microsoft.Storage/storageAccounts@2022-09-01’ =
{
name: storageaccount
location:resourceGroup().location
sku: { name:’Standard_LRS’ }
kind: ‘StorageV2’ tags: tagValues
}

Resources:

  1. https://github.com/Azure/bicep
  2. https://learn.microsoft.com/en-us/training/paths/fundamentals-bicep/

Posted

in

by

Tags: