After deleting a virtual system in Azure, not all its associated resources is deleted. Azure users can easily detect such unassociated resources with PowerShell.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our customers to solve Azure related issues.
In this context, we shall look into how to detect Azure un associated resources with PowerShell.
Deleting a virtual system in Azure does not necessary means that all its associated resources are completely deleted with it. You have to identity the unassociated resources which is left behind after the deletion process.
To get started, install Azure PowerShell modules. You can read more about it here.
After installing PowerShell, log into the subscription with the command;
Login-AzAccount
As soon as you log in successfully, you can manage Azure cloud via PowerShell.
You might need to check the Network interfaces after a deleting a virtual system in Azure. To do this, use the command below;
Get-AZNetworkInterface
The output will display a large amount of information. To get the exact useful data concerning unassociated resources, use the command below;
Get-AzNetworkInterface | Select-Object name, virtualmachine
Once we see the excess resources which are not associated with the virtual machine, we simply remove them with the command below;
Get-AzNetworkInterface | Where-Object { $_.virtualmachine -eq $null } | Remove-AzNetworkInterface
To get a list of the disk that is not allocated in the system, use the Get-AzDisk command below;
Get-AzDisk | Select-Object name,managedby
You will see the "empty field for ManagedBy" area which signifies the unallocated disk. Next, you can remove the leftover disks with the command below;
Get-AzDisk | Where-Object { $_.ManagedBy -eq $null } | Remove-AzDisk
Look into the system for unallocated Network Security Groups resources with the format below;
Get-AZNetworkSecurityGroup | Where-Object { $_.NetworkInterfaces.count -eq 0 } | Select-Object name
With the PowerShell tool, we can easily find unassociated resources in Azure.