Create A Website - AZURE - Day15
To create a website in Azure using Terraform, you will need to perform the following steps:
Here is an example of a Terraform configuration file that creates a website in Azure:
# Configure the Azure Resource Manager provider
provider "azurerm" {
? subscription_id = "your-subscription-id"
? client_id? ? ? ?= "your-client-id"
? client_secret? ?= "your-client-secret"
? tenant_id? ? ? ?= "your-tenant-id"
}
# Create a resource group
resource "azurerm_resource_group" "example" {
? name? ? ?= "my-resource-group"
? location = "East US"
}
# Create a storage account
resource "azurerm_storage_account" "example" {
? name? ? ? ? ? ? ? ? ? ? ?= "mystorageaccount"
? resource_group_name? ? ? = azurerm_resource_group.example.name
? location? ? ? ? ? ? ? ? ?= azurerm_resource_group.example.location
? account_tier? ? ? ? ? ? ?= "Standard"
? account_replication_type = "LRS"
}
# Create a web app
resource "azurerm_app_service" "example" {
? name? ? ? ? ? ? ? ? = "mywebapp"
? resource_group_name = azurerm_resource_group.example.name
? location? ? ? ? ? ? = azurerm_resource_group.example.location
? app_service_plan_id = azurerm_app_service_plan.example.id
? app_settings = {
? ? "WEBSITE_RUN_FROM_PACKAGE" = "https://${azurerm_storage_account.example.name}.blob.core.windows.net/packages/mywebsite.zip"
? }
}
# Create an App Service plan
resource "azurerm_app_service_plan" "example" {
? name? ? ? ? ? ? ? ? = "myappserviceplan"
? resource_group_name = azurerm_resource_group.example.name
? location? ? ? ? ? ? = azurerm_resource_group.example.location
? sku {
? ? tier = "Standard"
? ? size = "S1"
? }
}
4. Run the terraform init command to initialize the working directory and download the Azure provider plugin.
5. Run the terraform plan command to see a preview of the resources that will be created.
6. Run the terraform apply command to create the resources in Azure.
You can then visit the URL of the web app to access your website.
领英推荐
I hope this helps! Let me know if you have any questions.
We post regularly on social media about the free live hands-on learning opportunities, Opensource Proof Of Concepts, Solutions Architecture Reviews, Automation live hands-on, Live career Q&A Sessions, and promotions. Do follow and support us via the following links. ??
LinkedIn?|?Twitter?|??LinkedIn Group??|?YouTube
Want to Join Every week Free Terraform Cloud Automation Handson Training?
Feel free to add me in your LinkedIn connection and send me message for more steps.
"Aiming to create 1000 leaders every year with more confidence"
Are you looking for some life confidence. Feel free to reach me out?Vijayabalan Balakrishnan?not just learning.
76K+ Followers | 14K+ Newsletter Subscribers | Resume Tips & Career Growth | Developer @DXC Technology | Brand Partnerships Open ??
2 年cfbr
DevOps Engineer, Building Next-Gen Infra.
2 年Hi Vijay, Can you share the recordings of Terraform Class -3, I have shared my details in your DM. Thanks in advance.