Ejemplo n.º 1
0
def create_adls_account(cmd, client, resource_group_name, account_name, location=None, default_group=None, tags=None,
                        encryption_type=EncryptionConfigType.service_managed.value, key_vault_id=None, key_name=None,
                        key_version=None, disable_encryption=False, tier=None):

    location = location or _get_resource_group_location(cmd.cli_ctx, resource_group_name)
    create_params = CreateDataLakeStoreAccountParameters(
        location=location,
        tags=tags,
        default_group=default_group,
        new_tier=tier)

    if not disable_encryption:
        identity = EncryptionIdentity()
        config = EncryptionConfig(type=encryption_type)
        if encryption_type == EncryptionConfigType.user_managed:
            if not key_name or not key_vault_id or not key_version:
                # pylint: disable=line-too-long
                raise CLIError('For user managed encryption, --key_vault_id, --key_name and --key_version are required parameters and must be supplied.')
            config.key_vault_meta_info = KeyVaultMetaInfo(
                key_vault_resource_id=key_vault_id,
                encryption_key_name=key_name,
                encryption_key_version=key_version)
        else:
            if key_name or key_vault_id or key_version:
                # pylint: disable=line-too-long
                logger.warning('User supplied Key Vault information. For service managed encryption user supplied Key Vault information is ignored.')

        create_params.encryption_config = config
        create_params.identity = identity
    else:
        create_params.encryption_state = EncryptionState.disabled
        create_params.identity = None
        create_params.encryption_config = None

    return client.create(resource_group_name, account_name, create_params).result()
Ejemplo n.º 2
0
def create_adls_account(cmd, client, resource_group_name, account_name, location=None, default_group=None, tags=None,
                        encryption_type=EncryptionConfigType.service_managed.value, key_vault_id=None, key_name=None,
                        key_version=None, disable_encryption=False, tier=None):

    location = location or _get_resource_group_location(cmd.cli_ctx, resource_group_name)
    create_params = CreateDataLakeStoreAccountParameters(
        location=location,
        tags=tags,
        default_group=default_group,
        new_tier=tier)

    if not disable_encryption:
        identity = EncryptionIdentity()
        config = EncryptionConfig(type=encryption_type)
        if encryption_type == EncryptionConfigType.user_managed:
            if not key_name or not key_vault_id or not key_version:
                # pylint: disable=line-too-long
                raise CLIError('For user managed encryption, --key_vault_id, --key_name and --key_version are required parameters and must be supplied.')
            config.key_vault_meta_info = KeyVaultMetaInfo(key_vault_id, key_name, key_version)
        else:
            if key_name or key_vault_id or key_version:
                # pylint: disable=line-too-long
                logger.warning('User supplied Key Vault information. For service managed encryption user supplied Key Vault information is ignored.')

        create_params.encryption_config = config
        create_params.identity = identity
    else:
        create_params.encryption_state = EncryptionState.disabled
        create_params.identity = None
        create_params.encryption_config = None

    return client.create(resource_group_name, account_name, create_params).result()