4 Ways To Create Azure Resources
This blog will showcase four methods for creating resources in Azure: Azure Portal, Azure CLI, Azure PowerShell, and Terraform.
4 Ways To Create Azure Resources
RESOURCES
GETTING STARTED
🧪 Let’s quickly get started and create our first ever resource; a Resource Group.
1️⃣ CREATE USING AZURE PORTAL
- Let’s go to portal.azure.com and login using your Microsoft credentials.
- Go to Global Search bar (G+/) and search for Resource Group.
- Click on + Create button.
- Now, you need to fill in 2 details:
- Resource Group Name - I’m naming it
TestRGUsingPortal
- Location/Region - I’m using
CentralIndia
- Resource Group Name - I’m naming it
- You can now Click on Next. Feel free to add tags if you want.
- Once done, click on
Create
2️⃣ CREATE USING AZURE CLI
🚩 Skip 1st and 2nd step if you’re using Azure Cloud Shell.
- Download and install Azure CLI from aka.ms/azcli
- Run command
az login
to login. -
Run below command to create a new Resource Group using Azure CLI
1
az group create --name 'TestRGUsingAzCLI'
3️⃣ CREATE USING AZURE POWERSHELL
🚩 Skip 1st and 2nd step if you’re using Azure Cloud Shell.
-
Download and install Azure PowerShell module by running below command:
1
Install-Module -Name 'Az' -Scope CurrentUser
- Login to Azure PowerShell using command:
Login-AzAccount
-
Finally let’s create a Resource group using below command:
1
New-AzResourceGroup -Name 'TestRGUsingAzPowerShell'
4️⃣ CREATE USING HASHICORP TERRAFORM
- Let’s create folder:
mkdir terraform-demo && cd terraform-demo
-
Let’s create a new terraform file
main.tf
and add below contents:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
provider "azurerm" { features {} subscription_id = "0000-0000-0000000-00000000-0000000" } resource "azurerm_resource_group" "rg" { name = "TestRGUsingTerraform" location = "JapanEest" tags = { environment = "sandbox" platform = "app" department = "finance" } }
- To find the subscription ID, use command
az account show --query 'id'
- Use
terraform init
to initialize terraform. - Use
terraform apply
to create the resource group. Make sure you typeyes
and hit enter when asked to.
🧠 BONUS TIPS
- Use
terraform destroy
to delete what you’ve created using Terraform. - Use
--auto-approve
flag with apply and destroy commands to skip confirmation. E.g.terraform apply --auto-approve
terraform destroy --auto-approve
-
Use below PowerShell command to delete the resources that were created as part of this demo:
1
Get-AzResourceGroup -Name 'TestRGUsing*' | Remove-AzResourceGroup -Force
This post is licensed under CC BY 4.0 by the author.