1

Is there any way to get azure Resource ID for azure storage using azure storage connection string with rest API or any other programmatically in c#.

I need subscriptionId and resourceGroupName of the storage account

Jay Dadhaniya
  • 171
  • 4
  • 15
  • You don't need a Resource ID to use Azure Storage or in Azure connection-strings. All you need is the account-name and one of your account keys - or a SAS signature. – Dai Jun 07 '21 at 05:53
  • ...and the Account Name is in the hostname. – Dai Jun 07 '21 at 05:53

1 Answers1

3

Is there any way to get azure Resource ID for azure storage using azure storage connection string with rest API or any other programmatically in c#.

Using the connection string, it is not possible to get the resource id for a storage account. With connection string, you can perform data related operations on the storage account (also known as data plane operations). For resource id, you would need to perform management operation on the storage account (also known as control plane operations).

To get the resource id, you would need to use Storage Resource Provider REST API. The SDK you would want to use is Azure.ResourceManager.Storage.

However if you know the your Azure Subscription id, the name of the resource group where your storage account is and (obviously) the name of your storage account, you can construct the resource id using the following convention:

/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Storage/storageAccounts/{storage-account-name}
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241