Melbin K
Melbin K

Reputation: 55

How to get the creation date of Azure RM Resources including all resources from Azure

I need to use the command Get-AzureRMResource and return resources created after a particular date . Is it possible to filter the resources w.r.t creation date. Can someone please help?

Upvotes: 3

Views: 12270

Answers (3)

kudu-star
kudu-star

Reputation: 16

Like @kwill suggested, this site can also help run the command interactively via your browser and return these results for you:

https://learn.microsoft.com/en-us/rest/api/resources/resources/list#code-try-0

Steps below:

  1. Click on the try it now button
  2. Enter your subscription ID
  3. For a key value name use: $expand For the key value value use: createdTime
  4. Then run the query and it should produce a JSON file for you

Example

Upvotes: 0

kwill
kwill

Reputation: 11008

This information is available via ARM, but you have to call the API directly rather than the PS Get-AzureRMResource (or Get-AzResource) cmdlets.

See Deleting all resources in an Azure Resource Group with age more than x days.

Essentially, you need to add the $expand=createdTime to your query parameters, ie.:

GET https://management.azure.com/subscriptions/1237f4d2-3dce-4b96-ad95-677f764e7123/resourcegroups?api-version=2019-08-01&%24expand=createdTime

Upvotes: 1

Joy Wang
Joy Wang

Reputation: 42063

The Get-AzureRMResource could not get the creation date of Azure RM Resources. It seems there is no other way to get the creation date except the Activity log.

But still it can return only the items created on past 90 days.

For this issue, you could try to Archive the Azure Activity Log, this option is useful if you would like to retain your Activity Log longer than 90 days (with full control over the retention policy) for audit, static analysis, or backup.

Update:

If you want to get resources created after a particular date, try the command below, it returns the resources created after 11/20/2018 1:57:19 AM.

Get-AzureRmResourceGroupDeployment -ResourceGroupName "<ResourceGroupName>" | Where-Object {$_.Timestamp -gt '11/20/2018 1:57:19 AM'}

enter image description here

Upvotes: 2

Related Questions