Search code examples
javaazurecloudazure-storage-account

model object of StorageAccounts in microsoft azure


I have a requirement to fetch all storage accounts from my azure account and list all of their properties. I have configured azure object and using below call to get all storageAccounts.

Azure azure = Azure
                        .configure()
                        .withLogLevel(LogLevel.NONE)
                        .authenticate(credFile)
                        .withDefaultSubscription();                     

StorageAccounts storageAccounts  =  azure.storageAccounts();

I see that in com.microsoft.azure.management.storage.StorageAccounts interface there are many methods, but I am looking for a model object to fetch and list its details just like in case of aws we have com.amazonaws.services.s3.model.Bucket

My question is: which will be the model object in case of azure for the StorageAccounts ?


Solution

  • You could use method .list() to list storage accounts in your subscription. Please check SDK in this link. You could use the following code to get storage accounts properties.

     List<StorageAccount> accounts = azure.storageAccounts().list();
                for (StorageAccount sa : accounts) {
                    System.out.println("Storage Account " + sa.name() + " created @ " + sa.creationTime());
                } 
    

    You also could check this example to manage your storage accounts.