Setup Basic PaaS based web application on Azure using Terraform private modules

Vijay Borkar (VBCloudboy)
3 min readJan 14, 2021

--

The Underlined architecture and its references are taken from Azure Architecture Center. The Microsoft site has all content and services details and deployment details outlined are available in ARM-template (JSON format). This article deploys the same architecture using hashicorp language (HCL) terraform. The code build is enterprise-ready code in a modularized structure.

By Changing the values in terraform.tfvars files you can deploy this architecture in the N-number of environments you have in your organization.

Summary

The architecture shows proven practices for a web application that uses Azure App Service and Azure SQL Database. The architecture has other components like Resource groups, App Service Plan & App, Deployment Slots, IP-Address, Azure DNS, Azure SQL Database, Logical Server, Azure Storage, Azure Active Directory for more details on each resources please click on this link

Reference Architecture of Basic Web Application

Module Structure

Every Terraform configuration has at least one module, known as its root module, which consists of the resources defined in the .tf files in the main working directory. A module is a container for multiple resources that are used together. Modules can be used to create lightweight abstractions, so that we can describe our infrastructure in terms of its architecture, rather than directly in terms of physical objects.

Re-usable modules are defined using all of the same configuration language concepts we use in root modules. for more details to create them we can refer to this link create-module

$ tree minimal-module/
.
├── README.md
├── main.tf
├── variables.tf
├── outputs.tf

Where each file details are outlined as;

  • readme.md will contain documentation describing how to use the module, in markdown format.
  • main.tf will contain the main set of configurations for the module.
  • variables.tf will contain the variable definitions for the module.
  • Outputs.tf Module outputs are made available to the configuration using the module, so they are often used to pass information about the parts of the infrastructure defined in the module to other parts of the current configuration

Module Naming Convention

Naming details reference

Pre-requisites to execute first

  1. Resource group in azure account is created manually.
  2. Choice of region for deployment of azure resources is “Central India”

Step-By-Step Code Preparation

Step-1: Create DNS module and define dns code in main.tf, variables.tf & output.tf file.

Step-2: Create STORAGE module and define storage code in main.tf, variables.tf & output.tf file.

Step-3: Create AZURE SQL module and define mssql code in main.tf, variables.tf & output.tf file.

Step-4: Create AZURE WEB module and define web app & app service environment code in main.tf, variables.tf & output.tf file.

Step-5: Now we will create MAIN , VARIABLES, TFVARS file which will call these modules and help us to create an environment, we define code in main.tf, variables.tf & terraform.tfvars file.

By performing step-by-step executions you can set up a basic web application on azure. for more information on code and clone this enterprise-ready code you can go ahead and clone my git repo for quick execution.

--

--

Vijay Borkar (VBCloudboy)

Assisting Microsoft partners in elevating their technical capabilities in AI, Analytics, and Cybersecurity.