def validate_sas_definition_id(ns): from azure.keyvault import StorageSasDefinitionId acct_name = getattr(ns, 'storage_account_name', None) sas_name = getattr(ns, 'sas_definition_name', None) vault = getattr(ns, 'vault_base_url', None) identifier = getattr(ns, 'identifier', None) if identifier: ident = StorageSasDefinitionId(uri=identifier) setattr(ns, 'sas_definition_name', getattr(ident, 'sas_definition')) setattr(ns, 'storage_account_name', getattr(ident, 'account_name')) setattr(ns, 'vault_base_url', ident.vault) elif not (acct_name and sas_name and vault): raise CLIError('incorrect usage: --id ID | --vault-name VAULT --account-name --name NAME')
def get_sas_definitions(self, storage_account_name, vault_url): """ List the sas definitions for the storage account, and get each. """ from azure.keyvault import StorageSasDefinitionId # list the sas definitions for the storage account print('list and get sas definitions for the managed storage account') sas_defs = list( self.client.get_sas_definitions( vault_base_url=vault_url, storage_account_name=storage_account_name, maxresults=5)) # for each sas definition parse the id and get the SasDefinitionBundle for s in sas_defs: sas_def_id = StorageSasDefinitionId(uri=s.id) sas_def = self.client.get_sas_definition( vault_base_url=sas_def_id.vault, storage_account_name=sas_def_id.account_name, sas_definition_name=sas_def_id.sas_definition) print(sas_def_id.sas_definition, sas_def.template_uri)