0%

The ultimate guide to becoming proficient in Azure Bicep while having a better development experience and making your Infrastructure as Code seamless and error free

Key Features

  • Learn Azure Bicep from an official Microsoft trainer
  • Master the authoring experience to make your Infrastructure as Code journey seamless
  • Go beyond writing good templates with the help of advanced tips and tricks

Book Description

It's no secret that developers don't like using JSON files to declare their resources in Azure because of issues such as parameter duplication and not being able to use comments in templates. Azure Bicep helps resolve these issues, and this book will guide you, as a developer or DevOps engineer, to get the most out of the Bicep language.

The book takes you on a journey from understanding Azure Resource Manager (ARM) templates and what their drawbacks are to how you can use Bicep to overcome them. You will get familiar with tools such as Visual Studio Code, the Bicep extension, the Azure CLI, PowerShell, Azure DevOps, and GitHub for writing reusable, maintainable templates. After that, you'll test the templates and deploy them to an Azure environment either from your own system or via a continuous integration and continuous delivery (CI/CD) pipeline. The book features a detailed overview of all the Bicep features, when to use what, and how to write great templates that fit well into your existing pipelines or in a new one. The chapters progress from easy to advanced topics and every effort has been put into making them easy to follow with examples, all of which are accessible via GitHub.

By the end of this book, you'll have developed a solid understanding of Azure Bicep and will be able to create, test, and deploy your resources locally or in your CI/CD pipelines.

What you will learn

  • Get started with Azure Bicep and install the necessary tools
  • Understand the details of how to define resources with Bicep
  • Use modules to create templates for different teams in your company
  • Optimize templates using expressions, conditions, and loops
  • Make customizable templates using parameters, variables, and functions
  • Deploy templates locally or from Azure DevOps or GitHub
  • Stay on top of your IaC with best practices and industry standards

Who this book is for

This book is for cloud engineers, developers, and DevOps engineers who are responsible for writing templates to deploy resources in Microsoft Azure and contributing to CI/CD pipelines. Professionals who want to get started with DevOps and Infrastructure as Code when it comes to working with Microsoft Azure will also benefit from reading this book. Readers are expected to have a basic understanding of CI/CD concepts, must have worked with ARM templates to deploy resources to Azure, and must have used or be familiar with Azure DevOps or GitHub Actions for their CI/CD pipelines.

