Let's first find out what an azure app service is !!
Azure AppService is a Platform as a service (PaaS) cloud computing-based platform for hosting websites, created and managed by Microsoft. Azure appService includes multiple services(Azure Website, Azure Mobile services and Azure BizTalk ) that were previously delivered separately.
Being involved with Terraform configurations is done in three steps:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1> Create a configuration 2> Initialize the terraform state 3> Apply the configuration
1. Create an Azure App Service
~~~~~~~~~~~~~~~~~~~~~~~~
Now that we’ve seen what an Azure App Service is, let us dive deep and create a new App Service in Azure.
Create a terraform script file named myappservice.tf
vim myappservice.tf
To provision an appservice we need.
(a) Resource Group (b) AppService Plan (c) App Service
Now make the following configuration entries here.
#This section creates a azure Resource Group named "myrg"
resource "azurerm_resource_group" "stage" { name = "myrg" location = "West Europe" }
#Create a App Service Plan named "myplan".
resource "azurerm_app_service_plan" "stage" { name = "myplan" location = "${azurerm_resource_group.stage.location}" resource_group_name = "${azurerm_resource_group.stage.name}" sku { tier = "Free" size = "F1" } }
#Create a App Service named "myappsrvc"
resource "azurerm_app_service" "stage" { name = "myappsrvc" location = "${azurerm_resource_group.stage.location}" resource_group_name = "${azurerm_resource_group.stage.name}" app_service_plan_id = "${azurerm_app_service_plan.stage.id}" }
2. Initialize the terraform state
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before we start applying this configuration to your azure environment we need to initialliz terraform in the current folder in order to get it working with our script:
terraform init
This will download the required modules for our repository and setup any local files that our terraform script needs.
terraform init
3. Apply the configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~
Once initialization is done. it is time to apply our configuration to our azure environment.
terraform apply
This will deploy a new desired state for your environment.
Thanks for Reading