Blog Post

Azure Database Support Blog
2 MIN READ

Get creation dates of all Azure resources under an Azure subscription

RoshnaNazir's avatar
RoshnaNazir
Icon for Microsoft rankMicrosoft
Dec 23, 2021

Overview:

One of our Azure customers raised a support ticket to find out the creation dates for all their resources on their Azure subscription.

This blog shows you one of the ways to achieve that.

 

Step 1:

Create an Azure service principal with the az ad sp create-for-rbac command. Make sure to copy the output, as it is required in the next steps.

 

Input

az ad sp create-for-rbac --name serviceprincipalname --role reader

 

Output

Creating 'reader' role assignment under scope '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

The output includes credentials that you must protect. Be sure that you do not include these credentials in your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli

'name' property in the output is deprecated and will be removed in the future. Use 'appId' instead.

{

  "appId": "xxxxxxx",

  "displayName": "serviceprincipalname",

  "name": "xxxxxxx",

  "password": "xxxxxxx",

  "tenant": "xxxxxxx"

}

 

 

Step 2:

Generate the bearer token using Postman client - Postman API Platform

 

Type in the below URL with your tenant ID for a POST call

https://login.microsoftonline.com/xxxxtenant-IDxxxxxx/oauth2/token

 

 

Click on “Body” and type in the details from the output of Step 1 as following.

Note: Client ID = App ID.

 

Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials

client_id=xxxxxxxxxxxxxxxxxxxxxx

client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxx

resource=https://management.azure.com/

 

 

Click on “Send” and you will see a JSON response as below with a bearer/access token

 

Copy the access token which will now be used in Step 3 for a Get call.

 

 

Step 3:

Make the get call to get the creation dates of your resources on the subscription. You may also do it for a single resource by filtering as needed in the URL.

Get URL - https://management.azure.com/subscriptions/XXXX-Your-Subscription- IDXXXX/resources?api-version=2020-06-01&$expand=createdTime&$select=name,createdTime 

 

Select “Bearer Token” in the Authorization tab and paste the access token copied from Step 2.

 

Click on Send and enjoy the results you wanted!

 

Credits to @P V SUHAS for the guidance.

Updated Dec 23, 2021
Version 3.0

8 Comments

  •  I also would like to see a way to verify who created an azure ad group ?  the group is a year old.   The  date and time  when the group was created is accessible  in the overview. But not the  initiator, or  upn that created  the group.    And i can't search past 90 day in the activity log   

     

    Any response would be helpful.. 

  • sd_blogs's avatar
    sd_blogs
    Copper Contributor

     

     

    RoshnaNazir No not specific to to storage account only. I'm looking in general for all resource "Create Time" attribute value in portal under each resource detail page.

    And storage account need to create when I choose to go with above solution & but I don't have that want to do that.

  • PhilTorkington's avatar
    PhilTorkington
    Copper Contributor

    RoshnaNazir Agreed - Having a created timestamp available within the resource overview would be so helpful - we shouldn't have to go through the steps above

  • sd_blogs's avatar
    sd_blogs
    Copper Contributor

    RoshnaNazir Isn't there any better way to get created date? Like property with Createddate timestamp under the resource in Azure portal. Reason if I don't have storage service then I have to create that & it will incur an extra charge, which I don't want.