快速入门:设置用户以运行查询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
- 高级计划中的 Azure Databricks 帐户。Azure Databricks account on the Premium plan.
- 启动工作区。Launch a workspace. 您可以使用现有的工作区或创建一个新的工作区。You can use an existing workspace or create a new one. 有关创建工作区的信息,请参阅 快速入门:使用 Azure 门户在 Azure Databricks 上运行 Spark 作业。For information about creating workspaces, see Quickstart: Run a Spark job on Azure Databricks using the Azure portal.
步骤1: 添加用户 Step 1: Add a user
转到管理控制台。Go to the Admin Console.
在“用户”选项卡上,单击“添加用户”。On the Users tab, click Add User.
输入用户电子邮件 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.
单击“确定”。Click OK.
用户已添加到工作区。The user is added to the workspace.
尽管未选择 "工作区访问" 和 "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
在侧栏的底部,选择 "
>
At the bottom of the sidebar, select
>
单击Click the
“模型”图标。icon in the sidebar.
单击 " + 新建 SQL 终结点"。Click + New SQL Endpoint.
在“名称”字段中,输入
QS Endpoint
。In the Name field, enterQS Endpoint
.将 自动停止 设置切换为 "开"。Toggle the Auto Stop setting to On.
选择 " 更多选项"。Select More Options.
在 "权限" 选项卡中,单击
。In the Permissions tab, click the
icon. 选择 " 所有用户 " 主体和 " 可以使用 " 权限。Select the All Users principal and the Can Use permission.
单击 “添加” 。Click Add.
单击“创建”。Click Create.
在 "终结点" 列表中,在
QS
"筛选器" 框中键入。In the Endpoints list, typeQS
in the filter box.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
单击Click the
“模型”图标。icon in the sidebar.
单击 " + 新建查询"。Click + New Query. 将显示查询编辑器。The query editor displays.
选择 QS 终结 点终结点。Select the QS Endpoint endpoint.
启用你在 步骤 1 中创建的用户以访问
default
在 用户快速入门中使用的数据库。Enable the user you created in Step 1 to access thedefault
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 | +------------------+---------------+------------+-----------+