导出一份自定义镜像到与自定义镜像同一地域的OSS Bucket里。

接口说明

导出镜像前:

  • 您需要先了解前提条件以及注意事项。更多信息,请参见导出镜像
  • 您必须通过RAM授权云服务器ECS写入OSS的权限。具体操作说明如下:

    1. 创建角色:AliyunECSImageExportDefaultRole(其他任何角色名称无效),为该角色设置以下角色策略:
    
             {
               "Statement": [
                 {
                   "Action": "sts:AssumeRole",
                   "Effect": "Allow",
                   "Principal": {
                     "Service": [
                       "ecs.aliyuncs.com"
                     ]
                   }
                 }
               ],
               "Version": "1"
             }
         
    2. 在角色AliyunECSImageExportDefaultRole下加入默认的系统权限策略:AliyunECSImageExportRolePolicy,该策略是云服务器ECS提供导出镜像的默认策略。更多详情,请参见云资源访问授权。您也可以创建自定义策略,权限需要包含:
    
             {
               "Version": "1",
               "Statement": [
                 {
                   "Action": [
                     "oss:GetObject",
                     "oss:PutObject",
                     "oss:DeleteObject",
                     "oss:GetBucketLocation",
                     "oss:GetBucketInfo",
                     "oss:AbortMultipartUpload",
                     "oss:ListMultipartUploads",
                     "oss:ListParts"
                   ],
                   "Resource": "*",
                   "Effect": "Allow"
                 }
               ]
             }
          

导出镜像后:

自定义镜像将保存在指定的OSS bucket中,您可以下载自定义镜像。具体操作,请参见下载自定义镜像文件

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String ExportImage

系统规定参数。取值:ExportImage

RegionId String cn-hangzhou

自定义镜像的地域ID。您可以调用DescribeRegions查看最新的阿里云地域列表。

ImageId String m-bp67acfmxazb4p****

自定义镜像ID。

OSSBucket String testexportImage

保存导出镜像的OSS bucket。

OSSPrefix String EcsExport

您的OSS Object的前缀。可以由数字或者字母组成,字符长度为1~30。

ImageFormat String raw

镜像文件的导出格式。取值范围:

  • raw。
  • vhd。
  • qcow2。
  • vmdk。
  • vdi。

默认值:raw。

RoleName String AliyunECSImageExportDefaultRole

导出镜像时使用的RAM角色名称。

返回数据

名称 类型 示例值 描述
RequestId String C8B26B44-0189-443E-9816-D951F596****

请求ID。

TaskId String tsk-bp67acfmxazb4p****

导出镜像任务ID。

RegionId String cn-hangzhou

地域ID。

示例

请求示例

https://ecs.aliyuncs.com/?Action=ExportImage
&ImageId=m-bp67acfmxazb4p****
&OSSBucket=testexportImage
&RegionId=cn-hangzhou
&OSSPrefix=EcsExport
&ImageFormat=raw
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<ExportImageResponse>
    <RequestId>C8B26B44-0189-443E-9816-D951F596****</RequestId>
    <ExportTaskId>tsk-bp67acfmxazb4p****</ExportTaskId>
    <RegionId>cn-hangzhou</RegionId>
</ExportImageResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "C8B26B44-0189-443E-9816-D951F596****",
  "ExportTaskId" : "tsk-bp67acfmxazb4p****",
  "RegionId" : "cn-hangzhou"
}

错误码

HttpCode 错误码 错误信息 描述
400 InvalidImageName.Malformed The specified Image name is wrongly formed. 镜像名称格式错误。长度为2~128个字符。必须以大小字母或中文开头,不能以aliyun和acs:开头,不能包含http://或者https://。可以包含数字、半角句号(.)、半角冒号(:)、下划线(_)或者短划线(-)。
400 InvalidOSSPrefix.Malformed The specified OSSPrefix format is wrongly formed. 参数 OssPrefix 格式错误。
400 InvalidRegionId.NotFound The specified RegionId does not exist. 指定的地域 ID 不存在。
400 InvalidRegion.NotSupport The specified region does not support image import or export. 指定的地域暂时不支持此操作。
400 IncorrectImageStatus The specified Image is not available. 指定的源镜像状态不正确。
400 InvalidImageFormat.Malformed The specified Image Format is wrongly formed. 指定的镜像格式错误。
400 InvalidOSSBucket.NotFound The specified OSS bucket does not exist in this region. 指定的 bucket 不存在。
400 OperationDenied The specified image contains the snapshot of the data disk,does not support this operation. 包含了数据盘快照的镜像,不支持此操作。
400 InvalidImage.DiskAmountOrSize %s 无效的镜像,导出的镜像限制数据盘数不能超过 4 块,单块数据盘容量最大不能超过 500 GiB。
400 ImageNotSupported The specified Image contains encrypted snapshots, do not support export. 指定的镜像包含了加密快照,不支持导出。
400 InvalidOSSBucket.NotMatched The specified OSS bucket is incorrect, %s. 指定的 OSS Bucket 有误,具体信息请参见错误信息的实际返回结果。
403 ImageNotSupported The specified image from the image market, do not support export image. 指定的镜像来自云市场镜像,此镜像不能导出。
403 ImageIsExporting The specified Image is exporting. 指定的镜像正在导出。
403 ExportImageFailed Exporting image is failed, Please contact the administrator. 导出镜像失败,请联系系统管理员。
403 UserNotInTheWhiteList The user is not in the white list of exporting image. 该用户不在导出镜像白名单中。
403 NoSetRoletoECSServiceAcount ECS service account Have no right to access your OSS.please attach a role of access your oss to ECS service account. ECS 官网服务账号没有权限访问您指定的 OSS 的 bucket 和 Object。
403 ConcurrentQuotaExceed.ExportImage %s 当前处理中的任务,已达到并发最大额度,请耐心等待一段时间再创建任务。
403 WeeklyQuotaExceed.ExportImage %s 本周提交任务已经超出配额,请耐心等候再次分配可用额度。
403 InvalidImageLicense.NotSupported %s 指定的镜像不支持导出。具体信息请参见错误信息%s占位符的实际返回值。
403 InvalidOSSBucket.EncryptUnsupported Accessing objects from encrypted OSS bucket is not supported. 不支持从加密的OSS bucket读取对象。
404 InvalidImageId.NotFound The specified ImageId does not exist. 指定的镜像在该用户账号下不存在,请您检查镜像 ID 是否正确。

访问错误中心查看更多错误码。