Featured resource
Forrester Wave Report 2025
Pluralsight named a Leader in the Forrester Wave™

Our tech skill development platform earned the highest scores possible across 11 criteria.

Learn more
  • Labs icon Lab
  • Cloud
Azure icon
Labs

Setting Up Remote State Storage

Welcome to the Setting Up Remote State Storage lab. In this lab, we will cover three objectives: 1. Create an Azure Storage Account 1. Deploy a virtual network with the local backend 1. Update the backend and migrate state data By the end of this lab, you will know how to configure a Terraform deployment to use the `azurerm` backend and how to migrate existing state data.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon May 02, 2024

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create an Azure Storage Account

    In this objective, you'll create an Azure Storage account using Terraform. Make sure to include the storage account name in the outputs.

    1. Log into Azure using the Azure CLI.
    2. Create a new folder to hold a Terraform Configuration to deploy a storage account.
    3. Add a provider block for the azurerm provider with skip_provider_registration and storage_use_azuread set to true.
    4. Add the existing resource group as a data source.
    5. Create a random integer resource to generate a unique storage account name.
    6. Create an Azure Storage account with the following settings:
      • HTTPS traffic only: Enabled
      • Shared access key: Disabled
      • Default to OAuth authentication: Enabled
    7. Create a container in the storage account named tfstate.
    8. Initialize and deploy the Terraform configuration.
    9. Make note of the storage account name for the next objective.
  2. Challenge

    Deploy a Virtual Network with the Local Backend

    In this objective, you'll deploy a simple virtual network configuration using the local backend. The configuration will be updated in the next objective to use the azurerm backend instead.

    1. Create a new folder to hold a Terraform Configuration to deploy a virtual network.
    2. Add a provider block for the azurerm provider with skip_provider_registration and storage_use_azuread set to true.
    3. Add the existing resource group as a data source.
    4. Add an azurerm_virtual_network resource.
    5. Initialize and deploy the Terraform configuration.
  3. Challenge

    Update the Backend and Migrate State Data

    In this objective, you'll update the virtual network configuration to use the azurerm backend with a partial configuration. Then you'll initialize the configuration to migrate the existing state data to the storage account created in the first objective.

    1. Update you configuration to use the azurerm backend with a partial configuration.
    2. Create a backend configuration file with use_azuread_auth set to true.
    3. Use the storage account name from the first objective and the existing resource group name in the backend configuration.
    4. Run terraform init to initialize the configuration and migrate state data.
    5. Accept the migration prompt to copy the state data to the storage account.
    6. Verify the state data is stored in the storage account container.

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.