调用Azure Machine Learning REST API创建Data container报错及Dataset创建咨询
AML REST API创建Dataset问题解决方案
报错原因
- 你使用的
2021-03-01-preview版本API为早期预览版本,DataContainers_CreateOrUpdate端点未正式开放,同时存在字段校验逻辑缺陷,因此先后触发参数赋值错误、接口不支持的报错。
完整实现步骤
- 替换API版本为正式可用的
2022-10-01,该版本的数据集相关接口能力已完全对齐UI操作 - 先调用接口创建Data container,正确请求示例:
curl --location --request PUT 'https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.MachineLearningServices/workspaces/{{workspaceName}}/data/abc?api-version=2022-10-01' \ --header 'Authorization: Bearer {{实际Bearer令牌}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "properties": { "description": "自定义数据集描述", "tags": {}, "dataType": "uri_file" } }'
- 将本地文件上传到AML工作空间关联的任意datastore对应的存储路径中,可直接使用Azure存储服务的REST接口完成上传,无需UI操作
- 调用Data version创建接口,关联存储路径完成Dataset创建:
curl --location --request PUT 'https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.MachineLearningServices/workspaces/{{workspaceName}}/data/abc/versions/1?api-version=2022-10-01' \ --header 'Authorization: Bearer {{实际Bearer令牌}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "properties": { "dataUri": "azureml://datastores/{{目标datastore名称}}/paths/{{文件上传后的存储路径}}", "dataType": "uri_file" } }'
补充说明:如果需要创建包含多个文件的数据集,只需将
dataType参数值改为uri_folder,dataUri对应填写存储的文件夹路径即可。
内容的提问来源于stack exchange,提问作者Pribina
相关产品推荐
相关产品推荐

