Deploy to Azure Using the Terraform Command Line Interface (CLI)

30 minutes
  • 8 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you will author a Terraform configuration for Azure and apply the configuration using the Terraform Command Line Interface (CLI).

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log In to Azure
  1. Connect to the virtual machine using the credentials provided.
  2. Using the terminal in Visual Studio Code, log in to Azure using the Azure CLI.
Author Your Terraform Configuration
  1. Create a folder for your configuration.
  2. Create a main.tffile in the folder.
  3. Author your configuration, including the terraform block and required providers meta-argument.
Initialize the Working Directory

Use the Terraform executable to initialize the working directory.

Declare Your Provider Configuration
  1. Add the provider configuration block to your Terraform configuration file.
  2. The skip_provider_registration = true must be set.
Import the Existing Resource Group

Import the existing resource group into your Terraform state.

Declare a Storage Account Resource

Create an Azure Storage Account resource block, using the following properties:

```
account_tier = "Standard"
account_replication_type = "LRS"
```
Format and Validate the Configuration

Use the Terraform executable to format and validate the configuration.

Plan and Deploy Your Configuration

Use the Terraform executable to plan and apply your configuration.

Additional Resources

Scenario

As you walk through the lab, consider the following scenario:

You're playing the role of a platform engineer with River City AI.

River City AI specializes in optimizing speech to text for efficiency and accuracy using machine learning. They’re working on next-generation speech recognition for generative AI.

River City AI is already using Amazon Web Services. Due to the success and capabilities of Microsoft’s Data and AI services, they are looking to adopt a multi-cloud environment to drive innovation. Because they are multi-cloud, Terraform is an excellent choice to deploy their infrastructure as code.

You’ll be working with an existing virtual machine that has been configured as an Infrastructure as Code workstation, with all the required software, including Terraform, the Azure CLI, and Visual Studio Code with the Terraform extension for VS Code installed.

In this lab, you will:

  1. Log in to Azure.
  2. Author your terraform configuration.
  3. Initialize the working directory.
  4. Declare your provider configuration.
  5. Import the existing resource group.
  6. Declare a storage account resource.
  7. Format and validate the configuration.
  8. Plan and deploy your configuration.

Lab Setup

In this lab, you will be connecting to the VM using Remote Desktop and you will have access to the Azure portal.

Note: To complete this lab, you will need to use a remote desktop client.

If you get stuck, feel free to check out the lab objectives or the solution video. Good luck!

WARNING: Be Prepared for UI Changes Given the fluid nature of Microsoft's cloud tools, you may experience user interface (UI) changes that were made following the development of this hands-on lab that do not match up with the lab instructions. When any such changes are brought to our attention, we will attempt to update the content accordingly. However, if changes occur, you will have to adapt to the changes and work through them in the hands-on labs as needed.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?