获取工作区、群集、笔记本、模型和作业标识符Get workspace, cluster, notebook, model, and job identifiers

本文将介绍如何在 Azure Databricks 中获取工作区、群集、模型、笔记本、作业标识符和作业 URL。This article explains how to get workspace, cluster, model, notebook, and job identifiers and URLs in Azure Databricks.

工作区实例名称、URL 和 ID Workspace instance names, URLs, and IDs

唯一的实例名称(也称为每工作区 URL)已分配给每个 Azure Databricks 部署 。A unique instance name, also known as a per-workspace URL, is assigned to each Azure Databricks deployment. 它是完全限定的域名,用于登录到 Azure Databricks 部署和发出 API 请求。It is the fully-qualified domain name used to log into your Azure Databricks deployment and make API requests.

Azure Databricks 工作区 是运行 Azure Databricks 平台的位置,可在其中创建 Spark 群集和计划工作负载。An Azure Databricks workspace is where the Azure Databricks platform runs and where you can create Spark clusters and schedule workloads. 工作区具有唯一的数字工作区 ID。A workspace has a unique numerical workspace ID.

每工作区 URLPer-workspace URL

此唯一的每工作区 URL 采用以下格式:adb-<workspace-id>.<random-number>.databricks.azure.cnThe unique per-workspace URL has the format adb-<workspace-id>.<random-number>.databricks.azure.cn. 工作区 ID 紧跟在 adb- 的后面,在圆点 (.) 的前面。The workspace ID appears immediately after adb- and before the “dot” (.). 对于每工作区 URL https://adb-5555555555555555.19.databricks.azure.cn/For the per-workspace URL https://adb-5555555555555555.19.databricks.azure.cn/:

  • 实例名称为 adb-5555555555555555.19.databricks.azure.cnThe instance name is adb-5555555555555555.19.databricks.azure.cn.
  • 工作区 ID 为 5555555555555555The workspace ID is 5555555555555555.

确定每工作区 URLDetermine per-workspace URL

可确定工作区的每工作区 URL:You can determine the per-workspace URL for your workspace:

旧区域 URL Legacy regional URL

重要

不要使用旧的区域 URL。Avoid using legacy regional URLs. 它们可能不适用于新的工作区、可靠性更低,而且性能比每工作区 URL 的低。They may not work for new workspaces, are less reliable, and exhibit lower performance than per-workspace URLs.

