question

SangHoonKim-0818 avatar image
SangHoonKim-0818 asked ·

(Azure VM) How to get the time duration of a deployment in a resource group

Hello,

I am currently using Azure to create virtual machines, and I tried to find a way to get the time duration of creating a VM.
As you can see in the picture below, I found that as I go to the deployments section of a resource group where I create a VM, I can see the duration of the deployment for the VM, which is great.

However, I can only see the time duration in Azure portal, but I want to retrieve it using Azure CLI
because I want to automate this process using a script.

I cannot find any way to do this, so please help me!

4181-screen-shot-2020-03-10-at-114521-pm.png


azure-virtual-machines
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

jakaruna-MSFT avatar image
jakaruna-MSFT answered ·

You can use azure CLI or rest apis to get the duration.

Sample Azure cli command

az deployment list --query '[].[ name, properties.duration ]'

This will list the deployment name and the duration. The duration is a string in a specific format.
For example,

  • PT1M38.9192782S for 1 minute and 38 seconds.

  • PT16.0054451S for 16 seconds.

Reference for the rest api is here


Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.