DEV Community

IAC - Azure WebApp creation

Step1: Terraform provider section

    terraform {
        required_providers {
            azurerm ={
                source = "hashicorp/azurerm"
                version="3.17.0"
            }
        }  
    }

Enter fullscreen mode Exit fullscreen mode

Step2: Provider section of azurerm

Refer to article to get mentioned details required to be provided in azurerm provider - https://dev.to/srinivasuluparanduru/azure-service-principal-creation-step-by-step-approach-2a46

provider "azurerm" {
        subscription_id = ""
        tenant_id = ""
        client_id = ""
        client_secret = ""    

        features {

        }
    }

Enter fullscreen mode Exit fullscreen mode

Step3: Azure resource group creation

resource "azurerm_resource_group" "example" {
        name     = "template-grp"
        location = "North Europe"
    }
Enter fullscreen mode Exit fullscreen mode

Step4: Azure service plan

resource "azurerm_service_plan" "plan202407" {
        name                = "plan202407"
        resource_group_name = azurerm_resource_group.example.name
        location            = "North Europe"
        os_type             = "Windows"
        sku_name            = "F1"
    }
Enter fullscreen mode Exit fullscreen mode

Step5: Creation of Azure web app

resource "azurerm_windows_web_app" "example" {
        name                = "examplewebapp"
        resource_group_name = azurerm_resource_group.example.name
        location            = azurerm_service_plan.example.location
        service_plan_id     = azurerm_service_plan.example.id

        site_config {
            always_on = false
            application_stack {
                current_stack = "dotnet"
                dotnet_Version = "v6.0"
            }
        }
        depends_on= [
                azurerm_service_plan.plan202407
        ]
    }

Enter fullscreen mode Exit fullscreen mode

References:
1.Service Plan

2.Azure webapp

Conclusion : Creation of Azure webapp using IAC - Terraform
💬 If you enjoyed reading this blog post and found it informative, please take a moment to share your thoughts by leaving a review and liking it 😀 and follow me in dev.to , linkedin

Top comments (0)