首页
/ Azure CLI 中关于计算库镜像发布的重大变更解析

Azure CLI 中关于计算库镜像发布的重大变更解析

2025-06-15 10:09:06作者:尤峻淳Whitney

背景概述

近期微软Azure平台针对计算库(Compute Gallery)镜像发布功能进行了重要更新,这一变更将直接影响使用Azure CLI创建镜像版本的操作方式。作为Azure CLI的核心功能之一,这一变更需要开发者特别关注。

变更核心内容

本次变更主要涉及镜像版本创建过程中存储账户属性的使用方式。具体表现为:

  1. 旧版属性properties.storageProfile.[osDiskImage/dataDiskImages].source.Id将被弃用
  2. 新版要求使用properties.storageProfile.osDiskImage.source.storageAccountId属性
  3. 该变更要求API版本最低为2022-03-03

技术影响分析

在Azure CLI 2.70.0版本中,创建计算库镜像版本时仍在使用旧版属性。当执行如下命令时:

az sig image-version create --resource-group mygroup --location westeurope --gallery-image-version 1.0.0 --gallery-image-definition myimage --gallery-name mygallery --os-vhd-storage-account /subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Storage/storageAccounts/mystorage --os-vhd-uri https://mystorage.blob.core.windows.net/vhd/image

生成的请求体中仍会使用旧版属性格式:

{
  "location": "westeurope",
  "properties": {
    "publishingProfile": {
      "targetRegions": [{"name": "westeurope"}]
    },
    "storageProfile": {
      "osDiskImage": {
        "source": {
          "id": "/subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Storage/storageAccounts/mystorage",
          "uri": "https://mystorage.blob.core.windows.net/vhd/image"
        }
      }
    }
  }
}

解决方案

微软Azure CLI团队已经着手进行相应调整,主要变更包括:

  1. --os-vhd-storage-account参数映射到新版storageAccountId属性
  2. 对数据磁盘镜像同样应用此变更,将properties.storageProfile.dataDiskImages[].source.Id更新为properties.storageProfile.dataDiskImages[].source.storageAccountId

用户应对建议

  1. 及时升级Azure CLI到最新版本
  2. 检查现有自动化脚本和工作流中是否使用了相关命令
  3. 在API调用中确保使用2022-03-03或更高版本
  4. 对于使用Terraform等基础设施即代码工具的用户,需要关注相应provider的更新

技术深度解析

这一变更反映了Azure平台对资源标识管理的规范化改进。新版storageAccountId属性提供了更明确的语义,与Azure资源管理器的标准实践保持一致。从技术实现角度看,这种变更:

  1. 提高了API的一致性和可预测性
  2. 便于资源访问控制和权限管理
  3. 为未来功能扩展提供了更好的基础

总结

作为Azure CLI用户,理解并适应这一变更对于确保业务连续性至关重要。建议开发者密切关注官方更新公告,及时调整相关自动化流程和基础设施代码,以避免潜在的服务中断风险。

登录后查看全文
热门项目推荐
相关项目推荐

项目优选

收起