How long a virtual machine running under the subscripion

%3CLINGO-SUB%20id%3D%22lingo-sub-2028018%22%20slang%3D%22en-US%22%3EHow%20long%20a%20virtual%20machine%20running%20under%20the%20subscripion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2028018%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%20I%20would%20like%20to%20find%20out%20how%20long%20(how%20many%20years%2FMonth%2Fdays)%20certain%20virtual%20machines%20running%20on%20Azure.%20How%20can%20fetch%20these%20details%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3ESalai%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2029794%22%20slang%3D%22en-US%22%3ERe%3A%20How%20long%20a%20virtual%20machine%20running%20under%20the%20subscripion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2029794%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F916564%22%20target%3D%22_blank%22%3E%40SalaiJ%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Edepending%20on%20your%20expectations%2C%20it%20may%20or%20not%20be%20possible%20to%20get%20the%20information%20you%20want.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20The%20VM's%20operating%20system%20can%20tell%20you%20the%20uptime%2C%20but%20this%20is%20mostly%20inaccurate%2C%20as%20the%20VM%20may%20have%20rebooted%20many%20times%20since%20its%20creation.%3C%2FP%3E%0A%3CP%3E2.%20Azure%20Activity%20Log%20provides%20you%20with%20an%20history%20of%20operations%20made%20on%20your%20Azure%20resources%20(creation%2C%20update%2C%20delete)%2C%20but%20it%20is%20queryable%20only%20for%20the%20past%2090%20days.%20Again%2C%20a%20solution%20that%20falls%20short%2C%20unless%20you%20were%20exporting%20Activity%20Logs%20to%20a%20Storage%20Account%20or%20Log%20Analytics%20workspace%20with%20a%20longer%20retention.%3C%2FP%3E%0A%3CP%3E3.%20If%20you%20look%20at%20the%20VM's%20OS%20managed%20disk%20properties%2C%20you%20can%20see%20when%20the%20disk%20was%20created%20(see%20capture%20below).%20This%20solution%20would%20work%20for%20all%20your%20VMs%20that%20run%20on%20managed%20disks%2C%20provided%20the%20OS%20disk%20was%20never%20swapped.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOut%20of%20the%20box%2C%20there%20is%20not%20a%20100%25%20accurate%20answer%2C%20but%20I%20hope%20these%20hints%20help%20you%20somehow.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hspinto_1-1609776576908.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243857iFBD0EACD46904B56%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22hspinto_1-1609776576908.png%22%20alt%3D%22hspinto_1-1609776576908.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi there, I would like to find out how long (how many years/Month/days) certain virtual machines running on Azure. How can fetch these details?

 

Cheers

Salai

2 Replies

@SalaiJ 

 

depending on your expectations, it may or not be possible to get the information you want.

 

1. The VM's operating system can tell you the uptime, but this is mostly inaccurate, as the VM may have rebooted many times since its creation.

2. Azure Activity Log provides you with an history of operations made on your Azure resources (creation, update, delete), but it is queryable only for the past 90 days. Again, a solution that falls short, unless you were exporting Activity Logs to a Storage Account or Log Analytics workspace with a longer retention.

3. If you look at the VM's OS managed disk properties, you can see when the disk was created (see capture below). This solution would work for all your VMs that run on managed disks, provided the OS disk was never swapped.

 

Out of the box, there is not a 100% accurate answer, but I hope these hints help you somehow.

 

hspinto_1-1609776576908.png

 

 

Thanks for your response.