求助:无法删除Azure Compute Gallery中黄金VM的旧镜像
解决Azure Compute Gallery旧镜像版本无法删除的问题
问题核心
删除专用镜像版本时遇到API版本不支持、资源提供者未找到的错误,且误将资源提供者名称混淆为AzureComputeGallery(实际应为Microsoft.Compute)。
分步解决方案
1. 注册正确的资源提供者
Azure Compute Gallery归属于Microsoft.Compute资源提供者,而非AzureComputeGallery:
- 登录Azure门户,进入目标订阅
- 左侧导航选择资源提供者,搜索
Microsoft.Compute - 若状态为「未注册」,点击顶部「注册」按钮,等待注册完成(通常需1-5分钟)
2. 使用支持的API版本执行删除
错误提示明确列出了支持的API版本(如2021-10-01、2022-08-03等),避免使用2021-11-01这类未被支持的版本:
- Azure CLI示例:
az sig image-version delete \ --resource-group <你的资源组名> \ --gallery-name <你的画廊名称> \ --gallery-image-definition <镜像定义名> \ --gallery-image-version <要删除的版本号> \ --api-version 2022-08-03 \ --location <支持的位置,如eastus> - PowerShell示例:
Remove-AzGalleryImageVersion ` -ResourceGroupName <你的资源组名> ` -GalleryName <你的画廊名称> ` -GalleryImageDefinitionName <镜像定义名> ` -Name <要删除的版本号> ` -ApiVersion 2022-08-03 ` -Location <支持的位置,如eastus>
3. 确保位置参数正确
错误信息中位置字段为空,需指定错误提示里列出的支持位置(如westcentralus、eastus等),避免位置参数缺失或无效。
4. 检查镜像版本的引用关系
若该镜像版本仍被VMSS实例或其他虚拟机使用,会导致删除失败:
- 进入Azure Compute Gallery的镜像版本详情页,查看「依赖项」部分
- 解除所有资源对该镜像版本的引用后,再执行删除操作
内容的提问来源于stack exchange,提问作者Raghava Akula
相关产品推荐
相关产品推荐

