How to Find Azure VM Creation Date?
In this article, we'll be finding the Azure VM Creation Date, Time, User Created using various methods like az CLI, Azure PowerShell, az rest API, KQL Query, Activity Logs,...,etc.
Method 1 -Find Azure VM Creation Date and Time using Azure PowerShell
$vmName = "add vm name"
(Get-AzVM -Name $vmName).TimeCreated
This will return the creation date and time of your Azure VM.
You can also use | fl to see all the properties of the VM, and filter the properties you want.
(Get-AzVM -Name $vmName) | fl
Method 2 -Find Azure VM Creation Date using Az CLI command
Run the following az cli commands in cloud shell from azure portal. These commands works in both Bash and Powershell as well.
$ids = az vm list --query '[].id' --output tsv az vm show --ids $ids[0] --query '[name,timeCreated]'
Sample Output 1:
Sample Output 2:
Method 3 -Find VM Creation Date from Managed OS Disk using PowerShell:
Actually, there is no direct method to find the Azure VM creation data and time either using the tools or Azure Portal if the VM creation is beyond 90 days. Alternatively you can use the below Azure PowerShell command to get the creation data and time based on Azure VM OS Disk you can check the creation date and time of the managed disk.
PowerShell Command:
Get-AzDisk -ResourceGroupName "_add_rg_" -DiskName "_add_azure_vm_disk_" ` | Select Name,TimeCreated,@{N="VMname";e={($_.managedby -split "/")[8]}}
Sample Output:
Method 4 -Find VM Creation Date in Azure Activity Logs from Azure Portal:
- Access Azure Portal
- go to Virtual Machines
- select your target Azure VM
- After selecting your Azure VM, from menu select Activity Logs
- In search box type in "Create" to find the VM creation data, time and user created.
Note: Activity Logs from Azure Portal can only be fetched based on your Log Analytics retenction period. This method will not if the retenction period expires.
Method 5 -Finding VM Creation Date using KQL Log Query:
Using the below KQL Query you can find then azure resource creation data with time and Caller(created user email Id)
AzureActivity | where ResourceGroup!=" " and Resource!=" " | where ActivityStatus=="Succeeded" | project ResourceGroup,Resource,CreatedBy=Caller,CreationTime=TimeGenerated
Note: for this method you cannot retrieve the data if it is more than 90 days.
Method 6 -Finding Azure VM Creation Data Time using az rest API:
Use Cloud Shell from Azure Portal and run the following az rest command in Bash Terminal
az rest \ --method GET \ --url "https://management.azure.com/subscriptions/{_add_subscripion_id_}/providers/Microsoft.Compute/virtualMachines" \ --url-parameters api-version=2022-03-01