This article about,
List storage accounts in azure subscription or get storage details in azure subscription
What is Storage account in Azure Subscription?
Storage account is storage space given by Microsoft Azure can be used to store files. It supports different type of storage like Blob containers, File shares etc. Storage account support Mutiple tiers and pricing change as per tier we use while creating storage accounts.
Very famous type of storage is blob container where you can store the files like local disk and can be accessed easily whenever required. You can upload or download files on azure storage container.
Whenever you create storage account it has storage account name and Access key. This can be used to connect storage account. We can create access policy based on requirement.
If you are SQL DBA and you want to take SQL backup, from SQL 2012 we can take URL backup on azure blob storage. We can easily restore database from blob storage where out backup placed. You can take any type of backup of SQL Server on blob storage.
To view storage account, Download Azure storage explorer and then connect Storage account using storage account and access key. This can be done by using PowerShell to get storage details in azure subscription.
If you have multiple storage account on storage account whenever we have all production servers are on Azure. We need multiple storage account for different purpose for app servers and database servers.
If you want to
How to List storage accounts in azure subscription? or get storage details in azure subscription
Below script can help to export all storage details in excel file.
Step 1: Connect Azure account for subscription from which we need to retrieve storage account details.
To run below script, you need email account and password which have subscription access. Also need Subscription name and Tenant ID.
#Connct to subscription
$User = "Email ID having access on Azure Subscription"
$PWord = ConvertTo-SecureString -String "account password" -AsPlainText -Force
$tenant = "tenant ID you will get from portal in Azure directory"
$subscription = "Subscription Name"
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User,$PWord
Connect-AzAccount -Credential $Credential -Tenant $tenant -Subscription $subscription
Some time you will receive the term ‘Connect-AzAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program. if you received this message AZ module is not installed on your machine.
This below error because AZ module is not installedConnect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.At line:16 char:1+ Connect-AzAccount -Credential $Credential -Tenant $tenant -Subscripti ...+ ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
To install AZ module run below command and run above script to connect Azure subscription.
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -AllowClobber
Step 2: List storage accounts in azure subscription. Below script export all storage details in excel file. This script will capture storage name, resource group name, replication type, storage location.
$storageaccounts = Get-AzStorageAccount
$storageaccounts | Get-Member
$storageaccounts = Get-AzStorageAccount
$result = foreach($storageaccount in $storageaccounts)
{
[PSCustomObject]@{
Name = $storageaccount.StorageAccountName
Location = $storageaccount.Location
Kind = $storageaccount.Kind
Replication = $storageaccount.Sku.name
RGName = $storageaccount.ResourceGroupName
}
}
$result | Export-Csv -Path "C:\temp\storagedetails.csv" #Create folder or change path n script
This will create excel file with all details. If you want to get storage details from another subscription just need to change subscription name and tenant ID and you can get storage details in azure subscription.