【问题标题】:How to use the Azure Python SDK to provision a Databricks service?如何使用 Azure Python SDK 预配 Databricks 服务?
【发布时间】:2020-07-25 06:32:41
【问题描述】:

[之前在这篇文章中,我询问了如何在没有任何工作空间的情况下提供数据块服务。现在我要问的是如何使用工作空间来提供服务,因为第一种情况似乎不可行。]

作为一名云管理员,我被要求使用 Azure Python SDK 编写一个脚本,该脚本将为我们的一个大数据开发团队提供 Databricks 服务。

除了https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-databricks/0.1.0/azure.mgmt.databricks.operations.html之外,我在网上找不到很多关于 Azure Python SDK 中 Databricks 的信息

https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-databricks/0.1.0/azure.mgmt.databricks.html

这些似乎为配置工作区提供了一些帮助,但我还没有完成。

我错过了什么?

编辑:

感谢@Laurent Mazuel 和@Jim Xu 的帮助。

这是我现在正在运行的代码,以及我收到的错误:

client = DatabricksClient(credentials, subscription_id)
workspace_obj = client.workspaces.get("example_rg_name", "example_databricks_workspace_name")
WorkspacesOperations.create_or_update(
workspace_obj,
"example_rg_name",
"example_databricks_workspace_name",
custom_headers=None,
raw=False,
polling=True
)

错误:

TypeError: create_or_update() missing 1 required positional argument: 'workspace_name'

我对这个错误有点困惑,因为我提供了工作区名称作为第三个参数,并且根据this documentation,这正是该方法所需要的。

我也试过下面的代码:

client = DatabricksClient(credentials, subscription_id)
workspace_obj = client.workspaces.get("example_rg_name", "example_databricks_workspace_name")
client.workspaces.create_or_update(
workspace_obj,
"example_rg_name",
"example_databricks_workspace_name"
)

结果:

 Traceback (most recent call last):
   File "./build_azure_visibility_core.py", line 112, in <module>
     ca_databricks.create_or_update_databricks(SUB_PREFIX)
   File "/home/gitlab-runner/builds/XrbbggWj/0/SA-Cloud/azure-visibility-core/expd_az_databricks.py", line 34, in create_or_update_databricks
     self.databricks_workspace_name
   File "/home/gitlab-runner/builds/XrbbggWj/0/SA-Cloud/azure-visibility-core/azure-visibility-core/lib64/python3.6/site-packages/azure/mgmt/databricks/operations/workspaces_operations.py", line 264, in create_or_update
     **operation_config
   File "/home/gitlab-runner/builds/XrbbggWj/0/SA-Cloud/azure-visibility-core/azure-visibility-core/lib64/python3.6/site-packages/azure/mgmt/databricks/operations/workspaces_operations.py", line 210, in _create_or_update_initial
     body_content = self._serialize.body(parameters, 'Workspace')
   File "/home/gitlab-runner/builds/XrbbggWj/0/SA-Cloud/azure-visibility-core/azure-visibility-core/lib64/python3.6/site-packages/msrest/serialization.py", line 589, in body
     raise ValidationError("required", "body", True)
 msrest.exceptions.ValidationError: Parameter 'body' can not be None.
 ERROR: Job failed: exit status 1

所以 serialization.py 中的第 589 行有错误。我看不出我的代码中的错误是在哪里导致的。感谢所有慷慨提供帮助的人!

【问题讨论】:

    标签: azure azure-sdk-python


    【解决方案1】:

    您需要创建一个 databrick 客户端,并且工作区将附加到它:

    client = DatabricksClient(credentials, subscription_id)
    workspace = client.workspaces.get(resource_group_name, workspace_name)
    

    我认为创建没有工作空间的服务是不可能的,尝试在门户上创建数据块服务,你会看到工作空间名称也是必需的 所以使用 SDK 我会查看client.workspaces.create_or_update的文档

    (我在微软的 SDK 团队工作)

    【讨论】:

      【解决方案2】:

      在@Laurent Mazuel 和 Microsoft 支持工程师的帮助下,我有了一个解决方案:

      managed_resource_group_ID = ("/subscriptions/"+sub_id+"/resourceGroups/"+managed_rg_name)
      client = DatabricksClient(credentials, subscription_id)
      workspace_obj = client.workspaces.get(rg_name, databricks_workspace_name)
      client.workspaces.create_or_update(
          {
              "managedResourceGroupId": managed_resource_group_ID,
              "sku": {"name":"premium"},
              "location":location
          },
          rg_name,
          databricks_workspace_name
      ).wait()
      

      【讨论】:

        猜你喜欢
        • 2013-05-27
        • 2020-02-18
        • 1970-01-01
        • 1970-01-01
        • 2020-05-25
        • 2022-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多