Azure Databricks 中的数据集连接

问题描述 投票:0回答:1

我已在 Azure 数据工厂中发布了一个数据集,但无法访问 databricks 中的数据集。

数据集是从连接到 AWS S3 的服务发布的。 Here's the picture.

我尝试阅读 Azure 上的文档,但大多数文档都会建议将此数据放入 Azure Data Lake Storage 中。这是访问数据块中数据的唯一方法吗?

请提供任何好的文档链接。

azure azure-data-factory azure-databricks azure-data-lake azure-data-lake-gen2
1个回答
0
投票

通过设置必要的凭据和配置,将 Azure Databricks 配置为直接从 AWS S3 访问数据。

  • 在 AWS 中,您需要创建一个 IAM 角色,以允许 Azure Databricks 访问 S3 存储桶中的数据。 IAM 角色应有权访问必要的 S3 存储桶和对象。

了解有关外部位置和存储凭证的更多信息,并创建 IAM 角色

使用 Unity Catalog 卷或外部位置访问 S3 存储桶

以下代码将帮助您读取和写入S3存储桶:

从S3读取文件:

dbutils.fs.ls("s3://my-bucket/external-location/path/to/data")
spark.read.format("parquet").load("s3://my-bucket/external-location/path/to/data")
spark.sql("SELECT * FROM parquet.`s3://my-bucket/external-location/path/to/data`")

写入文件:

dbutils.fs.mv("s3://my-bucket/external-location/path/to/data", "s3://my-bucket/external-location/path/to/new-location")
df.write.format("parquet").save("s3://my-bucket/external-location/path/to/new-location")
© www.soinside.com 2019 - 2024. All rights reserved.