快速入门:设置用户以运行查询Quickstart: Set up a user to run a query

重要

此功能目前以公共预览版提供。This feature is in Public Preview. 请联系 Azure Databricks 代表,以申请访问权限。Contact your Azure Databricks representative to request access.

本快速入门介绍如何添加用户、创建 SQL 终结点,并为用户配置数据集访问权限。This quickstart shows how to add a user, create a SQL endpoint, and configure access to datasets for the user. SQL Analytics 用户快速入门是必需的。It is required for the SQL Analytics user quickstart.

要求Requirements

步骤1: 添加用户 Step 1: Add a user

  1. 转到管理控制台Go to the Admin Console.

  2. 在“用户”选项卡上,单击“添加用户”。On the Users tab, click Add User.

  3. 输入用户电子邮件 ID。Enter the user email ID. 可以添加属于 Azure Databricks 工作区的 Azure Active Directory 租户的任何用户。You can add any user who belongs to the Azure Active Directory tenant of your Azure Databricks workspace.

    添加用户Add user

  4. 单击“确定”。Click OK.

用户已添加到工作区。The user is added to the workspace.

已添加用户Added user

尽管未选择 "工作区访问" 和 "SQL Analytics" 复选框,但用户将这些权利作为组的成员继承 users ,该组具有权利。Although the Workspace access and SQL Analytics checkboxes are not selected, the user inherits these entitlements as a member of the users group, which has the entitlements. 工作区管理员可以从组中删除权利 users ,并将其分别分配给 "用户" 页上的用户。Workspace admins can remove the entitlements from the users group and assign them individually to users on the Users page. 有关 SQL Analytics 访问权限的信息,请参阅 管理用户和组For information about the SQL Analytics access entitlement, see Manage users and groups.

步骤2:创建并启动 SQL 端点Step 2: Create and start a SQL endpoint

  1. 在侧栏的底部,选择 "  应用切换器" 图标 >  应用切换器-SQL AnalyticsAt the bottom of the sidebar, select App Switcher Icon > App Switcher - SQL Analytics

  2. 单击Click the 终结点图标 “模型”图标。icon in the sidebar.

  3. 单击 " + 新建 SQL 终结点"。Click + New SQL Endpoint.

    创建终结点Create endpoint

  4. 在“名称”字段中,输入 QS EndpointIn the Name field, enter QS Endpoint.

  5. 自动停止 设置切换为 "开"。Toggle the Auto Stop setting to On.

  6. 选择 " 更多选项"。Select More Options.

  7. 在 "权限" 选项卡中,单击  向下箭头图标 In the Permissions tab, click the Down Arrow  Icon icon. 选择 " 所有用户 " 主体和 " 可以使用 " 权限。Select the All Users principal and the Can Use permission.

  8. 单击 “添加”Click Add.

    快速入门终结点Quickstart endpoint

  9. 单击“创建”。Click Create.

  10. 在 "终结点" 列表中,在 QS "筛选器" 框中键入。In the Endpoints list, type QS in the filter box.

    端点Endpoints

    QS 终结点应显示状态The QS Endpoint should display with State 正在启动 Starting。Starting.

    等待状态为Wait until the State is 运行 正在运行。Running.

步骤3:配置对数据库的访问权限 defaultStep 3: Configure access to the default database

  1. 单击Click the 查询图标 “模型”图标。icon in the sidebar.

  2. 单击 " + 新建查询"。Click + New Query. 将显示查询编辑器。The query editor displays.

  3. 选择 QS 终结 点终结点。Select the QS Endpoint endpoint.

  4. 启用你在 步骤 1 中创建的用户以访问 default用户快速入门中使用的数据库。Enable the user you created in Step 1 to access the default database used in the user quickstart. 逐个输入以下查询:Enter the following queries one by one:

    REVOKE ALL PRIVILEGES ON DATABASE default FROM `user@example.com`;
    
    GRANT USAGE ON DATABASE default TO `user@example.com`;
    
    GRANT SELECT ON DATABASE default TO `user@example.com`;
    
    GRANT READ_METADATA on DATABASE default TO `user@example.com`;
    
    SHOW GRANT `user@example.com` ON DATABASE default;
    

    每次查询后,按 Ctrl/Cmd + enter 或单击 " 执行 " 按钮。After each query, press Ctrl/Cmd + Enter or click the Execute button. 最后一次查询后,应显示:After the last query, it should display:

    +------------------+---------------+------------+-----------+
    | principal        | ActionType    | ObjectType | ObjectKey |
    +------------------+---------------+------------+-----------+
    | user@example.com | READ_METADATA | DATABASE   | default   |
    +------------------+---------------+------------+-----------+
    | user@example.com | SELECT        | DATABASE   | default   |
    +------------------+---------------+------------+-----------+
    | user@example.com | USAGE         | DATABASE   | default   |
    +------------------+---------------+------------+-----------+