def update_account(client, resource_group_name, account_name, tags=None, storage_account=None, encryption_key_source=None, encryption_key_identifier=None, identity_type=None): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None if (encryption_key_source and encryption_key_source.lower() == "microsoft.keyvault" and not encryption_key_identifier): raise ValueError( "The --encryption-key-identifier property is required when " "--encryption-key-source is set to Microsoft.KeyVault") encryption_key_identifier = KeyVaultProperties(key_identifier=encryption_key_identifier) \ if encryption_key_identifier else None encryption = EncryptionProperties( key_source=encryption_key_source, encryption_key_identifier=encryption_key_identifier ) if encryption_key_source else None identity = BatchAccountIdentity( type=identity_type) if identity_type else None parameters = BatchAccountUpdateParameters(tags=tags, encryption=encryption, identity=identity, auto_storage=properties) return client.update(resource_group_name=resource_group_name, account_name=account_name, parameters=parameters)
def create_account(client, resource_group_name, account_name, location, tags=None, storage_account=None, keyvault=None, keyvault_url=None, no_wait=False, public_network_access=None, encryption_key_source=None, encryption_key_identifier=None, identity_type=None): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None identity = BatchAccountIdentity(type=identity_type) if identity_type else None if (encryption_key_source and encryption_key_source.tolower() == "microsoft.keyvault" and not encryption_key_identifier): raise ValueError("The --encryption-key-identifier property is required when " "--encryption-key-source is set to Microsoft.KeyVault") encryption_key_identifier = KeyVaultProperties(key_identifier=encryption_key_identifier) \ if encryption_key_identifier else None encryption = EncryptionProperties( key_source=encryption_key_source, encryption_key_identifier=encryption_key_identifier) if encryption_key_source else None parameters = BatchAccountCreateParameters(location=location, tags=tags, auto_storage=properties, public_network_access=public_network_access, encryption=encryption, identity=identity) if keyvault: parameters.key_vault_reference = {'id': keyvault, 'url': keyvault_url} parameters.pool_allocation_mode = 'UserSubscription' return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name, account_name=account_name, parameters=parameters)
def update_account(client, resource_group_name, account_name, tags=None, storage_account=None): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None return client.update(resource_group_name=resource_group_name, account_name=account_name, tags=tags, auto_storage=properties)
def create_account(client, resource_group_name, account_name, location, # pylint:disable=too-many-arguments tags=None, storage_account=None): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None parameters = BatchAccountCreateParameters(location=location, tags=tags, auto_storage=properties) return client.create(resource_group_name=resource_group_name, account_name=account_name, parameters=parameters)
def create_account(client, resource_group_name, account_name, location, tags=None, storage_account=None, keyvault=None, keyvault_url=None, no_wait=False): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None parameters = BatchAccountCreateParameters(location=location, tags=tags, auto_storage=properties) if keyvault: parameters.key_vault_reference = {'id': keyvault, 'url': keyvault_url} parameters.pool_allocation_mode = 'UserSubscription' return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name, account_name=account_name, parameters=parameters)
def create_account(client, # pylint:disable=too-many-arguments resource_group_name, account_name, location, tags=None, storage_account=None, keyvault=None, keyvault_url=None): properties = AutoStorageBaseProperties(storage_account_id=storage_account) \ if storage_account else None parameters = BatchAccountCreateParameters(location=location, tags=tags, auto_storage=properties) if keyvault: parameters.key_vault_reference = {'id': keyvault, 'url': keyvault_url} parameters.pool_allocation_mode = 'UserSubscription' return client.create(resource_group_name=resource_group_name, account_name=account_name, parameters=parameters)
def update_account( client, resource_group_name, account_name, #pylint:disable=too-many-arguments tags=None, storage_account_id=None): if storage_account_id: properties = AutoStorageBaseProperties( storage_account_id=storage_account_id) else: properties = None return client.update(resource_group_name=resource_group_name, account_name=account_name, tags=tags, auto_storage=properties)
def _create_batch_account(self, credentials, subscription_id, resource_group, name, location, storage_account_id): """ Creates requested batch account on Azure. Returns a url endpoint and single key """ from azure.mgmt.batch.models import BatchAccountCreateParameters, AutoStorageBaseProperties batch_client = azbatch_mgmt.BatchManagementClient( credentials, subscription_id) batch_async_operation = batch_client.batch_account.create( resource_group_name=resource_group, account_name=name, parameters=BatchAccountCreateParameters( location=location, auto_storage=AutoStorageBaseProperties(storage_account_id))) batch_account = batch_async_operation.result() keys = batch_client.batch_account.get_keys( resource_group_name=resource_group, account_name=name) return (batch_account.name, f'https://{batch_account.account_endpoint}', keys.primary)
def create_batch_account(credentials, subscription_id, **kwargs): """ Create a Batch account :param credentials: msrestazure.azure_active_directory.AdalAuthentication :param subscription_id: str :param **resource_group: str :param **batch_account: str :param **region: str :param **storage_account_id: str """ batch_management_client = BatchManagementClient(credentials, subscription_id) batch_account = batch_management_client.batch_account.create( resource_group_name=kwargs.get("resource_group", DefaultSettings.resource_group), account_name=kwargs.get("batch_account", DefaultSettings.batch_account), parameters=BatchAccountCreateParameters( location=kwargs.get('region', DefaultSettings.region), auto_storage=AutoStorageBaseProperties( storage_account_id=kwargs.get('storage_account_id', DefaultSettings.region)))) return batch_account.result().id