RousselTMLEARNING

TP · Microsoft Azure: from discovery to expertise

Lab: Infrastructure as Code with Bicep (local validation and what-if)

What you will learn in this TP
  • Write a parameterised Bicep module
  • Validate with bicep build, lint and rules
  • Preview with what-if and deploy

Introduction #

What you will learn in this section
  • Write a parameterised Bicep module
  • Validate with bicep build, lint and rules
  • Preview with what-if and deploy

Context. The team wants every environment described as code and checked before deployment. You write and test the template locally.

Prerequisites: Azure CLI with Bicep (az bicep install); PSRule for Azure optional; a trial subscription only for the last two steps  ·  Estimated time: 45 min

A parameterised Bicep template, validated locally and ready for pipeline deployment.

Hands-on #

Guided steps, with their solution.

  1. 1. Write the template

    Why? Decorators (@allowed, @minLength) reject bad values before any deployment.

    Create main.bicep: ZRS storage in production and LRS otherwise, public access disabled, Linux App Service plan and outputs.
  2. 2. Compile and analyse

    Why? The linter flags bad practices (secrets in outputs, old API versions, hard-coded locations).

    Compile to ARM JSON, run the linter and inspect the generated JSON.
  3. 3. Test security rules

    Why? PSRule for Azure checks the template against the Well-Architected Framework without any subscription.

    Analyse the template with PSRule (container) and fix a warning if needed.
  4. 4. Preview and deploy (trial subscription)

    Why? What-if shows exactly what will change; a second identical deployment changes nothing (idempotence).

    Create a group, run what-if, deploy, run what-if again then delete the group.

Difficulty level : ●●●○○ (3/5)

My progress

  • ⏱ Estimated time : ≈ 45 min

Sign in to track your progress and take notes. Sign in

💬 Ask a question

Recommended Articles

Infrastructure as Code sur Azure : Bicep, Terraform, Cost Management et Well-Architected

Décrire et déployer Azure en code avec Bicep (modules, paramètres, what-if, déploiements par pipe...

Le calcul sur Azure : machines virtuelles, App Service, Functions et conteneurs

Choisir et utiliser le calcul Azure : machines virtuelles et groupes identiques (VMSS), App Servi...

Les modules Terraform : concevoir, versionner et réutiliser

Structurer Terraform avec des modules : module racine et modules enfants, entrées et sorties, sou...

Le stockage Azure : comptes de stockage, Blob, Files, disques et redondance

Stocker des données sur Azure : comptes de stockage, Blob (niveaux chaud, froid, archive, cycle d...

Tester et sécuriser Terraform : validate, terraform test, tflint, Checkov et politiques

Garantir la qualité du code Terraform : fmt et validate, tests natifs terraform test avec fournis...

Terraform en CI/CD : pipelines, revue du plan, OIDC et GitOps

Automatiser Terraform : pipeline plan sur demande de fusion et apply après approbation, publicati...

Bonnes pratiques Azure : landing zone, sécurité, fiabilité et coûts

Les bonnes pratiques pour exploiter Azure en production : landing zone et groupes d'administratio...

Le langage HCL : ressources, variables, sorties, données et expressions

Écrire du Terraform : blocs terraform, provider, resource et data, variables typées avec validati...

Préparer la certification Microsoft Azure Fundamentals (AZ-900)

Guide de préparation à l'AZ-900 : format, trois domaines et leurs pondérations, notions à maîtris...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!