01 Run vm show command (Windows/macOS/Linux) using the name of the virtual machine (VM) instance that you want to re-create as identifier parameter, to describe all the configuration information available for the selected VM instance:
az vm show
--name cc-project5-web-server
--resource-group cloud-shell-storage-westeurope
02 The command output should return the requested information:
{
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-web-server",
"identity": null,
"instanceView": null,
"licenseType": null,
"location": "westeurope",
"name": "cc-project5-web-server",
"osProfile": {
"adminPassword": null,
"adminUsername": "AzureUser",
"allowExtensionOperations": true,
"computerName": "cc-project5-web-server",
...
"requireGuestProvisionSignal": true,
"windowsConfiguration": null
},
"plan": null,
"priority": null,
"provisioningState": "Succeeded",
"proximityPlacementGroup": null,
"resourceGroup": "cloud-shell-storage-westeurope",
"resources": null,
"tags": null,
"type": "Microsoft.Compute/virtualMachines",
"virtualMachineScaleSet": null,
}
03 Run image list command (Windows/macOS/Linux) using custom query filters to list the name of each custom machine image available in the selected Azure subscription:
az image list
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
--output table
--query '[*].{name:name, resourceGroup:resourceGroup}'
04 The command output should return the VM image identifiers (i.e. names):
Result
-------------------------
cc-project5-golden-image
cc-web-base-machine-image
05 Run vm create command (Windows/macOS/Linux) using the configuration information of the virtual machine instance that you want to re-create, returned at step no. 2, and the name of the approved (golden) machine image as input for the vm create command parameters, to create a new, approved Azure virtual machine instance:
az vm create
--resource-group cloud-shell-storage-westeurope
--name cc-project5-approved-web-server
--image cc-project5-golden-image
--size Standard_DS2_v2
--admin-username azureuser
--generate-ssh-keys
06 The command output should return the metadata available for the new VM instance:
{
"fqdns": "",
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-approved-web-server",
"location": "westeurope",
"macAddress": "xx-xx-xx-xx-xx-xx",
"powerState": "VM running",
"privateIpAddress": "10.0.0.10",
"publicIpAddress": "xxx.xxx.xxx.xxx",
"resourceGroup": "cloud-shell-storage-westeurope",
"zones": ""
}
07 Migrate the necessary application data from the source (non-approved) virtual machine instance to the destination (approved) VM instance.
08 To remove the non-compliant virtual machine instance from your Azure cloud account in order to eliminate unnecessary costs, run vm delete command (Windows/macOS/Linux) using the name of the VM instance that you want to delete as identifier parameter (the command does not produce an output):
az vm delete
--name cc-project5-web-server
--resource-group cloud-shell-storage-westeurope
09 Type y (yes), then press Enter to confirm the resource removal, i.e.:
Are you sure you want to perform this operation? (y/n): y
10 Repeat step no. 1 – 9 to re-create other Azure VM instances using golden machine images, available in the selected subscription.
11 Repeat steps no. 1 – 10 for each subscription created in your Microsoft Azure cloud account.