【问题标题】:Find out the resource group of the storage account of cloud shell找出cloud shell的storage account的资源组
【发布时间】:2026-02-10 17:25:01
【问题描述】:

所以我知道 Azure Cloud Shell 背后有一个存储帐户。如何找出它是哪个存储帐户以及最重要的是我的 Cloud Shell 存储帐户属于哪个资源组?

【问题讨论】:

    标签: azure azure-storage-account azure-cloud-shell


    【解决方案1】:

    当您使用基本设置并仅选择订阅时,Cloud Shell 会代表您在离您最近的受支持区域创建三个资源:

    • 资源组:cloud-shell-storage-[region]
    • 存储账号:cs[uniqueGuid]
    • 文件共享:cs-[user]-[domain]-com-[uniqueGuid]

    您在 Cloud Shell 中创建的存储帐户用ms-resource-usage:azure-cloud-shell标记

    【讨论】:

    • 也许我在一家大公司,我的许多同事也使用 Cloud Shell。如何找出适合自己的 uniqueGuid?
    • 然后在您的云壳实例中创建一个文件,然后您可以搜索文件共享以找到关联的存储帐户。
    【解决方案2】:

    基于上述共享需求,我们创建了以下 PowerShell 脚本,它将拉取云 shell 存储帐户及其各自的资源组。

    我们已经在本地环境中测试了以下脚本,它运行良好。

    这是 PowerShell 脚本:

    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
        }
    }
    

    注意

    所有云 Shell 存储帐户的名称都以“cs”开头,并且相应的资源组将以“cloud-shell-storage”开头,因此我们使用了-like 运算符和wildcards 来拉取存储列表帐户。

    这是供参考的示例输出:

    【讨论】: