快速入門:設定使用者以執行查詢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 分析 使用者快速入門需要此功能。It is required for the SQL Analytics user quickstart.
規格需求Requirements
- Premium 方案上的 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:新增使用者並啟用 SQL Analytics 存取 Step 1: Add a user and enable for SQL Analytics access
以系統管理員身分登入您的 Azure Databricks 工作區。Log in to your Azure Databricks workspace as an admin.
按一下側邊欄底部的At the bottom of the sidebar, click the
應用程式切換器圖示並選取app switcher icon and select
在工作區 UI [工作區] 設定的右上方
,按一下
圖示使用者帳戶圖示,然後選取 [ 管理主控台]。At the top right of the Workspace UI
, click the
user account icon, and select Admin Console.
在 [ 使用者 ] 索引標籤上,按一下 [ 新增使用者]。On the Users tab, click Add User.
在 [ 電子郵件 ] 欄位中,輸入使用者的電子郵件地址,例如
user@example.com
。In the Email field, enter the user email address, for example,user@example.com
.按一下 [ 傳送邀請]。Click Send invite.
在包含電子郵件地址的資料列中,選取 [ SQL 分析存取 ] 核取方塊。In the row containing the email address, select the SQL Analytics access checkbox.
按一下 [確認] 。Click Confirm.
步驟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.
等候狀態為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 | +------------------+---------------+------------+-----------+