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

如何在Terraform中使用Azure Marketplace中的虚拟机镜像

在Terraform中使用Azure Marketplace镜像创建Linux虚拟机

一、SQL Server 2019 on Ubuntu Server 20.04 LTS的具体配置

针对你需要的SQL Server 2019 on Ubuntu Server 20.04 LTS镜像,对应的source_image_reference块配置如下:

source_image_reference {
  publisher = "MicrosoftSQLServer"
  offer     = "sql2019-linux"
  sku       = "ubuntu-2004"
  version   = "latest"
}

二、通用查找方法(获取Marketplace镜像的publisher/offer/sku信息)

要将任意Azure Marketplace镜像用于Terraform配置,需先获取该镜像的publisher、offer、sku参数,可通过Azure CLI执行以下步骤:

  • 列出目标区域内的镜像发布者:
    az vm image list-publishers --location <你的Azure区域,比如eastus> --output table
    
  • 找到目标发布者后,列出其提供的镜像产品(offer):
    az vm image list-offers --location <区域> --publisher <发布者名称> --output table
    
  • 找到对应offer后,列出该产品下的SKU:
    az vm image list-skus --location <区域> --publisher <发布者> --offer <产品名称> --output table
    
  • (可选)查看该SKU的可用版本,或直接用latest自动拉取最新版本:
    az vm image list --location <区域> --publisher <发布者> --offer <产品> --sku <SKU> --output table
    

执行命令时,替换<区域>、<发布者名称>等占位符为实际值即可获取对应镜像的完整参数,填入Terraform的source_image_reference块即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 01:20:39