Azure Resource Manager Templates Quick Start Guide

Book description

Compose and decompose ARM templates and use advanced concepts like looping, conditions, dependencies, PowerShell and Desired State Configuration.

Key Features

  • Design, implement, and unit test ARM templates
  • Develop and deploy ARM templates following security best practices

Book Description

Azure Resource Manager (ARM) templates are declarations of Azure resources in the JSON format to provision and maintain them using infrastructure as code. This book gives practical solutions and examples for provisioning and managing various Azure services using ARM templates.

The book starts with an understanding of infrastructure as code, a refresher on JSON, and then moves on to explain the fundamental concepts of ARM templates. Important concepts like iteration, conditional evaluation, security, usage of expressions, and functions will be covered in detail.

You will use linked and nested templates to create modular ARM templates. You will see how to create multiple instances of the same resources, how to nest and link templates, and how to establish dependencies between them.

You will also learn about implementing design patterns, secure template design, the unit testing of ARM templates, and adopting best practices.

By the end of this book, you will understand the entire life cycle of ARM templates and their testing, and be able to author them for complex deployments.

What you will learn

  • Understand the foundations of ARM templates including nested and linked templates
  • Design, create, and unit test ARM templates using best practices
  • Learn about conditional deployments, looping, Custom Script Extensions using PowerShell, Bash, and DSC
  • Implement design patterns related to ARM templates
  • Run post-deployment PowerShell and Desired State Configuration scripts
  • Create solutions and deploy them on Azure using ARM templates

Who this book is for

This books is for developers, DevOps engineers, and architects who have experience in Azure.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Azure Resource Manager Templates Quick Start Guide
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Foreword
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Section 1: ARM Template Foundational Skills
  8. Infrastructure as Code and Configuration Management
    1. What is configuration management?
    2. Infrastructure as Code
    3. What are ARM templates?
    4. Designing ARM templates
    5. A brief primer on JSON
    6. Azure Resource Manager
      1. Provisioning
        1. Parallel
        2. Multi-region
        3. API-driven
        4. Automation
      2. Management
        1. Tags
        2. Resource groups
        3. Hierarchical
      3. Monitoring
        1. Logs
        2. Alerts
        3. Actions
      4. Governance
        1. Role-based access control
        2. Policies
        3. Locks
    7. Summary
  9. Azure Resource Manager Templates
    1. Setting up the development environment
      1. Using Visual Studio 2017 as a development environment
      2. Using Visual Studio Code as a development environment
    2. ARM template structure
    3. Writing your first template
    4. Template deployment
      1. Deployment using Azure portal
      2. Deployment using the Azure CLI
      3. Deployment using PowerShell
        1. Understanding Complete and Incremental deployment
          1. How does Incremental take care of these differences?
          2. How to create and apply configuration in the case of Complete deployments
    5. Parameters
      1. Structure of a parameter in an ARM template
      2. Referencing a parameter within a template
      3. Grouping parameters
    6. Variables
      1. Accessing variables
    7. Summary
  10. Understanding Core Elements of ARM Templates
    1. ARM template expressions
    2. ARM template functions
    3. Resources
      1. Resource names
      2. Resource types
      3. API Version
      4. Resource properties
      5. Resource locations
      6. Resources and nested resources
      7. Outputs
    4. A complete template
    5. Nesting resources
    6. Understanding dependsOn
    7. Using references
    8. Understanding resourceId
    9. Using linked templates
    10. Nested templates
    11. Summary
  11. Advance Template Features
    1. Creating multiple instances of a resource type
    2. Creating multiple instances of a resource type, using Serial mode
    3. Creating multiple instances of a resource property
    4. Using copy to generate multiple variables
    5. Conditions in ARM templates
      1. Conditions that return a Boolean value
      2. Conditions that return condition values
    6. Advanced deployments
      1. Using copy with deployment resources
      2. Creating resource groups, using ARM templates
      3. Deploying resources into multiple resource groups, using the deployment resource
      4. Deploying resources into multiple resource groups in multiple subscriptions
      5. Creating Nested Deployments
    7. Summary
  12. Section 2: ARM Template Advanced Concepts
  13. IaaS Solutions Using Templates
    1. Configuration inside an Azure virtual machine
    2. Protecting scripts using SAS tokens
    3. Using protectedSettings
    4. CustomScriptExtension as separate resource
      1. Getting output from CustomScriptExtension
      2. Using CustomScriptExtension with Linux virtual machines
      3. Desired State Configuration
      4. Using configuration data
    5. Summary
  14. Unit Testing ARM Templates
    1. Unit testing
    2. Unit testing ARM templates
    3. Retrieving outputs from ARM templates
    4. Using Pester
    5. Setting up the test harness
      1. Unit testing of a storage account
      2. Unit testing a public IP address
      3. Unit testing virtual networks
      4. Unit testing an NIC
      5. Unit testing a virtual machine
      6. The complete unit test script
    6. Summary
  15. Design Patterns
    1. Why use modular ARM templates?
      1. Single responsibility principle
      2. Known configuration/T-shirt sizing
    2. Scenario
    3. Technical prerequisites
      1. Setting up Azure login and subscription
      2. New resource group
      3. Creating an Azure Storage Account
      4. Creating an Azure Storage blob container
      5. Generating an Azure Storage SAS token
      6. Uploading ARM templates to storage
      7. Creating an Azure Key Vault
      8. Creating secrets in Key Vault
      9. Creating the Azure AD Service Principal
      10. Assigning permissions to a Service Principal on Key Vault
    4. Deploying the solution
      1. Log to Azure using Service Principal
      2. Deploying the ARM template
    5. Template patterns
      1. Modular ARM templates
        1. Generalized templates
        2. Azure SQL template
        3. App service plan template
        4. Azure App Services template
      2. Using Key Vault for passwords and secrets
      3. Static usage of Key Vault information
      4. Dynamic declaration of Key Vault information
      5. Dependencies between resources
      6. Creating multiple resources in loop
      7. Tagging of resources
      8. Runtime sharing of property values
    6. Redefining resources in the same template
    7. Summary
  16. ARM Template Best Practices
    1. Use resourceId function
    2. Generate Resource Identifier used multiple times
    3. Use Comments
    4. Use Tags for resources and resource groups
    5. Use parameters sparingly
    6. Group related parameters
    7. Order parameters alphabetically
    8. Constraint parameters if possible
    9. Parameter's defaultValue and API versions
    10. Declare All Resources as top-level resources
    11. Output Resource Properties and Configuration
    12. Resource-naming conventions
    13. Storage of Linked templates
    14. Resource Dependencies
    15. Using Key Vaults for secrets
    16. Using ContentVersion
    17. Deployment – Best Practices
    18. Summary
  17. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Azure Resource Manager Templates Quick Start Guide
  • Author(s): Ritesh Modi
  • Release date: February 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789803235