Forum Discussion
Oleg_A
Aug 25, 2024Copper Contributor
Fin All new Resources and ideally their cost
Hello:
I wonder if there is a way to find out ALL Resources in our tenant that were created since specific date (like last 7 days) and their cost for the same period.
Ideally I'd like to run it via PowerShell...
How can I do it?
We are not enforcing "create date" tags...
Thank you!
- To get a list of all resources created within a specific date range (like the last 7 days) and their associated costs, you can use a combination of Azure PowerShell and the Cost Management API. Since you aren’t using tags for creation dates, you’ll need to query resource metadata to approximate the creation date
Step 1: Retrieve Resources Created Within a Specific Date Range
Azure doesn’t store the creation date directly, but you can approximate it by using the CreatedTime property, which can be retrieved from resource activity logs.
Step 2: Retrieve Costs for the Identified Resources
Once you have the resource IDs, you can use the Cost Management API to pull the associated costs.
2 Replies
- sachinagrawalCopper ContributorTo get a list of all resources created within a specific date range (like the last 7 days) and their associated costs, you can use a combination of Azure PowerShell and the Cost Management API. Since you aren’t using tags for creation dates, you’ll need to query resource metadata to approximate the creation date
Step 1: Retrieve Resources Created Within a Specific Date Range
Azure doesn’t store the creation date directly, but you can approximate it by using the CreatedTime property, which can be retrieved from resource activity logs.
Step 2: Retrieve Costs for the Identified Resources
Once you have the resource IDs, you can use the Cost Management API to pull the associated costs.- Oleg_ACopper Contributorsachinagrawal ,
Yes, Thanks a lot for the idea!!!
It worked just fine.
Some code could be found here: https://techcommunity.microsoft.com/t5/azure/list-all-new-resources-created-within-a-week/m-p/4228218#M17230