Power BI服务中M查询服务主体认证ADLS失败问题排查
Power BI Service中自定义M Query连接ADLS Gen2(分层命名空间)的问题
我尝试通过M Query对启用分层命名空间的Azure Data Lake(非Blob存储)进行认证,因官方连接器无法实现凭证参数化,自行编写了查询逻辑。本地环境下,数据加载、报表显示及刷新均正常,但上传至Power BI Service后出现以下问题:
Power BI Service报错情况
- 上传后无法连接,报错:
400): Value for one of the query parameters specified in the request URI is invalid. - 刷新时触发错误:
[Unable to combine data] Section1/DataSource/source references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.. The exception was raised by the IDbCommand interface.
当前实现代码
获取AccessToken的函数查询
let GetAccessToken = () => let tenantId = TenantID, tokenEndpoint = "https://login.microsoftonline.com/", // 创建Token请求体 tokenBody = [ client_id = ServicePrincipleClientID, client_secret = ServicePrincipleClientSecret, scope = "https://storage.azure.com/.default", grant_type = "client_credentials" ], tokenRequest = Web.Contents(tokenEndpoint, [ Content = Text.ToBinary(Uri.BuildQueryString(tokenBody)), Headers = [#"Content-Type" = "application/x-www-form-urlencoded"], //Timeout=#duration(0, 0, 0, 2), RelativePath = TenantID & "/oauth2/v2.0/token" ]), source = tokenRequest, tokenSource = Json.Document(tokenRequest), result = tokenSource[access_token] in result in GetAccessToken
数据查询
let accessToken = GetAccessToken, UtcTimeZone = DateTimeZone.UtcNow(), UtcTime = DateTimeZone.RemoveZone(UtcTimeZone), UtcTimeText = DateTime.ToText(UtcTime, [Format="r"]), headers = [ #"x-ms-version" = "2023-08-03", #"x-ms-date" = UtcTimeText, #"Authorization" = "Bearer " & accessToken ], response = Web.Contents (DataLakeURL, [ Headers = headers, RelativePath = ConsumableStorage&ConsumableFileName ]), source = Text.FromBinary(response) in source
已排查内容
- 两个查询均已设置隐私级别
- 已使用
RelativePath参数而非直接拼接URL,符合Power BI Service的网关要求 - 验证过服务主体具备ADLS的必要访问权限
- Postman及本地M Query均可正常访问目标文件
请求解决思路
希望得到针对Power BI Service中上述报错的排查方向和可行的解决方法。
内容的提问来源于stack exchange,提问作者Thomas Gebetsberger
相关产品推荐
相关产品推荐

