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

AzureMachineLearningFileSystem将Parquet存至指定Blob容器问题求助

解决Azure ML FileSystem保存Parquet到指定Blob容器的问题

问题概述

使用AzureMachineLearningFileSystem时遇到以下问题:

  • 采用完整azureml://路径执行to_parquet时触发NotFoundException
  • 使用相对路径或其他方法保存,文件会存入文件共享而非目标Blob容器

尝试的报错代码:

F_AUDIT.to_parquet("azureml://subscriptions/xyz/resourcegroups/xyzz/workspaces/xyz/datastores/xyz/paths/2_FILES_PIPE/SPACE_DEF/text.parquet", 
                   engine = 'pyarrow', 
                   compression = 'gzip') 

错误信息:

Message: rslex failed, falling back to clex.
Error Message: ScriptExecutionException was caused by StreamAccessException.
StreamAccessException was caused by NotFoundException.
Found no resources for the input provided

可行解决方案

1. 确认目标数据存储的类型与权限

  • 验证xyz数据存储为Blob容器类型:在AML工作室「数据存储」页面查看,若为文件共享类型,需切换到关联Blob容器的数据存储。
  • 确保数据存储的认证主体(如服务Principal)拥有Blob容器的写入权限(分配Storage Blob Data Contributor角色)。

2. 显式使用Azure ML FileSystem API写入

直接用pandas的to_parquet配合azureml://路径可能存在解析问题,建议显式初始化文件系统操作:

from azureml.fsspec import AzureMachineLearningFileSystem

# 初始化指向目标数据存储的文件系统
fs = AzureMachineLearningFileSystem("azureml://subscriptions/xyz/resourcegroups/xyzz/workspaces/xyz/datastores/xyz/")

# 先创建目标目录(若不存在)
fs.mkdirs("2_FILES_PIPE/SPACE_DEF", exist_ok=True)

# 写入Parquet文件
with fs.open("2_FILES_PIPE/SPACE_DEF/text.parquet", 'wb') as f:
    F_AUDIT.to_parquet(f, engine='pyarrow', compression='gzip')

3. 检查路径格式正确性

  • azureml://路径中paths/后的部分是Blob容器内的相对路径,无需包含容器名称(数据存储已关联容器)。
  • 若路径含空格,需用URL编码(空格替换为%20)或用引号完整包裹路径。

4. 通过挂载数据存储写入(适合计算实例/集群)

将目标Blob数据存储挂载到本地路径,直接写入挂载目录:

from azureml.core import Workspace, Datastore

# 加载工作区配置
ws = Workspace.from_config()
# 获取目标Blob数据存储
target_datastore = Datastore.get(ws, datastore_name='xyz')

# 挂载数据存储到本地目录
mount_context = target_datastore.mount('/mnt/target_blob')
mount_context.start()

# 写入挂载后的本地路径
F_AUDIT.to_parquet('/mnt/target_blob/2_FILES_PIPE/SPACE_DEF/text.parquet', engine='pyarrow', compression='gzip')

# 结束挂载
mount_context.stop()

5. 排查NotFoundException的关键要点

  • 核对订阅ID、资源组、工作区、数据存储名称的拼写,确保完全匹配。
  • 确认目标目录2_FILES_PIPE/SPACE_DEF已存在,若不存在需先通过fs.mkdirs创建。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 22:02:06