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

Azure ML Studio Python API创建的数据资产权限拒绝问题求助

解决方案:AutoML访问Python API创建的MLTable数据资产权限错误

问题背景

通过Python Azure API创建了路径模式为wasbs://<container-name>@<account name>.blob.core.windows.net/<folder>/*.csv的MLTable数据资产,存储账户和容器与Azure ML工作区一致。数据资产在UI中可正常查看,但使用自建计算实例启动Automated ML任务时触发权限拒绝错误,而通过UI创建的相同数据资产可正常运行AutoML任务。

创建代码如下:

tbl = mltable.from_delimited_files(
    paths=[{"pattern": body}],
    delimiter=",",
    header=MLTableHeaders.all_files_same_headers,
    infer_column_types=True,
    include_path_column=False,
    encoding=MLTableFileEncoding.utf8,
)

my_data = Data(
    path=mltable_folder,    
    type=AssetTypes.MLTABLE,
    name="Measurements",
)

my_data = ml_client.data.create_or_update(my_data)

错误信息:

Error Message: Authentication failed when trying to access the stream. Make sure you have correct permissions set up. Ok(This request is not authorized to perform this operation using this permission.)| session_id=0e120470-1498-4fc9-8201-19783974e5df
ErrorResponse
{
"error": {
"code": "UserError",
"message": "The provided path to the data in the Datastore was inaccessible. Please make sure you have the necessary access rights on the resource. Error:
Error Code: ScriptExecution.StreamAccess.Authentication
Native Error: Dataflow visit error: ExecutionError(StreamError(PermissionDenied(Some(This request is not authorized to perform this operation using this permission.))))
VisitError(ExecutionError(StreamError(PermissionDenied(Some(This request is not authorized to perform this operation using this permission.)))))
=> Failed with execution error: error in streaming from input data sources
ExecutionError(StreamError(PermissionDenied(Some(This request is not authorized to perform this operation using this permission.))))
Error Message: Authentication failed when trying to access the stream. Make sure you have correct permissions set up. Ok(This request is not authorized to perform this operation using this permission.)| session_id=0e120470-1498-4fc9-8201-19783974e5df",
"inner_error": {
"code": "Auth",
"inner_error": {
"code": "Authentication",
"inner_error": {
"code": "DataPathInaccessible"
}
}
}
}
}

解决步骤

1. 修正MLTable的路径与身份验证配置

Python API创建的MLTable若直接使用wasbs://路径,会绕过工作区的默认数据存储身份验证机制,导致AutoML任务无法获取合法权限。

  • 打开生成的MLTable文件,将绝对Blob路径改为工作区数据存储的相对路径:
paths:
- file: ./<folder>/*.csv
transformations:
- read_delimited:
    delimiter: ','
    header: all_files_same_headers
    infer_column_types: true
    encoding: utf8
  • 修改数据资产创建代码,直接关联工作区默认数据存储:
from azure.ai.ml.entities import Data, MLTable

# 获取工作区默认Blob存储数据存储
datastore = ml_client.datastores.get("workspaceblobstore")
# 用数据存储引用构造路径
my_data = Data(
    path=f"{datastore.name}:/<folder>/*.csv",
    type=AssetTypes.MLTABLE,
    name="Measurements",
)
my_data = ml_client.data.create_or_update(my_data)

2. 配置计算实例的托管身份权限

自建计算实例需要具备存储账户的访问权限:

  • 进入Azure Portal,找到目标计算实例,在身份选项卡启用系统分配的托管身份。
  • 导航到对应存储账户的访问控制(IAM),为计算实例的系统托管身份添加存储Blob数据读取者角色。

3. 检查数据资产的访问权限

确保数据资产允许计算实例访问:

  • 在Azure ML工作区UI中找到目标数据资产,进入访问控制,添加计算实例的托管身份为数据读取者角色。

4. 直接将MLTable保存到数据存储

避免本地MLTable文件的路径解析问题,直接将MLTable对象保存到工作区数据存储:

# 将MLTable保存到数据存储指定路径
tbl.save(f"{datastore.name}:/mltables/Measurements")
# 基于数据存储中的MLTable创建数据资产
my_data = Data(
    path=f"{datastore.name}:/mltables/Measurements",
    type=AssetTypes.MLTABLE,
    name="Measurements",
)
my_data = ml_client.data.create_or_update(my_data)

5. 验证存储账户的网络设置

确认存储账户的防火墙没有阻止计算实例访问:

  • 进入存储账户的网络选项卡,勾选允许Azure服务访问此存储账户,或把计算实例所在虚拟网络添加到允许列表。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 18:55:06