0

I would like to get an instance of Microsoft.WindowsAzure.Storage.Table.CloudTable object from:

  • Azure username,
  • Azure password,
  • storage account name, and
  • table name.

I know how to do access the table having the accountName and the accountKey:

//I would like to use username + password and then specify which account to access
var storageCredentials = new StorageCredentials(accountName, accountKey);
var storageAccount = new CloudStorageAccount(storageCredentials, useHttps: true);
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("my_table");

This is for a simple data export app where the user provides their username and password.


For the record, I ended up using an SAS Token for now.

tymtam
  • 31,798
  • 8
  • 86
  • 126

1 Answers1

0

As far as I know, currently we could only use storage account key or SAS to access the storage resources.

We couldn't directly use azure username and password to access the storage resources.

If you still want to use azure username and password to access the storage resources.

Here is a work around.

You could use azure rest api to get the storage account key by using user name and password firstly(using azure AD to ask access token).

Then send the request to get the storage account key.

POST: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resrouceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/listKeys?api-version=2016-01-01
Authorization: Bearer {token}

At last you could use this storage account key to access the storage table resources.

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
  • I was looking at your answer to https://stackoverflow.com/questions/44515610/c-sharp-programmatically-get-azure-storage-account-proprieties Now, I'm looking if it is possible to get the token without application/client_id. – tymtam Sep 20 '17 at 01:49