旧区域 URL 由部署 Azure Databricks 工作区的区域和域 databricks.azure.cn(例如 https://chinaeast2.databricks.azure.cn/)组成。The legacy regional URL is composed of the region where the Azure Databricks workspace is deployed plus the domain databricks.azure.cn, for example, https://chinaeast2.databricks.azure.cn/.

  • 如果登录到类似 https://chinaeast2.databricks.azure.cn/ 的旧区域 URL,则实例名称为 chinaeast2.databricks.azure.cnIf you log in to a legacy regional URL like https://chinaeast2.databricks.azure.cn/, the instance name is chinaeast2.databricks.azure.cn.
  • 仅在使用旧区域 URL 登录之后,此 URL 中才会显示工作区 ID。The workspace ID appears in the URL only after you have logged in using a legacy regional URL. 它显示在 o= 的后面。It appears after the o=. 在 URL https://<databricks-instance>/?o=6280049833385130 中,工作区 ID 为 6280049833385130In the URL https://<databricks-instance>/?o=6280049833385130, the workspace ID is 6280049833385130.

群集 URL 和 IDCluster URL and ID

Azure Databricks 群集为运行生产 ETL 管道、流分析、临时分析和机器学习等各种用例提供了统一平台。An Azure Databricks cluster provides a unified platform for various use cases such as running production ETL pipelines, streaming analytics, ad-hoc analytics, and machine learning. 每个群集都有一个被称作群集 ID 的唯一 ID。Each cluster has a unique ID called the cluster ID. 这既适用于通用群集,也适用于作业群集。This applies to both all-purpose and job clusters. 若要使用 REST API 获取群集的详细信息,必须使用群集 ID。To get the details of a cluster using the REST API, the cluster ID is essential.

若要获取群集 ID,请单击边栏中的“群集”选项卡,然后选择群集名称。To get the cluster ID, click the Clusters tab in sidebar and then select a cluster name. 群集 ID 是此页面的 URL 中 /clusters/ 组件后面的数字The cluster ID is the number after the /clusters/ component in the URL of this page

https://<databricks-instance>/#/settings/clusters/<cluster-id>

在以下屏幕截图中,群集 ID 为:0831-211914-clean632In the following screenshot, the cluster ID is 0831-211914-clean632.

群集 URLCluster URL

笔记本 URL 和 ID Notebook URL and ID

笔记本是文档的基于 Web 的接口,其中包含可运行的代码、可视化效果和叙述性文本。A notebook is a web-based interface to a document that contains runnable code, visualizations, and narrative text. 笔记本是用于与 Azure Databricks 进行交互的接口。Notebooks are one interface for interacting with Azure Databricks. 每个笔记本都具有唯一的 ID。Each notebook has a unique ID. 笔记本 URL 具有笔记本 ID,因此笔记本 URL 对于笔记本而言是唯一的。The notebook URL has the notebook ID, hence the notebook URL is unique to a notebook. 可与 Azure Databricks 平台上有权查看和编辑笔记本的任何人共享笔记本 ID。It can be shared with anyone on Azure Databricks platform with permission to view and edit the notebook. 此外,每个笔记本命令(单元)都有不同的 URL。In addition, each notebook command (cell) has a different URL.

若要访问笔记本 URL,请打开笔记本。To get to a notebook URL, open a notebook.

在以下笔记本中,笔记本 URL 是 https://chinaeast2.databricks.azure.cn/?o=6280049833385130#notebook/1940481404050342,笔记本 ID 是 1940481404050342,命令(单元)URL 是In the following notebook, the notebook URL is https://chinaeast2.databricks.azure.cn/?o=6280049833385130#notebook/1940481404050342, the notebook ID is 1940481404050342, and the command (cell) URL is

https://chinaeast2.databricks.azure.cn/?o=6280049833385130#notebook/1940481404050342/command/2432220274659491

笔记本 URLNotebook URL

模型 IDModel ID

模型指的是 MLflow 已注册的模型,你可使用它通过阶段转换和版本控制在生产中管理 MLflow 模型。A model refers to an MLflow registered model, which lets you manage MLflow Models in production through stage transitions and versioning. 通过权限 API 以编程方式更改此模型的权限时,需要使用已注册模型的 ID。The registered model ID is required for changing the permissions on the model programmatically through the Permissions API.

若要获取已注册模型的 ID,可使用 REST API 2.0 终结点 mlflow/databricks/registered-models/getTo get the ID of a registered model, you can use the REST API 2.0 endpoint mlflow/databricks/registered-models/get. 例如,下面的代码会返回已注册模型的对象及其属性,包括其 ID:For example, the following code returns the registered model object with its properties, including its ID:

curl -n -X GET -H 'Content-Type: application/json' -d '{"name": "model_name"}' \
https://<databricks-instance>/api/2.0/mlflow/databricks/registered-models/get

返回的值采用以下格式:The returned value has the format:

{
  "registered_model_databricks": {
    "name":"model_name",
    "id":"ceb0477eba94418e973f170e626f4471"
  }
}

作业 URL 和 IDJob URL and ID

作业是立即运行或按计划运行笔记本或 JAR 的一种方法。A job is a way of running a notebook or JAR either immediately or on a scheduled basis.

若要访问作业 URL,请单击边栏中的“作业”选项卡,然后单击作业名称。To get to a job URL, click the Jobs tab in sidebar and click a job name. 若要对失败的作业运行进行故障排除并调查根本原因,必须使用此作业 URL。This job URL is critical piece of information needed to troubleshoot job runs that have failed and investigate the root cause.

在以下屏幕截图中,作业 URL 为 https://chinaeast2.databricks.azure.cn/?o=6280049833385130#job/1,作业 ID 为 1In the following screenshot, the job URL is https://chinaeast2.databricks.azure.cn/?o=6280049833385130#job/1, and the job ID is 1.

作业 URLJob URL