Table of Contents

  1. Infrastructure as Code with Azure Bicep
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewer
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  7. Section 1: Getting Started with Azure Bicep
  8. Chapter 1: An Introduction to Azure Bicep
    1. Technical requirements
    2. What is Azure Bicep?
    3. IaC
    4. ARM templates
    5. Azure Bicep
    6. Why was it created?
    7. Why create a new revision?
    8. What about current third-party tools?
    9. How does it work?
    10. Authoring experience
    11. What happens to my ARM templates?
    12. Bicep CLI
    13. Summary
  9. Chapter 2: Installing Azure Bicep
    1. Technical requirements
    2. Cross-platform installation
    3. Installing the Azure CLI
    4. Installing Bicep using the Azure CLI
    5. Installing Bicep using Azure PowerShell
    6. Installation on Windows
    7. Installation using Windows Installer
    8. Installation using Chocolatey
    9. Installation using winget
    10. Manual installation using PowerShell
    11. Manual installation on macOS
    12. Installing Bicep via Homebrew
    13. Installing Bicep via Bash
    14. Manual installation on Linux
    15. Getting nightly builds
    16. Working with Bicep in a Docker container
    17. Working with an Azure CLI Docker container
    18. Summary
  10. Chapter 3: Authoring Experience
    1. Technical requirements
    2. Bicep extension for Visual Studio Code
    3. Installing Visual Studio Code
    4. Installing the Bicep extension
    5. Snippets offered by the Bicep extension
    6. Refactoring
    7. Formatting
    8. Using quick fixes
    9. Configuring the Bicep linter
    10. Customizing the linter
    11. Using the Bicep CLI to use the linter
    12. Bicep Playground
    13. Compiling Bicep snippets
    14. Decompiling an ARM template
    15. Using sample templates in Bicep Playground
    16. Summary
  11. Chapter 4: Compiling and Decompiling Bicep Files
    1. Technical requirements
    2. Compiling Bicep files
    3. Compiling a Bicep file using the Bicep CLI
    4. Compiling and deploying a Bicep file using the Azure CLI
    5. Compiling and deploying a Bicep file using Azure PowerShell
    6. Troubleshooting possible errors and warnings
    7. An invalid template
    8. Linter errors
    9. Decompiling ARM templates into Bicep
    10. Using the Azure CLI
    11. Using the Bicep CLI
    12. Potential fixes after decompiling
    13. Exporting templates and decompiling
    14. Summary
  12. Section 2: Azure Bicep Core Concepts
  13. Chapter 5: Defining Resources
    1. Technical requirements
    2. Resource definition
    3. Common properties
    4. Resource-specific properties
    5. Adding additional properties
    6. Referencing existing resources
    7. Referencing a resource that is in the same file
    8. Referencing an already deployed resource
    9. Explicit dependencies
    10. Visualizing dependencies
    11. Resource scopes
    12. Resource group
    13. Subscription
    14. Management group
    15. Tenant
    16. Setting the scope at the resource level
    17. Multi-scope Bicep files
    18. Global functions
    19. Bicep language specification
    20. Structure
    21. Whitespaces
    22. Comments
    23. Bicep type system
    24. Supported data types
    25. Simple types
    26. Objects
    27. Arrays
    28. Union types
    29. ARM and Bicep syntax comparison
    30. Best practices for Bicep syntax
    31. Summary
  14. Chapter 6: Using Parameters, Variables, and Template Functions
    1. Technical requirements
    2. Parameters
    3. Minimalistic definition
    4. Setting default values
    5. Using decorators
    6. Using parameters within a Bicep template
    7. Passing parameters during deployment
    8. Variables
    9. Defining variables
    10. Using variables
    11. Configuration variables
    12. Template functions
    13. The any function
    14. Date functions
    15. The bool function
    16. Deployment functions
    17. Numeric functions
    18. Array functions
    19. Object functions
    20. Resource functions
    21. String functions
    22. Summary
  15. Chapter 7: Understanding Expressions, Symbolic Names, Conditions, and Loops
    1. Technical requirements
    2. Understanding expressions
    3. Unary operators
    4. Comparison operators
    5. Logical operators
    6. Numeric operators
    7. Accessor operators
    8. Operator precedence and associativity
    9. Exploring conditions
    10. Deploy condition
    11. New or existing resource
    12. Runtime checks
    13. Diving into resource iterations
    14. Syntax
    15. Loop index
    16. Loop array
    17. Loop array and index
    18. Nested loops with conditions
    19. Using batches
    20. Summary
  16. Chapter 8: Defining Modules and Utilizing Outputs
    1. Technical requirements
    2. Modules
    3. Defining modules
    4. Consuming a module
    5. Additional considerations
    6. Defining and configuring module scopes
    7. Using Bicep outputs
    8. Defining outputs
    9. Conditional outputs
    10. Returning multiple outputs with loops
    11. Module outputs
    12. Getting output values after deployment
    13. Summary
  17. Section 3: Deploying Azure Bicep Templates
  18. Chapter 9: Deploying a Local Template
    1. Technical requirements
    2. Deploying Bicep with Azure PowerShell
    3. Connecting to your Azure environment
    4. Previewing changes with the what-if operation
    5. Passing parameters
    6. Deployment scopes
    7. Deploying Bicep with the Azure CLI
    8. Connecting to your Azure environment
    9. Preview changes with what-if operation
    10. Passing parameters
    11. Deployment scopes
    12. Troubleshooting possible errors and warnings
    13. Compile-time errors and warnings
    14. Deployment-time errors
    15. Summary
  19. Chapter 10: Deploying Bicep Using Azure DevOps
    1. Technical requirements
    2. Creating the Azure DevOps pipeline
    3. Prerequisites
    4. Creating a pipeline in Azure DevOps
    5. Adding a validation step to our pipeline
    6. Validating the deployment
    7. Deploying the template
    8. Adding the deployment step
    9. Pushing the changes to your repository
    10. Accessing the deployment output in the pipeline
    11. Receiving outputs from a deployment
    12. An alternative approach to accessing deployment outputs
    13. Summary
  20. Chapter 11: Deploying Bicep Templates Using GitHub Actions
    1. Technical requirements
    2. Creating a GitHub action
    3. Prerequisites
    4. Creating the workflow from code
    5. Adding validation steps to the workflow
    6. Adding an Azure CLI action to the workflow
    7. Adding deployment steps to the workflow
    8. Using the official Azure ARM action
    9. Adding the Azure ARM action to the workflow
    10. Accessing deployment outputs for later use
    11. Accessing outputs from the Azure CLI action
    12. Accessing outputs from the Azure ARM action
    13. Summary
  21. Chapter 12: Exploring Best Practices for Future Maintenance
    1. Technical requirements
    2. Applying version control and code flows for your IaC
    3. Single pipeline approach
    4. Separate pipelines for code and infrastructure
    5. Source control everything
    6. Idempotency and its importance
    7. Idempotency
    8. Immutability
    9. Modularity and microservices
    10. Bicep best practices
    11. Parameters
    12. Variables
    13. Resource definitions
    14. Outputs
    15. Configuration set
    16. Shared variable file
    17. Managing service version updates
    18. Azure Bicep's known limitations
    19. Single-line objects and arrays
    20. Newline sensitivity
    21. No support for API profiles
    22. CLI limitations
    23. Summary
    24. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
44.200.39.110