You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用只读权限Service Principal在Databricks创建存储挂载失败求助

使用Service Principal挂载Azure存储账户到Databricks的权限问题

我需要在Databricks中使用Service Principal创建到存储账户的挂载。该Service Principal拥有存储账户的Storage Blob Data Reader权限,因为Databricks仅需读取数据,不允许修改。我在Databricks中使用的代码如下:

client_id = dbutils.secrets.get('key-vault', 'client-id')
secret = dbutils.secrets.get('key-vault', 'secret')
tenant_id = dbutils.secrets.get('key-vault', 'tenant-id')

configs = {
    "fs.azure.account.auth.type": "OAuth",
    "fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
    "fs.azure.account.oauth2.client.id": client_id,
    "fs.azure.account.oauth2.client.secret": secret,
    "fs.azure.account.oauth2.client.endpoint": f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"
}

source = f"abfss://container-name@storage-account.dfs.core.windows.net"
mount_point = f"/mnt/mount-name"

dbutils.fs.mount(
  source = source,
  mount_point = mount_point,
  extra_configs = configs
)

但执行时出现如下错误:

An error occurred while calling o434.mount.
: Operation failed: "This request is not authorized to perform this operation.", 403, HEAD, 

我确认密钥保管库中的所有密钥均正确,因此怀疑仅拥有Storage Blob Data Reader权限无法创建挂载。我的判断是否正确?能否不授予Contributor权限实现该需求?


解答

你的判断是正确的:仅拥有Storage Blob Data Reader权限确实无法完成挂载操作。这是因为挂载过程中,Databricks需要先执行容器的HEAD/List操作来验证目标路径的有效性,而Storage Blob Data Reader权限仅允许读取Blob内容,不包含对容器本身的元数据读取或列表权限,无法通过挂载时的预验证步骤。

不需要授予Contributor权限,你可以通过以下方式实现只读挂载:

  • 创建自定义RBAC角色:
    在Azure门户中创建一个自定义角色,包含以下必要权限:

    • Microsoft.Storage/storageAccounts/blobServices/containers/read:允许读取容器元数据、列出容器内容,满足挂载验证需求
    • Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read:允许读取Blob内容和元数据,保证后续数据读取权限
      将该自定义角色分配给目标Service Principal,权限范围限定在目标存储账户或容器即可,避免不必要的权限扩散。
  • 权限验证:分配完成后,重新执行挂载代码即可成功,后续所有数据操作都会受限于只读权限,不会产生修改数据的风险。

内容的提问来源于stack exchange,提问作者Duccio Borchi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 02:16:07