示例#1
0
def create_workspace(cmd,
                     client,
                     resource_group_name,
                     workspace_name,
                     storage_account,
                     file_system,
                     sql_admin_login_user,
                     sql_admin_login_password,
                     location,
                     enable_managed_virtual_network=None,
                     tags=None,
                     no_wait=False):
    identity_type = "SystemAssigned"
    identity = ManagedIdentity(type=identity_type)
    account_url = "https://{}.dfs.{}".format(
        storage_account, cmd.cli_ctx.cloud.suffixes.storage_endpoint)
    default_data_lake_storage = DataLakeStorageAccountDetails(
        account_url=account_url, filesystem=file_system)
    workspace_info = Workspace(
        identity=identity,
        default_data_lake_storage=default_data_lake_storage,
        sql_administrator_login=sql_admin_login_user,
        sql_administrator_login_password=sql_admin_login_password,
        location=location,
        managed_virtual_network="default"
        if enable_managed_virtual_network is True else None,
        tags=tags)
    return sdk_no_wait(no_wait, client.create_or_update, resource_group_name,
                       workspace_name, workspace_info)
示例#2
0
def create_workspace(cmd,
                     client,
                     resource_group_name,
                     workspace_name,
                     storage_account,
                     file_system,
                     sql_admin_login_user,
                     sql_admin_login_password,
                     location=None,
                     key_name="default",
                     key_identifier=None,
                     enable_managed_virtual_network=None,
                     allowed_aad_tenant_ids=None,
                     prevent_data_exfiltration=None,
                     tags=None,
                     no_wait=False):
    identity_type = "SystemAssigned"
    identity = ManagedIdentity(type=identity_type)
    account_url = "https://{}.dfs.{}".format(
        storage_account, cmd.cli_ctx.cloud.suffixes.storage_endpoint)
    default_data_lake_storage = DataLakeStorageAccountDetails(
        account_url=account_url, filesystem=file_system)
    encryption = None
    managed_virtual_network_settings = None
    tenant_ids_list = None
    if key_identifier is not None:
        workspace_key_detail = WorkspaceKeyDetails(
            name=key_name, key_vault_url=key_identifier)
        encryption = EncryptionDetails(cmk=CustomerManagedKeyDetails(
            key=workspace_key_detail))

    if [''] == allowed_aad_tenant_ids:
        tenant_ids_list = []
    else:
        tenant_ids_list = allowed_aad_tenant_ids

    if enable_managed_virtual_network:
        if prevent_data_exfiltration:
            managed_virtual_network_settings = ManagedVirtualNetworkSettings(
                prevent_data_exfiltration=True,
                allowed_aad_tenant_ids_for_linking=tenant_ids_list)
        else:
            managed_virtual_network_settings = ManagedVirtualNetworkSettings(
                prevent_data_exfiltration=False)

    workspace_info = Workspace(
        identity=identity,
        default_data_lake_storage=default_data_lake_storage,
        sql_administrator_login=sql_admin_login_user,
        sql_administrator_login_password=sql_admin_login_password,
        location=location,
        managed_virtual_network="default"
        if enable_managed_virtual_network is True else None,
        managed_virtual_network_settings=managed_virtual_network_settings,
        encryption=encryption,
        tags=tags)
    return sdk_no_wait(no_wait, client.begin_create_or_update,
                       resource_group_name, workspace_name, workspace_info)
示例#3
0
def create_workspace(cmd,
                     client,
                     resource_group_name,
                     workspace_name,
                     storage_account,
                     file_system,
                     sql_admin_login_user,
                     sql_admin_login_password,
                     location=None,
                     key_name="default",
                     key_identifier=None,
                     enable_managed_virtual_network=None,
                     allowed_aad_tenant_ids=None,
                     prevent_data_exfiltration=None,
                     tags=None,
                     repository_type=None,
                     host_name=None,
                     account_name=None,
                     collaboration_branch=None,
                     repository_name=None,
                     root_folder='/',
                     project_name=None,
                     tenant_id=None,
                     no_wait=False):
    identity_type = "SystemAssigned"
    identity = ManagedIdentity(type=identity_type)
    account_url = "https://{}.dfs.{}".format(
        storage_account, cmd.cli_ctx.cloud.suffixes.storage_endpoint)
    default_data_lake_storage = DataLakeStorageAccountDetails(
        account_url=account_url, filesystem=file_system)
    encryption = None
    managed_virtual_network_settings = None
    tenant_ids_list = None
    workspace_repository_configuration = None
    if key_identifier is not None:
        workspace_key_detail = WorkspaceKeyDetails(
            name=key_name, key_vault_url=key_identifier)
        encryption = EncryptionDetails(cmk=CustomerManagedKeyDetails(
            key=workspace_key_detail))

    if [''] == allowed_aad_tenant_ids:
        tenant_ids_list = []
    else:
        tenant_ids_list = allowed_aad_tenant_ids

    if enable_managed_virtual_network:
        if prevent_data_exfiltration:
            managed_virtual_network_settings = ManagedVirtualNetworkSettings(
                prevent_data_exfiltration=True,
                allowed_aad_tenant_ids_for_linking=tenant_ids_list)
        else:
            managed_virtual_network_settings = ManagedVirtualNetworkSettings(
                prevent_data_exfiltration=False)

    if repository_type:
        if repository_type == 'AzureDevOpsGit':
            repository_type = 'WorkspaceVSTSConfiguration'
        else:
            repository_type = 'WorkspaceGitHubConfiguration'
        if repository_type == 'WorkspaceVSTSConfiguration' and tenant_id is None:
            from ..util import get_tenant_id
            tenant_id = get_tenant_id()
        if repository_type == 'WorkspaceVSTSConfiguration' and project_name is None:
            from azure.cli.core.azclierror import RequiredArgumentMissingError
            err_msg = 'project_name argument is missing'
            recommendation = 'provide a project name by --project-name'
            raise RequiredArgumentMissingError(err_msg, recommendation)
        workspace_repository_configuration = WorkspaceRepositoryConfiguration(
            type=repository_type,
            host_name=host_name,
            account_name=account_name,
            project_name=project_name,
            repository_name=repository_name,
            collaboration_branch=collaboration_branch,
            root_folder=root_folder,
            tenant_id=tenant_id)

    workspace_info = Workspace(
        identity=identity,
        default_data_lake_storage=default_data_lake_storage,
        sql_administrator_login=sql_admin_login_user,
        sql_administrator_login_password=sql_admin_login_password,
        location=location,
        managed_virtual_network="default"
        if enable_managed_virtual_network is True else None,
        managed_virtual_network_settings=managed_virtual_network_settings,
        encryption=encryption,
        tags=tags,
        workspace_repository_configuration=workspace_repository_configuration)
    return sdk_no_wait(no_wait, client.begin_create_or_update,
                       resource_group_name, workspace_name, workspace_info)