DEV Community

Cover image for Deploy Azure App Service Using Terraform
Clinton Mbilitem
Clinton Mbilitem

Posted on • Edited on

Deploy Azure App Service Using Terraform

Alright, glad to have you all back with me. Today we will be taking a look at how to create a simple webapp service in Azure using Terraform.

as stated in our previous class, we need to first write the Terraform block for every deployment, which is where the required provider is stated.
Terraform and required provider block
terraform

.

The provider block instructs Terraform on how to connect to Azure in order to establish resources such as the Web App, App Service Plan, and Resource Group during an Azure web app deployment.
provider block
provider

.

Terraform is informed by this block:

"In the westus2 region, create a Resource Group in Azure named terraform-lab-rg."

In essence, a Resource Group is a folder or container that houses Azure resources
Resource group block
resource group

.

An Azure App Service Plan defines
how much compute you get, what OS you run, how much it costs
Think of it as the server farm your web app runs on.
Service plan block
service plan

'
Azure requires web app names to be globally unique (across all Azure customers).
This resource generates a random 6-character lowercase string and avoids name collisions. Example of output: k9f3qa
Random string
random string

.

What this creates: An Azure App Service (Linux) — basically:
Final name example: terraform-lab-webapp-k9f3qa
Main webapp block
webapp

.

What this does: After terraform apply, Terraform will print:
web_app_url = terraform-lab-webapp-k9f3qa.azurewebsites.net
That’s the public URL of your web app.
Web output block
web output

.

*Azure portal view *
azure portal view

.

Top comments (1)

Collapse
 
realcloudprojects profile image
SKILL.SCH

Welldone Clinton