Search code examples
azure-storageazure-powershell

Powershell command to retrieve storage account resource id, blob resourceid from Storage account V2


I want to retrieve all components resource id from Storage account using powershell command.

  • Storage Account Resource ID
  • Blob service-Resource ID
  • File service-Resource ID
  • Queue service-Resource ID
  • Table service-Resource ID

I tried with below command for blob service, but resource id is not available in the property

Get-AzStorageBlobServiceProperty -ResourceGroupName "rg-eval" -AccountName "dlseval"

How can I retrieve the Resource Id's dynamically?

enter image description here


Solution

  • AFAIK, There is no direct way to get all the ID that you are looking for, but once you get Storage Account Resource ID, you can combine other service ID yourself, they are fixed, just try the code below:

    $account = Get-AzStorageAccount -ResourceGroupName '<Group Namw>' -Name '<account Name>' 
    
    $accountResID = $account.ID
    $blobResID = $account.ID + "/blobServices/default"
    $fileResID = $account.ID + "/fileServices/default"
    $queueResID = $account.ID + "/queueServices/default"
    $tableResID = $account.ID + "/tableServices/default"