使用 distcp 复制到 Azure ADLS Gen1 失败并显示 403

Using distcp to copy to Azure ADLS Gen1 fails with 403

我正在尝试复制到 Azure Data Lake Storage (ADLS) Gen1,同时使用 OAuth2 进行身份验证。

我收到以下错误:

com.microsoft.azure.datalake.store.ADLException: Error getting info for file /myContainer Operation GETFILESTATUS failed with HTTP403 : null

这是我的 distcp 的样子

hadoop distcp 
    -Dfs.adl.oauth2.access.token.provider.type=ClientCredential 
    -Dfs.adl.oauth2.client.id=<client_id>
    -Dfs.adl.oauth2.credential=<key>
    -Dfs.adl.oauth2.refresh.url=https://login.microsoftonline.com/*****/oauth2/token 
hdfs:///path/to/file 
adl://adlsgen1.blob.core.windows.net/myContainer

知道是什么原因造成的吗?

如果您想使用 Azure AD 通过服务主体访问 Azure 数据湖 gen2,我们需要 configure RABC role 服务主体。

例如

  1. 创建服务主体并将 Storage Blob Data Owner 分配给 sp。(我使用 Azure CLI)。
az ad sp create-for-rbac -n "MyApp" --role "Storage Blob Data Owner"\
    --scopes /subscriptions/{SubID}/resourceGroups/{ResourceGroup1} \
    /subscriptions/{SubID}/resourceGroups/{ResourceGroup2}
  1. 配置
hadoop distcp 
    -D fs.azure.account.auth.type=OAuth 
    -D fs.azure.account.oauth.provider.type=org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider
    -D fs.azure.account.oauth2.client.endpoint=[token endpoint],
    -D fs.azure.account.oauth2.client.id=[Application client ID],
    -D fs.azure.account.oauth2.client.secret=[client secret]
hdfs:///path/to/file 
abfs://container1@abfswales1.dfs.core.windows.net/

详情请参考document and the document