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

使用azurerm_mssql_virtual_machine部署SQL VM遇CRPNotAllowedOperation错误

问题:使用自定义镜像创建Azure SQL Server虚拟机时触发SqlIaaSAgent扩展自动升级错误

使用azurerm_mssql_virtual_machine资源,基于预配置SQL Server 2016的自定义镜像构建SQL Server虚拟机,执行以下Terraform代码时出现错误:

resource "azurerm_mssql_virtual_machine" "mssql_vm" {
  provider            = azurerm.spoke-subscription
  virtual_machine_id  = azurerm_windows_virtual_machine.sql_server.id
  sql_license_type                 = "PAYG"
  sql_connectivity_port            = "49535"
  sql_connectivity_update_username = var.sql_login
  sql_connectivity_update_password = var.sql_password
  sql_instance {
    collation = "Latin1_General_CI_AS"
  }
  assessment {
    enabled = true
    run_immediately = true
  }
  storage_configuration {
    disk_type             = "${var.disk_type}"
    storage_workload_type = "OLTP"
    data_settings {
      default_file_path = "F:\\DATA"
      luns              = [1]
    }
    log_settings {
      default_file_path = "G:\\LOGS"
      luns              = [2]                 
    }
    temp_db_settings {
      default_file_path = "K:\\TEMPDB"
      luns              = [3]                
    }
  }
  lifecycle {
    ignore_changes = [
      tags,
      #assessment[0].schedule
    ]
  }
  tags = {
    "application owner" = var.application_owner_tag
    "environment"       = var.environment_tag
    "department"        = var.department_tag
    "technicalcontact"  = var.technicalcontact_tag
    "application"       = var.application_tag
    "service"           = "SQL server"
  }
}

错误信息

performing CreateOrUpdate: sqlvirtualmachines.SqlVirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 --

Original Error: Code="CRPNotAllowedOperation" Message="Operation cannot be completed due to the following error: VM Extension with publisher 'Microsoft.SqlServer.Management' and type 'SqlIaaSAgent' does not support setting enableAutomaticUpgrade property to true on this subscription.

已尝试的步骤

  • 将SQL Server虚拟机重新注册到Azure订阅
  • 关闭azurerm_windows_virtual_machine的自动升级

解决方案

1. 显式禁用SqlIaaSAgent扩展的自动升级

在azurerm_mssql_virtual_machine资源中添加sql_iaas_agent块,强制关闭扩展自动升级功能,这是触发错误的核心原因:

resource "azurerm_mssql_virtual_machine" "mssql_vm" {
  # ... 原有代码 ...

  sql_iaas_agent {
    enable_automatic_upgrade = false
  }

  # ... 原有代码 ...
}

2. 检查自定义镜像中的SqlIaaSAgent状态

如果自定义镜像已预装SqlIaaSAgent扩展,确认镜像内该扩展的enableAutomaticUpgrade属性为false,避免Terraform执行时尝试修改该属性。

3. 重新注册Microsoft.SqlServer资源提供者

执行Azure CLI命令重新注册SQL Server资源提供者,确保订阅与资源提供者的交互状态正常:

az provider register --namespace Microsoft.SqlServer

等待注册完成后,重新执行Terraform部署。

内容的提问来源于stack exchange,提问作者Callum Hester

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 08:40:48