DBFS使用dbutils实现存储服务的装载(mount、挂载),用户可以把Azure Data Lake Storage Gen2和Azure Blob Storage 账户装载到DBFS中。Mount是Data Lake Storage Gen2的指针,因此数据不会同步到本地,但是用户可以访问远程文件系统中的数据。Mount操作相当于创建了一个共享文件系统。
要实现挂载,需要5个最基本条件:
- Azure Data Lake Storage Gen2 account
- Azure Application
- Azure Key Vault
- Databricks Workspace
- Secret Scope
一,创建Azure Data Lake Storage Gen2 Account
从Azure Portal中搜索Storage Accounts服务,创建Data Lake V2 Account
1,创建Data Lake V2的详细步骤
Step1:配置Basics选项卡
配置Storage Account使用的Subscription和Resource group;
选择Account Kind为:StorageV2(General purpose v2);
![](https://img-blog.csdnimg.cn/img_convert/bf8f1aaee06598e96aaefa78aaacd46f.png)
Step2:Networking 使用默认值
Step3:Data Protection 使用默认值
Step4:配置Advanced选项卡,
启用"Hierarchical namespace",这是Data Lake Storage Gen2的独有功能,有层次结构的文件系统
![](https://img-blog.csdnimg.cn/img_convert/bdeac8df13bb12b9fa154e812143ce44.png)
Step5:Review+Create
2,为Data Lake Storage Gen2创建文件系统
进入到Data Lake Storage Gen2的资源页面中,从“Tools and SDKs”中选择“Storage Explorer”,
![](https://img-blog.csdnimg.cn/img_convert/29065e7d597ff03921d003b1eb39ad04.png)
进入到Storage Explorer中,右击CONTAINERS,选择“Create file system”:
![](https://img-blog.csdnimg.cn/img_convert/ef77c802c5a245288501b640858e6819.png)
文件系统其实就是一个Directory,并可以创建子目录。
二,注册Application
为了在ADLS Gen 2和Azure Databricks之间建立连接,需要建立应用程序连接,因此我们需要注册一个Azure AD application,创建一个服务主体(Service Principal),用于生成application 验证密钥,该密钥称作Client Secret,存储在Azure Key Vault实例中。
1,注册App