az vm image list --output table
az resource list
az resource list -g <resource-group-name>
Find just partial information you need to delete the resource(this will give you just the name,type)
az resource list -g <resource-group-name> | grep "name\|type"
az resource delete -g <resource-group-name> --name <name> --resource-type <resource-type>
az group delete -n <resource-group-name>
az group create -n <resource-group-name> --location <region> --tags "createdby=Daniel Plas Rivera" "year=2019"
az storage account create --resource-group <Resource-group-name> --name <storageaccountname> --sku Standard_LRS
Typing -h after any command seeing the options will help you incase it starts to not make sense after a while. for instance if you forget why you typed "az storage account create" you can simply traverse the help documentation by typing -h after any part of the command:
az -h
...
options at root level of az
...
az storage -h
...
options at storage level of az
...
az storage create -h
...
options at create level of the storage action
...
Unlike linux build templates in packer, Windows builds require an object_id, you can find the object_id by going loging into azure cli "az login" then doing the following:
az account show
You'll get returned a json object, grab the user.name value:
{
"environmentName": "AzureCloud",
"id": "xxxxxxxx-1111-1111-xxxx-xxxxxxxxxxxx",
"isDefault": true,
"name": "Experminent",
"state": "Enabled",
"tenantId": "xxxxxxxx-2222-2222-xxxx-xxxxxxxxxxxx",
"user": {
"name": "xxxxxxxx-3333-3333-xxxx-xxxxxxxxxxxx",
"type": "servicePrincipal"
}
}
Grab the "user":"name" value that's in the object
"name": "xxxxxxxx-3333-3333-xxxx-xxxxxxxxxxxx",
Show the object_id of that user by doing this
az ad sp show --id xxxxxxxx-3333-3333-xxxx-xxxxxxxxxxxx
An json object with the "objectId" will be in it after you enter that command
{
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"displayName": "SuperLab",
"objectId": "11111111-2222-3333-4444-555566667777",
"objectType": "ServicePrincipal",
"servicePrincipalNames": [
"http://example.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
]
}
You can then use the "objectId" in your packer build template or anyhwere else you might need an objectId. Below is where you provide it in a packer build "object_id"
{
"builders": [{
"type": "azure-arm",
"client_id": "",
"client_secret": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "11111111-2222-3333-4444-555566667777",
"managed_image_resource_group_name": "myResourceGroup",
"managed_image_name": "myStorageAccount",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "3m",
"winrm_username": "packer",
"azure_tags": {
"dept": "Engineering",
"task": "Image deployment"
},
"location": "East US",
"vm_size": "Standard_DS2_v2"
}],
"provisioners": [{
"type": "powershell",
"inline": [
"Add-WindowsFeature Web-Server",
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
"& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
]
}]
}
###create image from VHD az image create --resource-group <> --name <> --os-type Windows --source https://sfdasfasfasdf.vhd
az network list-usages --location <location> -o table
az image delete -n <image name> --resource-group <resource group>
az image list