@Omn Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
Adding more information to the above response!
This thread provides detailed information: How to find out which of the resources are linked to a storage account?
If you want to find out all the Azure Resources in a subscription which are using Azure Storage account to store logs or diagnostics data, you can leverage the below PowerShell script.
Note: Before running the sample ensure that you have the necessary Azure PowerShell modules installed. see below:
Install-Module -Name Az.Accounts
Install-Module -Name Az.Resources
Install-Module -Name Az.Storage
After importing the above modules, you need to update the subscription ID in the below PS script:
# Login to Azure
Connect-AzAccount
# Select the concerned subscription ID
Select-AzSubscription -SubscriptionId 'XXXXXXX'
Write-Output "`r`n"
# Get all resources in the subscription
$resources = Get-AzResource
# Loop through each resource and check if it has Azure monitor with storage diagnostic enabled
foreach ($resource in $resources) {
$resourceName = $resource.Name
$resourceType = $resource.ResourceType
$resourceId = $resource.ResourceId
# Check if the resource has Azure monitor with storage diagnostic enabled
$diagnosticSettings = Get-AzDiagnosticSetting -ResourceId $resourceId -ErrorAction SilentlyContinue
if ($diagnosticSettings -ne $null -and $diagnosticSettings.StorageAccountId -ne $null) {
# If it has Azure monitor with storage diagnostic enabled, get the storage account name
$storageAccountId = $diagnosticSettings.StorageAccountId
# $storageAccountName = (Get-AzStorageAccount -ResourceGroupName $resource.ResourceGroupName -Name $storageAccountId.Split("/")[-1]).StorageAccountName
# Output the resource name and storage account name
Write-Output "$resourceId of Type ($resourceType) has Azure monitor with storage diagnostic enabled. Storage account ID: $storageAccountId"
Write-Output "`r`n"
}
}
Yes, you can delete storage accounts without causing any issues to resources listed as virtual machines. Virtual machines are not configured to manually access resources other than what they were initially set up with. If these storage accounts are costing a significant amount of money and you believe there's no use for them, it should be safe to delete them. Just ensure that you won't be affecting any other services or data that might be dependent on those storage accounts.
Note: If you do not find any dependencies on the storage account, you can safely delete it. However, please note that deleting a storage account will also delete all the data stored in it, so make sure that you have backed up any important data before deleting the storage account.
For more insight and guidance on this scenario, I recommend reaching out to the Billing and Subscription team. They can provide assistance in identifying which storage account is incurring charges and where these charges are billed. You can utilize the free support provided by Azure by creating a support ticket for your specific situation. Visit this link for further assistance: https://azure.microsoft.com/en-us/support/options/
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.