0

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

Shabaz
  • 3
  • 2
  • 1
    You still need to connect to server,. You can get the tables names by using GetSchema. See : https://stackoverflow.com/questions/64724198/azure-function-in-python-get-schema-of-parquet-file?force_isolation=true – jdweng Sep 27 '22 at 15:33

1 Answers1

0

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 :

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
  • Hi. Thank you. It is very insightful. However, as I mentioned, I am trying to build a UWP application. I cannot store the subscriptionID and resource group name as the app will be on the client machine. It can lead to possible security issues. Can you provide some insights on how I can move further? I am authenticating using MSAL. Can I use it somehow? – Shabaz Sep 28 '22 at 10:54
  • You need to give subscription id and resource group to get it using programatically or else you can get directly the keys using Azure portal – RithwikBojja Sep 28 '22 at 10:58