Home > Software engineering >  Programmatically Get Storage Account Key
Programmatically Get Storage Account Key

Time:09-28

I am building a UWP application. I want to upload and download data to Azure Blob containers belonging to various storage accounts. I do not intend to store the connection strings as they keep rotating.

Is there a way to dynamically get the storage account key?

(I have the container name and Blob URL)

Once I get the account key, I can generate the connection string using:

DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<???>;EndpointSuffix=core.windows.net

Using Azure.Storage.Blob - V12

CodePudding user response:

Way-1: There is one way to get the Storage account key is by using Azure CLI commands as below and I followed Microsoft-Document:

az storage account keys list -g xx -n yy

xx- Name of the resource group yy- Name of Storage account

enter image description here

Way 2: To get programmatically, Thanks to @Ivan Yang and I followed his SO-Thread :

keys = storage_client.storage_accounts.list_keys(RESOURCE_GROUP_NAME,STORAGE_ACCOUNT_NAME)

So the Storage Account key is the value of keys.keys[0].value

Way 3: You can also get storage account key by using api and call the below api in c# to get the Key and I followed Microsoft-Document as below: POST Req:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys?api-version=2021-09-01

References :

CodePudding user response:

I HAVE A DOUBT IN MY PROFILE MY DOUBT IS ABOUT private void SelectionChanged(object sender, SelectionChangedEventArgs e)

  • Related