1
votes

I want to retrieve the creator of a virtual machine under Azure using azure rm powershell cmdlt or an api whitxh could return this type of information.

I used the "Get-AzureRmVM" command and the "GET https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/vmName?api-version=2018-06-01" api but both of them don't return information about the creator of the VM

2

2 Answers

0
votes

This information is not exposed in Azure API (unfortunately). Your only option is to take a look at activity logs of the resource and find the very first write operation to the resource, unfortunately resources do not expose creation time either, so you cannot be sure you will find proper creator, because activity logs only go back 90 days.

0
votes

You can use the Get-AzLog command to look for the caller value in the Azure Activity logs.

Examples can be found here:

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-audit#powershell

You can also set up alerts in Azure Monitoring that can send you an email or text message everytime a VM is created.

https://docs.microsoft.com/en-us/azure/azure-monitor/platform/alerts-overview