Reputation: 1878
I couldn't find anything about how to get all storage accounts
, I know it is possible get all blob containers
and queues
, so Is it possible to get all storage accounts
by Azure-Functions?
Or is it possible to generate a unique SAS Token
for access all storage Accounts
, so I can use on StorageCredentials(string sasToken)
?
Upvotes: 3
Views: 4132
Reputation: 8265
another option for getting a list of all storage accounts under the subscription is to use the REST API, see Storage Accounts - List.
Note, that the Bearer token is required.
Upvotes: 2
Reputation: 20127
You could use Microsoft.Azure.Management.Fluent
to list all the storage account in your subscription.
Refer to the following code:
var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"D:\azurecred.txt");
var azure = Azure
.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithDefaultSubscription();
var account = azure.StorageAccounts.List();
You need to set subscription,client,key,tenantId in your credentials file.
Upvotes: 4
Reputation: 59001
It is possible to get all storage accounts using the StorageManagementClient
(you have to install the Microsoft.WindowsAzure.Management.Storage
NuGet package).
After you set your authentication and subscription you can call the List()
method on the StorageAccounts
property. e. g. :
new StorageManagementClient().StorageAccounts.List()
The List Storage Accounts operation lists the storage accounts that are available in the specified subscription.
Upvotes: 3