Here are the steps to generate such a report:
Using Azure PowerShell
- Install Azure PowerShell Module:
If not already installed, you can install the Azure PowerShell module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
- Login to Azure:
Log in to your Azure account:
Connect-AzAccount
- List Storage Accounts and Check for Immutability Policies:
The following script lists all storage accounts across all subscriptions and checks each container for an immutability policy:
# Get all subscriptions $subscriptions = Get-AzSubscription foreach ($subscription in $subscriptions) { # Set the context to the subscription Set-AzContext -SubscriptionId $subscription.Id # List all storage accounts in the subscription $storageAccounts = Get-AzStorageAccount foreach ($storageAccount in $storageAccounts) { # Get the context for the storage account $context = $storageAccount.Context # List all containers in the storage account $containers = Get-AzStorageContainer -Context $context foreach ($container in $containers) { # Check if the container has an immutability policy $immutabilityPolicy = Get-AzStorageContainerImmutabilityPolicy -ContainerName $container.Name -Context $context if ($immutabilityPolicy) { # Output details if the container has an immutability policy Write-Output "Subscription: $($subscription.Name), Storage Account: $($storageAccount.StorageAccountName), Container: $($container.Name), Immutability Policy: $($immutabilityPolicy)" } } } }
Additional Considerations
- Permissions: Ensure you have the necessary permissions to list storage accounts and containers across subscriptions.
- Output Format: The script outputs to the console. You can modify it to export the data to a CSV file or another format if needed.
- API Rate Limits: Keep in mind that running this script may take time, especially if you have a large number of subscriptions and storage accounts, due to API rate limits.
This script provides a basic framework. Depending on your exact needs, it might require further customization. If you're not comfortable with PowerShell scripting, you may want to seek assistance from someone with a development background.
Accept the answer if the information helped you. This will help us and others in the community as well.