Deploy a Web Application with Terraform

15 minutes
  • 2 Learning Objectives

About this Hands-on Lab

In this lab, we will be deploying an Azure Application Service plan with a .NET Framework site with a Local Git content management setting.

If you are working with a DevOps team, you may encounter many requests to either set up a Web app or provide the DevOps team with a way to deploy their own.

By deploying the application with Terraform, you can set guidelines for naming conventions, code repo’s, service plan levels, and deployment locations.

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.
  1. Open the CLI.
  2. Select Bash at the prompt.
  3. Click Show Advanced Settings. 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 Cloud Shell region as your lab provisioned Storage Account. Leave both the Resource Group and Storage Account as using the existing resources. In the File share section, enter a name for the account (for this example, we are using cloudcli ) and click the Attach Storage button. Once finished, we can continue.
  4. Once the command prompt is initialized, proceed to Task 2.
Deploy a Web Application

To complete this exercise, please make sure you’ve completed Task 1 before completing the following:

  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. 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

Deploy a Standard tier, "S1" application service plan with a Dot Net 4.0 framework with a local git software config manager. As in previous labs, be sure to copy in the lab generated resource group name.

Code for file follows

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "= 2.99"

provider "azurerm" {
  features {}

  skip_provider_registration = true

resource "azurerm_app_service_plan" "svcplan" {
  name                = "newweb-appserviceplan"
  location            = "eastus"
  resource_group_name = "<YOUR_RESOURCE_GROUP_NAME>"

  sku {
    tier = "Standard"
    size = "S1"

resource "azurerm_app_service" "appsvc" {
  name                = "custom-tf-webapp-for-thestudent"
  location            = "eastus"
  resource_group_name = "<YOUR_RESOURCE_GROUP_NAME>"
  app_service_plan_id =

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"

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?