Check if resource is used

Lubomir Sokolovsky 1 Reputation point
2021-11-02T09:21:01.233+00:00

We have inherited an old project with tons of Azure resources (roughly 1600 in 30+ subscriptions). We were tasked to determined, whether they are still used or can be removed. We were able to identify a vast majority of these services via ARM templates, PowerShell scripts, etc. However, there remains ~250 resources which we are not sure about.

Is there any simple way (Kusto query, API endpoint, ...) to check whether a resource was actively used in the past 2-3 years? Some of our resources are used very irregularly (e.g.: only at the start of new year, during scale unit migration or as a backup during recovery), so the usual insights which go back only 30-90 days are not enough for us. I am especially interested in these types of resources:

  • Cosmos DB
  • Key Vaults
  • SQL Servers/Databases
  • Storage accounts

However, I would really appreciate some comments also for:

  • Log Analytics Workspace
  • Service Bus Namespace
  • Microsfot Insights Action Groups
Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
Azure SQL Database
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,636 Reputation points
    2021-11-08T09:22:03.827+00:00

    Hi @Lubomir Sokolovsky , welcome to Microsoft Q&A forum and apologies for delay in response.

    Currently Activity log events are retained in Azure for 90 days and then deleted as you mentioned. For additional functionality such as longer retention, you should create a diagnostic setting and route the entires to another location based on your needs. See the criteria in the earlier section of below article.

    Azure Activity log

    There are specific ways we can check for different azure resources about last accessed date. As an example, please check below article for Azure SQL Database access:

    Find the time when table was last accessed in SQL Server database

    For Cosmos DB, we can check the '_ts' property of element by using similar below query:

    SELECT top 1 c._ts FROM c order by c._ts desc  
    

    Once we have the list of resources that are older than our requirements, we can remove them according to requirements.

    Please let us know if you need any more details on this and we can discuss further.

    ----------

    Please don't forgot to click on accept it as answer button 147199-image.png wherever the information provided helps you. This can be beneficial to other community members as well.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.