How I can Delete Storage Accounts Without Affecting Virtual Machines?

Omn 0 Reputation points
2024-05-08T17:30:28.6266667+00:00

hi. can i delete i delete resources that are listed as "storage account' without causing any issues with resources listed as "virtual machines" my virtual machines where not configured to manually access and resources other than what they were spun up with. these storage accounts seems to be costing quite a bit of money and i don't believe they is any use for them.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,757 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Amrinder Singh 3,255 Reputation points Microsoft Employee
    2024-05-08T17:56:30.2133333+00:00

    Hi Omn - Thanks for reaching out.

    Before deleting an account there are couple of pointers to review:

    • Ensuring the storage accounts are not being used by any application.
    • The account are not configured for any VM diagnostics data.
    • Deleting a storage account will also delete any associated resources, such as containers and VHDs. So it is important to ensure that you have properly backed up any data or resources that you want to keep before deleting the storage account.

    Once you have verified this, you can check for next 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.


  2. Sumarigo-MSFT 44,081 Reputation points Microsoft Employee
    2024-05-13T06:25:12.2233333+00:00

    @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.

    0 comments No comments