Create Azure resource group
Create Azure resource group
$ az group create -n myResourceGroup -l eastus
Create Azure credentials
$ az ad sp create-for-rbac --role Contributor --scopes /subscriptions/<subscription_id> --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
$ az account show --query "{ subscription_id: id }"
Build Packer image
$ packer init
$ packer build ubuntu.pkr.hcl
source "azure-arm" "autogenerated_1" { | |
azure_tags = { | |
dept = "Engineering" | |
task = "Image deployment" | |
} | |
client_id = "f5b6a5cf-fbdf-4a9f-b3b8-3c2cd00225a4" | |
client_secret = "0e760437-bf34-4aad-9f8d-870be799c55d" | |
image_offer = "UbuntuServer" | |
image_publisher = "Canonical" | |
image_sku = "16.04-LTS" | |
location = "East US" | |
managed_image_name = "myPackerImage" | |
managed_image_resource_group_name = "myResourceGroup" | |
os_type = "Linux" | |
subscription_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" | |
tenant_id = "72f988bf-86f1-41af-91ab-2d7cd011db47" | |
vm_size = "Standard_DS2_v2" | |
} | |
build { | |
sources = ["source.azure-arm.autogenerated_1"] | |
provisioner "shell" { | |
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'" | |
inline = ["apt-get update", "apt-get upgrade -y", "apt-get -y install nginx", "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"] | |
inline_shebang = "/bin/sh -x" | |
} | |
} |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND