快速入门:设置用户以运行查询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. 在终结点列表中,在筛选器框中键入 QSIn 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:配置 default 数据库的访问权限Step 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   |
    +------------------+---------------+------------+-----------+