Jelle den Burger
Jelle den Burger

Reputation: 1468

Resource createdTime property missing in Azure Resource Graph Explorer

I am trying to get the createdTime field for Azure resources through the Azure Resource Graph Explorer and it seems the Azure Resource Graph Explorer does not support this value. I cannot find it anywhere.

The odd thing is that the resources endpoint does have this value, so it does exist somewhere. See the documentation of this endpoint here: https://learn.microsoft.com/en-us/rest/api/resources/resources/list (look at the $expand URI parameter). I tested this endpoint and it works. I can see the createdTime for all my resources within one subscription.

So why does the Resource Graph Explorer not have/expose this field?

Upvotes: 1

Views: 1591

Answers (2)

Ivan
Ivan

Reputation: 13

For Graph I don't know but using PowerShell or Rest you can use this sniped code.

    $subscriptionID = "11111-111-1111-111111"
    $resourceGroupName = "myResourceGroup"

    #assumes you have an active Az CLI context authenticated to target subscription. Can also be done with Az PowerShell, but requires a  different token retrieval method
    $accessToken = az account get-access-token --query accessToken

    #specify target API endpoint
    $uri = "https://management.azure.com/subscriptions/$($subscriptionID)/resourcegroups/$($resourceGroupName)?api-version=2019-08-01&%24expand=createdTime"

    $headers = @{
      "Authorization" = "Bearer $($accessToken)"
     }

    #consume ARM endpoint
   $rgInfo = Invoke-RestMethod -Uri $uri -Headers $headers -Method 'GET'

   $creationDate = $rgInfo.createdTime

Code from michaeldroessler

Upvotes: 0

Joey Cai
Joey Cai

Reputation: 20127

Resource Graph Explorer provides browsable information about the Azure Resource Manager resource types and properties that you can query. Resource Graph Explorer also provides a clean interface for working with multiple queries, evaluating the results, and even converting the results of some queries into a chart that can be pinned to an Azure dashboard.

Some resource you can see creation Time such as below, but if you want to query you need to give detailed time. The article you provided is about resource list.

enter image description here

Upvotes: 0

Related Questions