Home > Back-end >  Find out the resource group of the storage account of cloud shell
Find out the resource group of the storage account of cloud shell

Time:12-13

So I know that there is a storage account behind Azure Cloud Shell. How can I find out which storage account it is and most important which resource group is my Cloud Shell storage account belongs to?

CodePudding user response:

When you use basic settings and select only a subscription, Cloud Shell creates three resources on your behalf in the supported region that's nearest to you:

  • Resource group: cloud-shell-storage-[region]
  • Storage account: cs[uniqueGuid]
  • File share: cs-[user]-[domain]-com-[uniqueGuid]

Storage accounts that you create in Cloud Shell are tagged with ms-resource-usage:azure-cloud-shell.

enter image description here

CodePudding user response:

Based on the above shared Requirement, we have created the below PowerShell script which will pull the cloud shell storage accounts & their respective resource groups.

We have tested the below script in our local environment which is working fine.

Here is the PowerShell Script :

Connect-AzAccount

$strglist=Get-AzStorageAccount ##pulling the storageaccounts in that particular subscription that you have connected to.

foreach( $item in $strglist){

    if( ($item.StorageAccountName -like 'cs*') -and  ($item.ResourceGroupName -like 'cloud-shell-storage*'))
    {
        Write-Host $item.StorageAccountName,$item.ResourceGroupName
    }
}

Note :

All the cloud Shell storage accounts will have name start with 'cs' & respective resource groups will be with 'cloud-shell-storage' so we have used the -like operator & wildcards to pull the list of storage accounts.

Here is the sample output for reference:

enter image description here

  • Related