How to check the usage and status of Azure objects before decommisioning?

EnterpriseArchitect 5,036 Reputation points
2023-11-28T10:35:21.11+00:00

Could you please explain how to use Azure PowerShell to check if the Azure object has not been used for some time or has been neglected and is therefore safe to delete?

Use the following command:

Get-AzureRmResource -ResourceId $ObjectId

The output will show the status of the object and whether it is currently in use. If the status is "unused", the object is safe to delete.

However, it is already deprecated, so I wonder how to use the replacement command to achieve the same?

https://video2.skills-academy.com/en-us/powershell/module/az.resources/get-azresource?view=azps-11.0.0

Any help would be greatly appreciated.

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
669 questions
Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,286 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,263 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,273 questions
{count} votes

1 answer

Sort by: Most helpful
  1. v-vvellanki-MSFT 4,915 Reputation points Microsoft Vendor
    2023-11-29T10:45:39.8233333+00:00

    Hi @EnterpriseArchitect ,

    Thanks for contacting Microsoft Q&A platform.
    If you want to retrieve a specific Azure resource using its resource ID, you should use the Get-AzResource cmdlet in the Az module. Here's an example:

    # Install and import the Az module if you haven't already
    Install-Module -Name Az -Force -AllowClobber
    Import-Module Az
    
    # Authenticate to Azure
    Connect-AzAccount
    
    # Replace $ResourceId with the actual resource ID you want to retrieve
    $ResourceId = "/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/{ResourceProviderNamespace}/{ResourceType}/{ResourceName}"
    
    # Get the specific Azure resource
    $resource = Get-AzResource -ResourceId $ResourceId
    
    # Display information about the resource
    $resource | Format-List
    

    Please replace your subscription and resource group and other details in the script.

    Hope this helps you.