def validate_storage_account_id(ns): from azure.keyvault import StorageAccountId acct_name = getattr(ns, 'storage_account_name', None) vault = getattr(ns, 'vault_base_url', None) identifier = getattr(ns, 'identifier', None) if identifier: ident = StorageAccountId(uri=identifier) setattr(ns, 'storage_account_name', ident.name) setattr(ns, 'vault_base_url', ident.vault) elif not (acct_name and vault): raise CLIError('incorrect usage: --id ID | --vault-name VAULT --name NAME')
def get_storage_accounts(self): """ Lists the storage accounts in the vault, and gets each. """ from azure.keyvault import StorageAccountId # list the storage accounts in the vault print('list and get storage accounts managed by the vault') storage_accounts = list( self.keyvault_sp_client.get_storage_accounts( vault_base_url=self.sample_vault_url, maxresults=5)) # for each storage account parse the id and get the storage account for sa in storage_accounts: sa_id = StorageAccountId(uri=sa.id) storage_account = self.keyvault_sp_client.get_storage_account( vault_base_url=sa_id.vault, storage_account_name=sa_id.name) print(sa_id.name, storage_account.resource_id)