Deploy an Azure File Share and Blob Storage with Terraform

15 minutes
  • 2 Learning Objectives

About this Hands-on Lab

In this lab, we deploy a Blob storage container as well as a File share.

File shares and blob storage are fundamental parts of any Azure environment. From archival storage for OS images to SMB file shares for on-premise servers and workstaions, terraform allows for quick deployments of blob and file storage that can be pre-set to adhere to your department’s requirements and standards.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log into the Azure Portal and set up the Command Line Interface (CLI) for use.

In the Azure portal, select the Command Line button at the top of the screen. Open the CLI. Here, select Bash when prompted. We then want to choose Show Advanced Settings. Choose the same location as the lab provided Resource Group. Leave both the Resource Group and Storage Account as the provided defaults. If you are unable to select the existing storage account, choose to create one with a unique name. In the File share section, enter a name for the account (for this example, we are using Console*) and click the Attach Storage button. Once the command prompt completes, we can continue.

Deploy an Azure Storage Blob container and File Share.
  1. Use the code block found in the Additional Information and Resources section to create a file and upload it to the CLI.
  2. In the (resource "azurerm_storage_account" "lab") declaration, you’ll need to edit the resource_group_name value with the name generated by the lab. Use the same location as your lab provided resource group. Additionally, you’ll need to enter a unique name for the storage account that will be used for the file share. The "provider" statement has been added to the code, so you won’t need to create a file to deploy the storage account.
  3. Once the file has been uploaded, run terraform init.
  4. Run terraform plan and review the output to confirm that Terraform will create the desired resource. Green plus signs will indicate the resources that need to be added.
  5. Run terraform apply, answering yes to the prompt to continue.
  6. Once Terraform completes the deployment, check the Azure Portal to confirm.

You’re done! Go ahead and shut down the lab.

Additional Resources

In this lab, you'll deploy a storage account, a container with a private blob, and a 50GB file share. This builds on the previous lab, where we created the storage account. Use the code block below.

*** Code for file follows:

provider "azurerm" {
    version = 1.38

resource "azurerm_storage_account" "lab" {
  name                     = "unique storage account name"
  resource_group_name      = "Enter Resource Group Name"
  location                 = "[Use the same location as your lab provided resource group]"
  account_tier             = "Standard"
  account_replication_type = "LRS"

resource "azurerm_storage_container" "lab" {
  name                  = "blobcontainer4lab"
  storage_account_name  =
  container_access_type = "private"

resource "azurerm_storage_blob" "lab" {
  name                   = "TerraformBlob"
  storage_account_name   =
  storage_container_name =
  type                   = "Block"
resource "azurerm_storage_share" "lab" {
  name                 = "terraformshare"  
  storage_account_name =
  quota                = 50

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?