Polybase 到 Azure Data Lake Gen 2 失败
Polybase to Azure Data Lake Gen 2 Failing
我正在尝试通过 Polybase 从 Azure SQLDW 连接到 Data Lake Gen 2 中的 Parquet 文件。这是我的代码:
CREATE DATABASE SCOPED CREDENTIAL DSC_ServicePrincipal
WITH IDENTITY = '1234567890@https://login.microsoftonline.com/1234567890/oauth2/token',
SECRET = '1234567890'
GO
CREATE EXTERNAL DATA SOURCE [DS_ADLS] WITH (TYPE = HADOOP,
LOCATION = N'abfss://filesystem@storageacc.dfs.core.windows.net',
CREDENTIAL = DSC_ServicePrincipal)
GO
CREATE EXTERNAL FILE FORMAT [ParquetFileFormatSnappy]
WITH (FORMAT_TYPE = PARQUET, DATA_COMPRESSION = N'org.apache.hadoop.io.compress.SnappyCodec')
GO
CREATE EXTERNAL TABLE [dbo].[DimDate]
(
[DateSKey] int not null,
[Date] date not null,
[Year] int not null,
[Month] int not null,
[Day] int not null,
[WeekOfYear] int not null,
[MonthNameShort] varchar(50) not null,
[MonthName] varchar(50) not null,
[DayNameShort] varchar(50) not null,
[DayName] varchar(50) not null
)
WITH (DATA_SOURCE = [DS_ADLS],LOCATION = N'/PRESENTED/dimDate',FILE_FORMAT = [ParquetFileFormatSnappy],REJECT_TYPE = VALUE,REJECT_VALUE = 0)
create external table执行失败,返回如下错误:
Error occurred while accessing HDFS: Java exception raised on call to
HdfsBridge_IsDirExist. Java exception message: HdfsBridge::isDirExist
- Unexpected error encountered checking whether directoy exists or not: AbfsRestOperationException: HEAD
https://xxxx.dfs.core.windows.net/xxxx?resource=filesystem&timeout=90
StatusCode=403 StatusDescription=Server failed to authenticate the
request. Make sure the value of Authorization header is formed
correctly including the signature. ErrorCode= ErrorMessage=
该目录确实存在并且我的服务主体具有访问权限。我已通过使用来自 Databricks 的相同服务主体并无误地读取文件来确认这一点。
我不知道自己做错了什么。
问题是 abfs/abfss 当前不支持用户提供的 oauth 凭据。
支持的认证方式有:
- 存储帐户密钥
- 基于 MSI 的身份验证
顺便说一句 - Oauth2.0 is supported now on Gen2。
如果您已验证路径和权限是正确的,即通过 Azure Databricks,我会怀疑它的网络相关。尝试使用具有无限制网络设置的存储帐户来确认。
由于启用了存储固件,您可能会收到此错误 - 查看 docs here,您可以看到星号表示使用各种权限类型的固件限制。
copy-into可以参考这个authorisation table.
通常您可以在存储网络中“允许受信任的 Microsoft 服务”,但这仅在使用 MSI 时有效 - 在您的情况下,您使用的是 SPN。
如果您仍想使用服务主体或用户身份(而不是 MSI)查询您的数据湖,您可以尝试遵循 steps here via powershell 这将允许 Synapse 专用池(以前称为 SQLDW)通过存储 FW,然后切换到 SPN 或 UPN 以针对 POSIX 个 ACL 进行授权。
最后,这是一篇讨论 different options 的好博客 post。
我正在尝试通过 Polybase 从 Azure SQLDW 连接到 Data Lake Gen 2 中的 Parquet 文件。这是我的代码:
CREATE DATABASE SCOPED CREDENTIAL DSC_ServicePrincipal
WITH IDENTITY = '1234567890@https://login.microsoftonline.com/1234567890/oauth2/token',
SECRET = '1234567890'
GO
CREATE EXTERNAL DATA SOURCE [DS_ADLS] WITH (TYPE = HADOOP,
LOCATION = N'abfss://filesystem@storageacc.dfs.core.windows.net',
CREDENTIAL = DSC_ServicePrincipal)
GO
CREATE EXTERNAL FILE FORMAT [ParquetFileFormatSnappy]
WITH (FORMAT_TYPE = PARQUET, DATA_COMPRESSION = N'org.apache.hadoop.io.compress.SnappyCodec')
GO
CREATE EXTERNAL TABLE [dbo].[DimDate]
(
[DateSKey] int not null,
[Date] date not null,
[Year] int not null,
[Month] int not null,
[Day] int not null,
[WeekOfYear] int not null,
[MonthNameShort] varchar(50) not null,
[MonthName] varchar(50) not null,
[DayNameShort] varchar(50) not null,
[DayName] varchar(50) not null
)
WITH (DATA_SOURCE = [DS_ADLS],LOCATION = N'/PRESENTED/dimDate',FILE_FORMAT = [ParquetFileFormatSnappy],REJECT_TYPE = VALUE,REJECT_VALUE = 0)
create external table执行失败,返回如下错误:
Error occurred while accessing HDFS: Java exception raised on call to HdfsBridge_IsDirExist. Java exception message: HdfsBridge::isDirExist - Unexpected error encountered checking whether directoy exists or not: AbfsRestOperationException: HEAD https://xxxx.dfs.core.windows.net/xxxx?resource=filesystem&timeout=90 StatusCode=403 StatusDescription=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. ErrorCode= ErrorMessage=
该目录确实存在并且我的服务主体具有访问权限。我已通过使用来自 Databricks 的相同服务主体并无误地读取文件来确认这一点。
我不知道自己做错了什么。
问题是 abfs/abfss 当前不支持用户提供的 oauth 凭据。
支持的认证方式有:
- 存储帐户密钥
- 基于 MSI 的身份验证
顺便说一句 - Oauth2.0 is supported now on Gen2。 如果您已验证路径和权限是正确的,即通过 Azure Databricks,我会怀疑它的网络相关。尝试使用具有无限制网络设置的存储帐户来确认。
由于启用了存储固件,您可能会收到此错误 - 查看 docs here,您可以看到星号表示使用各种权限类型的固件限制。 copy-into可以参考这个authorisation table.
通常您可以在存储网络中“允许受信任的 Microsoft 服务”,但这仅在使用 MSI 时有效 - 在您的情况下,您使用的是 SPN。
如果您仍想使用服务主体或用户身份(而不是 MSI)查询您的数据湖,您可以尝试遵循 steps here via powershell 这将允许 Synapse 专用池(以前称为 SQLDW)通过存储 FW,然后切换到 SPN 或 UPN 以针对 POSIX 个 ACL 进行授权。
最后,这是一篇讨论 different options 的好博客 post。