Helion


Szczegóły ebooka

Infrastructure as Code with Azure Bicep

Infrastructure as Code with Azure Bicep


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.

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