Deploy Angular App in Azure using Terraform

Nandhabalan Marimuthu
2 min readJun 27, 2023

--

Prerequisites:

Azure DevOps, Azure Cli, Terraform

  1. Create a Repo in Azure DevOps and upload your code.
  2. Install Azure CLI, and Terraform in your machine
  3. Login into Azure CLI using the below command
az login

4. Once you log in create a file name main.tf and paste the below contents

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.58.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
# Create a resource group
resource "azurerm_resource_group" "rg" {
name = "webapp-rg"
location = "West Europe"
}
resource "azurerm_static_site" "web" {
name = "webapp"
resource_group_name = azurerm_resource_group.rg.name
location = "West Europe"
}
output "sample_app_deployment_token" {
value = azurerm_static_site.web.api_key
sensitive = true
}

The above code will create a resource group named — webapp-rg and a static web app resource called web app in West Europe Region.

Run the below commands to execute the code

Terraform init
Terraform plan
Terraform Apply

Once you executed all the commands terraform.tfstate will be created, inside that file copy the api_key value.

Create a pipeline at Azure DevOps and paste the following in the yaml file, replace the key with the deployment token you copied from terraform.tfstate

Start the build

Your Angular Application is now LIVE!

--

--