你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

Microsoft。计算盘 2026-03-02

Bicep 资源定义

可以使用目标操作部署磁盘资源类型:

有关每个 API 版本中已更改属性的列表,请参阅更改日志。

用法示例

Bicep示例

部署托管磁盘的基本示例。

param location string = 'westeurope'
param resourceName string = 'acctest0001'

resource disk 'Microsoft.Compute/disks@2022-03-02' = {
  name: resourceName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  properties: {
    creationData: {
      createOption: 'Empty'
    }
    diskSizeGB: 10
    encryption: {
      type: 'EncryptionAtRestWithPlatformKey'
    }
    networkAccessPolicy: 'AllowAll'
    osType: ''
    publicNetworkAccess: 'Enabled'
  }
}

Azure 验证模块

以下 Azure 验证模块 可用于部署此资源类型。

模块 Description
计算磁盘 计算磁盘的 AVM 资源模块

Azure 快速入门示例

以下 Azure 快速入门模板 包含用于部署此资源类型的 Bicep 示例。

Bicep 文件 Description
创建磁盘 &通过备份保险库启用保护 用于创建磁盘并通过备份保管库启用保护的模板
安装了 Portainer 和 Traefik 的 Windows Docker 主机 预安装了 Portainer 和 Traefik 的 Windows Docker 主机
使用 SSH Windows Server VM 部署启用了开放 SSH 的单个 Windows VM,以便可以使用基于密钥的身份验证通过 SSH 进行连接。

资源格式

若要创建 Microsoft.Compute/disks 资源,请将以下 Bicep 添加到模板。

resource symbolicname 'Microsoft.Compute/disks@2026-03-02' = {
  extendedLocation: {
    name: 'string'
    type: 'string'
  }
  location: 'string'
  name: 'string'
  properties: {
    availabilityPolicy: {
      actionOnDiskDelay: 'string'
    }
    burstingEnabled: bool
    completionPercent: int
    creationData: {
      createOption: 'string'
      elasticSanResourceId: 'string'
      galleryImageReference: {
        communityGalleryImageId: 'string'
        id: 'string'
        lun: int
        sharedGalleryImageId: 'string'
      }
      imageReference: {
        communityGalleryImageId: 'string'
        id: 'string'
        lun: int
        sharedGalleryImageId: 'string'
      }
      instantAccessDurationMinutes: int
      logicalSectorSize: int
      performancePlus: bool
      provisionedBandwidthCopySpeed: 'string'
      securityDataUri: 'string'
      securityMetadataUri: 'string'
      sourceResourceId: 'string'
      sourceUri: 'string'
      storageAccountId: 'string'
      uploadSizeBytes: int
    }
    dataAccessAuthMode: 'string'
    diskAccessId: 'string'
    diskIOPSReadOnly: int
    diskIOPSReadWrite: int
    diskMBpsReadOnly: int
    diskMBpsReadWrite: int
    diskSizeGB: int
    encryption: {
      diskEncryptionSetId: 'string'
      type: 'string'
    }
    encryptionSettingsCollection: {
      enabled: bool
      encryptionSettings: [
        {
          diskEncryptionKey: {
            secretUrl: 'string'
            sourceVault: {
              id: 'string'
            }
          }
          keyEncryptionKey: {
            keyUrl: 'string'
            sourceVault: {
              id: 'string'
            }
          }
        }
      ]
      encryptionSettingsVersion: 'string'
    }
    hyperVGeneration: 'string'
    maxShares: int
    networkAccessPolicy: 'string'
    optimizedForFrequentAttach: bool
    osType: 'string'
    publicNetworkAccess: 'string'
    purchasePlan: {
      name: 'string'
      product: 'string'
      promotionCode: 'string'
      publisher: 'string'
    }
    securityProfile: {
      secureVMDiskEncryptionSetId: 'string'
      securityType: 'string'
    }
    supportedCapabilities: {
      acceleratedNetwork: bool
      architecture: 'string'
      diskControllerTypes: 'string'
      supportedSecurityOption: 'string'
    }
    supportsHibernation: bool
    tier: 'string'
  }
  sku: {
    name: 'string'
  }
  tags: {
    {customized property}: 'string'
  }
  zones: [
    'string'
  ]
}

属性值

Microsoft.Compute/disks

Name Description Value
extendedLocation 将创建磁盘的扩展位置。 无法更改扩展位置。 ExtendedLocation
位置 资源所在的地理位置 字符串(必需)
名字 资源名称 字符串(必需)
性能 磁盘资源属性。 DiskProperties
sku 磁盘 SKU 名称。 可以是Standard_LRS、Premium_LRS、StandardSSD_LRS、UltraSSD_LRS、Premium_ZRS、StandardSSD_ZRS或PremiumV2_LRS。 DiskSku
tags 资源标记 标记名称和值的字典。 请参阅模板中的标记
区域 磁盘的逻辑区域列表。 string[]

可用性策略

Name Description Value
actionOnDiskDelay 确定如何处理 I/O 速度较慢的磁盘。 'AutomaticReattach'
“None”

CreationData

Name Description Value
createOption 这会枚举磁盘创建可能的源。 “Attach”
'Copy'
“CopyFromSanSnapshot”
“CopyStart”
“Empty”
“FromImage”
'Import'
“ImportSecure”
“还原”
'Upload'
“UploadPreparedSecure”(必需)
elasticSanResourceId 如果 createOption 为 CopyFromSanSnapshot,则是必需的。 这是源弹性 san 卷快照的 ARM ID。 字符串
galleryImageReference (图片参考) 从库映像创建时是必需的。 ImageDiskReference 的 id/sharedGalleryImageId/communityGalleryImageId 将是要从中创建磁盘的共享 galley 映像版本的 ARM ID。 ImageDiskReference (图像磁盘引用)
imageReference PIR 或用户映像的磁盘源信息。 ImageDiskReference (图像磁盘引用)
instantAccessDurationMinutes 对于从高级 SSD v2 或超级磁盘创建的快照,此属性确定保留快照以供即时访问以实现更快还原的时间(以分钟为单位)。 int

约束:
最小值 = 1
logicalSectorSize (逻辑扇区大小) 超级磁盘的逻辑扇区大小(以字节为单位)。 支持的值为 512 ad 4096。 4096 是默认值。 int
performancePlus 性能 将此标志设置为 true 以提升部署的磁盘的性能目标,请参阅此处的相应性能目标。 此标志只能在磁盘创建时设置,在启用后不能禁用。 bool
预置带宽复制速度 如果在快照上设置了此字段,并且 createOption 为 CopyStart,则会以更快的速度复制快照。 “增强”
“None”
securityDataUri 数据库 如果 createOption 为 ImportSecure,则这是要导入 VM 来宾状态的 Blob 的 URI。 字符串
securityMetadataUri 的 如果 createOption 为 ImportSecure,则这是要导入到机密 VM 的 VM 元数据中的 blob 的 URI。 字符串
源资源 ID 如果 createOption 为 Copy,则这是源快照或磁盘的 ARM ID。 字符串
sourceUri 如果 createOption 为 Import,则这是要导入到托管磁盘中的 Blob 的 URI。 字符串
storageAccountId 如果 createOption 为 Import,则为必需。 包含要作为磁盘导入的 Blob 的存储帐户的 Azure 资源管理器标识符。 字符串
uploadSize字节 如果 createOption 为 Upload,则这是上传内容的大小,包括 VHD 页脚。 此值应介于 20972032(VHD 页脚的 20 MiB + 512 字节)和35183298347520字节(VHD 页脚的 32 TiB + 512 字节)。 int

DiskProperties

Name Description Value
可用性策略 确定平台如何处理磁盘故障 可用性策略
bursting已启用 设置为 true 以启用超出磁盘预配性能目标的突发。 默认情况下禁用突发功能。 不适用于超级磁盘。 bool
completionPercent 通过 CopyStart作创建资源时后台副本完成的百分比。 int
creationData 磁盘源信息。 创建磁盘后,无法更改 CreationData 信息。 CreationData (必需)
dataAccessAuthMode 导出或上传到磁盘或快照时的其他身份验证要求。 'AzureActiveDirectory'
“None”
diskAccessId 磁盘上使用专用终结点的 DiskAccess 资源的 ARM ID。 字符串
diskIOPSReadOnly 将允许在所有 VM 中以 ReadOnly 身份装载共享磁盘的 IOPS 总数。 一个作可以在 4k 到 256k 字节之间传输。 int
diskIOPSReadWrite 此磁盘允许的 IOPS 数;只能为 UltraSSD 磁盘设置。 一个作可以在 4k 到 256k 字节之间传输。 int
diskMBpsReadOnly 磁盘MB ps只读 所有装载共享磁盘的 VM(MBps)的总吞吐量(MBps)将作为 ReadOnly 装载。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskMBpsReadWrite 此磁盘允许的带宽;只能为 UltraSSD 磁盘设置。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskSizeGB 磁盘大小 如果 creationData.createOption 为 Empty,则此字段是必需的,并指示要创建的磁盘的大小。 如果此字段可用于更新或创建其他选项,则表示调整大小。 仅当磁盘未附加到正在运行的 VM 时,才允许重设大小,并且只能增加磁盘的大小。 int
加密 加密属性可用于使用客户托管密钥或平台托管密钥加密静态数据。 加密
encryptionSettingsCollection 用于 Azure 磁盘加密的加密设置集合可以包含每个磁盘或快照的多个加密设置。 EncryptionSettingsCollection
hyperVGeneration 虚拟机监控程序的代次。 仅适用于 OS 磁盘。 'V1'
'V2'
最大分享数 可以同时附加到磁盘的最大虚拟机数量。 大于一个值表示可以同时装载到多个 VM 上的磁盘。 int
网络访问策略 (networkAccessPolicy) 通过网络访问磁盘的策略。 'AllowAll'
“AllowPrivate”
'DenyAll'
optimizedForFrequentAttach 将此属性设置为 true 可提高数据磁盘的可靠性和性能,这些磁盘通常(每天超过 5 次),方法是从一个虚拟机分离并附加到另一个虚拟机。 不应为未频繁分离和附加的磁盘设置此属性,因为它会导致磁盘与虚拟机的容错域不一致。 bool
osType 作系统类型。 'Linux'
“Windows”
公用网络访问 用于控制磁盘上的导出的策略。 “Disabled”
'Enabled'
购买计划 为从中创建 OS 磁盘的映像购买计划信息。 例如 - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer} 磁盘购买计划
securityProfile 包含资源的安全相关信息。 DiskSecurity配置文件
supportedCapabilities 创建 OS 磁盘的映像支持的功能列表。 支持的功能
支持休眠 指示磁盘上的 OS 支持休眠。 bool
分层 磁盘的性能层(例如 P4、S10)如下所述:https://azure.microsoft.com/pricing/details/managed-disks/。 不适用于超级磁盘。 字符串

磁盘购买计划

Name Description Value
名字 计划 ID。 字符串(必需)
产品 指定来自市场的映像的产品。 此值与 imageReference 元素下的 Offer 相同。 字符串(必需)
promotionCode 产品/服务促销代码。 字符串
发布服务器 发布者 ID。 字符串(必需)

DiskSecurity配置文件

Name Description Value
secureVMDiskEncryptionSetId 与使用客户托管密钥加密的机密 VM 支持的磁盘关联的磁盘加密集的 ResourceId 字符串
安全类型 指定 VM 的 SecurityType。 仅适用于 OS 磁盘。 “ConfidentialVM_DiskEncryptedWithCustomerKey”
“ConfidentialVM_DiskEncryptedWithPlatformKey”
“ConfidentialVM_NonPersistedTPM”
“ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey”
“TrustedLaunch”

DiskSku

Name Description Value
名字 SKU 名称。 'PremiumV2_LRS'
“Premium_LRS”
'Premium_ZRS'
'StandardSSD_LRS'
'StandardSSD_ZRS'
“Standard_LRS”
'UltraSSD_LRS'

Encryption

Name Description Value
diskEncryptionSetId 用于启用静态加密的磁盘加密集的 ResourceId。 字符串
类型 用于加密磁盘数据的密钥类型。 “EncryptionAtRestWithCustomerKey”
“EncryptionAtRestWithPlatformAndCustomerKeys”
“EncryptionAtRestWithPlatformKey”

EncryptionSettingsCollection

Name Description Value
enabled 将此标志设置为 true,并提供 DiskEncryptionKey 和可选 KeyEncryptionKey 以启用加密。 将此标志设置为 false,并删除 DiskEncryptionKey 和 KeyEncryptionKey 以禁用加密。 如果 Request 对象中的 EncryptionSettings 为 null,则现有设置保持不变。 bool (必需)
encryptionSettings 加密设置的集合,每个磁盘卷各有一个。 EncryptionSettingsElement[]
encryptionSettingsVersion 描述磁盘使用哪种类型的加密。 设置此字段后,无法覆盖它。 “1.0”对应于 AAD 应用的 Azure 磁盘加密。“1.1”对应于 Azure 磁盘加密。 字符串

EncryptionSettingsElement

Name Description Value
diskEncryptionKey 的 磁盘加密密钥的 密钥保管库 机密 URL 和保管库 ID KeyVaultAndSecretReference
keyEncryptionKey 密钥保管库密钥 URL 和密钥加密密钥的保管库 ID。 KeyEncryptionKey 是可选的,当提供用于解包磁盘加密密钥时。 KeyVaultAndKeyReference

ExtendedLocation

Name Description Value
名字 扩展位置的名称。 字符串
类型 扩展位置的类型。 “EdgeZone”

ImageDiskReference (图像磁盘引用)

Name Description Value
communityGalleryImageId 包含社区 Azure 计算库映像引用的相对 URI。 字符串
id 包含平台映像存储库、用户映像或 Azure 计算库映像引用的相对 URI。 字符串
伦 如果磁盘是从映像的数据磁盘创建的,则这是一个索引,指示要使用的映像中的数据磁盘。 对于 OS 磁盘,此字段为 null。 int
sharedGalleryImageId 包含直接共享 Azure 计算库映像引用的相对 URI。 字符串

KeyVaultAndKeyReference

Name Description Value
keyUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

KeyVaultAndSecretReference

Name Description Value
secretUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

SourceVault

Name Description Value
id 资源 ID 字符串

支持的功能

Name Description Value
加速网络 如此 如果从中创建 OS 磁盘的映像支持加速网络。 bool
体系结构 OS 磁盘支持的 CPU 体系结构。 “Arm64”
“x64”
diskController类型 OS 磁盘支持的磁盘控制器。 如果将其设置为 SCSI 或 SCSI、NVME 或 NVME、SCSI。 字符串
supportedSecurityOption 指支持创建受信任启动或机密 VM 的磁盘的安全功能 “TrustedLaunchAndConfidentialVMSupported”
'TrustedLaunchSupported' (受信任的启动支持)

TrackedResourceTags

Name Description Value

ARM 模板资源定义

可以使用目标操作部署磁盘资源类型:

用法示例

Azure 快速入门模板

以下 Azure 快速入门模板 部署此资源类型。

Template Description
从 EfficientIP VHD 创建 VM

部署到 Azure
此模板从 EfficientIP VHD 创建 VM,并允许将其连接到可以驻留在另一个资源组中的现有 VNET,然后连接到虚拟机
从自定义 VHD 在新的或现有 vnet 中创建 VM

部署到 Azure
此模板从专用 VHD 创建一个 VM,并使你能够将其连接到一个新的或现有的 VNET,该 VNET 可以驻留在另一个资源组中,而不是虚拟机
创建磁盘 &通过备份保险库启用保护

部署到 Azure
用于创建磁盘并通过备份保管库启用保护的模板
从现有 VHD 创建 VM 并将其连接到现有 VNET

部署到 Azure
此模板从 VHD(OS + 数据磁盘)创建 VM,并让你将其连接到可以驻留在另一个资源组中的现有 VNET,然后虚拟机
创建具有特定扇区大小的超级托管磁盘

部署到 Azure
此模板创建新的超级托管磁盘,允许用户指定扇区大小为 512 或 4096。
在可用性区域中部署 3 节点 Percona XtraDB 群集

部署到 Azure
此模板在 CentOS 6.5 或 Ubuntu 12.04 上部署 3 节点 MySQL 高可用性群集
图库图片版本,包含UEFI CA 2011证书

部署到 Azure
该模板从市场Linux镜像创建Azure计算库、图像定义和图像版本,并带有自定义的UEFI安全配置文件签名。
在 UltraSSD 上 SQL VM 性能优化存储设置

部署到 Azure
使用 UltraSSD for SQL 日志文件创建具有性能优化存储设置的 SQL Server 虚拟机
安装了 Portainer 和 Traefik 的 Windows Docker 主机

部署到 Azure
预安装了 Portainer 和 Traefik 的 Windows Docker 主机
使用 SSH Windows Server VM

部署到 Azure
部署启用了开放 SSH 的单个 Windows VM,以便可以使用基于密钥的身份验证通过 SSH 进行连接。

资源格式

若要创建 Microsoft.Compute/disks 资源,请将以下 JSON 添加到模板。

{
  "type": "Microsoft.Compute/disks",
  "apiVersion": "2026-03-02",
  "name": "string",
  "extendedLocation": {
    "name": "string",
    "type": "string"
  },
  "location": "string",
  "properties": {
    "availabilityPolicy": {
      "actionOnDiskDelay": "string"
    },
    "burstingEnabled": "bool",
    "completionPercent": "int",
    "creationData": {
      "createOption": "string",
      "elasticSanResourceId": "string",
      "galleryImageReference": {
        "communityGalleryImageId": "string",
        "id": "string",
        "lun": "int",
        "sharedGalleryImageId": "string"
      },
      "imageReference": {
        "communityGalleryImageId": "string",
        "id": "string",
        "lun": "int",
        "sharedGalleryImageId": "string"
      },
      "instantAccessDurationMinutes": "int",
      "logicalSectorSize": "int",
      "performancePlus": "bool",
      "provisionedBandwidthCopySpeed": "string",
      "securityDataUri": "string",
      "securityMetadataUri": "string",
      "sourceResourceId": "string",
      "sourceUri": "string",
      "storageAccountId": "string",
      "uploadSizeBytes": "int"
    },
    "dataAccessAuthMode": "string",
    "diskAccessId": "string",
    "diskIOPSReadOnly": "int",
    "diskIOPSReadWrite": "int",
    "diskMBpsReadOnly": "int",
    "diskMBpsReadWrite": "int",
    "diskSizeGB": "int",
    "encryption": {
      "diskEncryptionSetId": "string",
      "type": "string"
    },
    "encryptionSettingsCollection": {
      "enabled": "bool",
      "encryptionSettings": [
        {
          "diskEncryptionKey": {
            "secretUrl": "string",
            "sourceVault": {
              "id": "string"
            }
          },
          "keyEncryptionKey": {
            "keyUrl": "string",
            "sourceVault": {
              "id": "string"
            }
          }
        }
      ],
      "encryptionSettingsVersion": "string"
    },
    "hyperVGeneration": "string",
    "maxShares": "int",
    "networkAccessPolicy": "string",
    "optimizedForFrequentAttach": "bool",
    "osType": "string",
    "publicNetworkAccess": "string",
    "purchasePlan": {
      "name": "string",
      "product": "string",
      "promotionCode": "string",
      "publisher": "string"
    },
    "securityProfile": {
      "secureVMDiskEncryptionSetId": "string",
      "securityType": "string"
    },
    "supportedCapabilities": {
      "acceleratedNetwork": "bool",
      "architecture": "string",
      "diskControllerTypes": "string",
      "supportedSecurityOption": "string"
    },
    "supportsHibernation": "bool",
    "tier": "string"
  },
  "sku": {
    "name": "string"
  },
  "tags": {
    "{customized property}": "string"
  },
  "zones": [ "string" ]
}

属性值

Microsoft.Compute/disks

Name Description Value
apiVersion API 版本 '2026-03-02'
extendedLocation 将创建磁盘的扩展位置。 无法更改扩展位置。 ExtendedLocation
位置 资源所在的地理位置 字符串(必需)
名字 资源名称 字符串(必需)
性能 磁盘资源属性。 DiskProperties
sku 磁盘 SKU 名称。 可以是Standard_LRS、Premium_LRS、StandardSSD_LRS、UltraSSD_LRS、Premium_ZRS、StandardSSD_ZRS或PremiumV2_LRS。 DiskSku
tags 资源标记 标记名称和值的字典。 请参阅模板中的标记
类型 资源类型 “Microsoft.Compute/disks”
区域 磁盘的逻辑区域列表。 string[]

可用性策略

Name Description Value
actionOnDiskDelay 确定如何处理 I/O 速度较慢的磁盘。 'AutomaticReattach'
“None”

CreationData

Name Description Value
createOption 这会枚举磁盘创建可能的源。 “Attach”
'Copy'
“CopyFromSanSnapshot”
“CopyStart”
“Empty”
“FromImage”
'Import'
“ImportSecure”
“还原”
'Upload'
“UploadPreparedSecure”(必需)
elasticSanResourceId 如果 createOption 为 CopyFromSanSnapshot,则是必需的。 这是源弹性 san 卷快照的 ARM ID。 字符串
galleryImageReference (图片参考) 从库映像创建时是必需的。 ImageDiskReference 的 id/sharedGalleryImageId/communityGalleryImageId 将是要从中创建磁盘的共享 galley 映像版本的 ARM ID。 ImageDiskReference (图像磁盘引用)
imageReference PIR 或用户映像的磁盘源信息。 ImageDiskReference (图像磁盘引用)
instantAccessDurationMinutes 对于从高级 SSD v2 或超级磁盘创建的快照,此属性确定保留快照以供即时访问以实现更快还原的时间(以分钟为单位)。 int

约束:
最小值 = 1
logicalSectorSize (逻辑扇区大小) 超级磁盘的逻辑扇区大小(以字节为单位)。 支持的值为 512 ad 4096。 4096 是默认值。 int
performancePlus 性能 将此标志设置为 true 以提升部署的磁盘的性能目标,请参阅此处的相应性能目标。 此标志只能在磁盘创建时设置,在启用后不能禁用。 bool
预置带宽复制速度 如果在快照上设置了此字段,并且 createOption 为 CopyStart,则会以更快的速度复制快照。 “增强”
“None”
securityDataUri 数据库 如果 createOption 为 ImportSecure,则这是要导入 VM 来宾状态的 Blob 的 URI。 字符串
securityMetadataUri 的 如果 createOption 为 ImportSecure,则这是要导入到机密 VM 的 VM 元数据中的 blob 的 URI。 字符串
源资源 ID 如果 createOption 为 Copy,则这是源快照或磁盘的 ARM ID。 字符串
sourceUri 如果 createOption 为 Import,则这是要导入到托管磁盘中的 Blob 的 URI。 字符串
storageAccountId 如果 createOption 为 Import,则为必需。 包含要作为磁盘导入的 Blob 的存储帐户的 Azure 资源管理器标识符。 字符串
uploadSize字节 如果 createOption 为 Upload,则这是上传内容的大小,包括 VHD 页脚。 此值应介于 20972032(VHD 页脚的 20 MiB + 512 字节)和35183298347520字节(VHD 页脚的 32 TiB + 512 字节)。 int

DiskProperties

Name Description Value
可用性策略 确定平台如何处理磁盘故障 可用性策略
bursting已启用 设置为 true 以启用超出磁盘预配性能目标的突发。 默认情况下禁用突发功能。 不适用于超级磁盘。 bool
completionPercent 通过 CopyStart作创建资源时后台副本完成的百分比。 int
creationData 磁盘源信息。 创建磁盘后,无法更改 CreationData 信息。 CreationData (必需)
dataAccessAuthMode 导出或上传到磁盘或快照时的其他身份验证要求。 'AzureActiveDirectory'
“None”
diskAccessId 磁盘上使用专用终结点的 DiskAccess 资源的 ARM ID。 字符串
diskIOPSReadOnly 将允许在所有 VM 中以 ReadOnly 身份装载共享磁盘的 IOPS 总数。 一个作可以在 4k 到 256k 字节之间传输。 int
diskIOPSReadWrite 此磁盘允许的 IOPS 数;只能为 UltraSSD 磁盘设置。 一个作可以在 4k 到 256k 字节之间传输。 int
diskMBpsReadOnly 磁盘MB ps只读 所有装载共享磁盘的 VM(MBps)的总吞吐量(MBps)将作为 ReadOnly 装载。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskMBpsReadWrite 此磁盘允许的带宽;只能为 UltraSSD 磁盘设置。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskSizeGB 磁盘大小 如果 creationData.createOption 为 Empty,则此字段是必需的,并指示要创建的磁盘的大小。 如果此字段可用于更新或创建其他选项,则表示调整大小。 仅当磁盘未附加到正在运行的 VM 时,才允许重设大小,并且只能增加磁盘的大小。 int
加密 加密属性可用于使用客户托管密钥或平台托管密钥加密静态数据。 加密
encryptionSettingsCollection 用于 Azure 磁盘加密的加密设置集合可以包含每个磁盘或快照的多个加密设置。 EncryptionSettingsCollection
hyperVGeneration 虚拟机监控程序的代次。 仅适用于 OS 磁盘。 'V1'
'V2'
最大分享数 可以同时附加到磁盘的最大虚拟机数量。 大于一个值表示可以同时装载到多个 VM 上的磁盘。 int
网络访问策略 (networkAccessPolicy) 通过网络访问磁盘的策略。 'AllowAll'
“AllowPrivate”
'DenyAll'
optimizedForFrequentAttach 将此属性设置为 true 可提高数据磁盘的可靠性和性能,这些磁盘通常(每天超过 5 次),方法是从一个虚拟机分离并附加到另一个虚拟机。 不应为未频繁分离和附加的磁盘设置此属性,因为它会导致磁盘与虚拟机的容错域不一致。 bool
osType 作系统类型。 'Linux'
“Windows”
公用网络访问 用于控制磁盘上的导出的策略。 “Disabled”
'Enabled'
购买计划 为从中创建 OS 磁盘的映像购买计划信息。 例如 - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer} 磁盘购买计划
securityProfile 包含资源的安全相关信息。 DiskSecurity配置文件
supportedCapabilities 创建 OS 磁盘的映像支持的功能列表。 支持的功能
支持休眠 指示磁盘上的 OS 支持休眠。 bool
分层 磁盘的性能层(例如 P4、S10)如下所述:https://azure.microsoft.com/pricing/details/managed-disks/。 不适用于超级磁盘。 字符串

磁盘购买计划

Name Description Value
名字 计划 ID。 字符串(必需)
产品 指定来自市场的映像的产品。 此值与 imageReference 元素下的 Offer 相同。 字符串(必需)
promotionCode 产品/服务促销代码。 字符串
发布服务器 发布者 ID。 字符串(必需)

DiskSecurity配置文件

Name Description Value
secureVMDiskEncryptionSetId 与使用客户托管密钥加密的机密 VM 支持的磁盘关联的磁盘加密集的 ResourceId 字符串
安全类型 指定 VM 的 SecurityType。 仅适用于 OS 磁盘。 “ConfidentialVM_DiskEncryptedWithCustomerKey”
“ConfidentialVM_DiskEncryptedWithPlatformKey”
“ConfidentialVM_NonPersistedTPM”
“ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey”
“TrustedLaunch”

DiskSku

Name Description Value
名字 SKU 名称。 'PremiumV2_LRS'
“Premium_LRS”
'Premium_ZRS'
'StandardSSD_LRS'
'StandardSSD_ZRS'
“Standard_LRS”
'UltraSSD_LRS'

Encryption

Name Description Value
diskEncryptionSetId 用于启用静态加密的磁盘加密集的 ResourceId。 字符串
类型 用于加密磁盘数据的密钥类型。 “EncryptionAtRestWithCustomerKey”
“EncryptionAtRestWithPlatformAndCustomerKeys”
“EncryptionAtRestWithPlatformKey”

EncryptionSettingsCollection

Name Description Value
enabled 将此标志设置为 true,并提供 DiskEncryptionKey 和可选 KeyEncryptionKey 以启用加密。 将此标志设置为 false,并删除 DiskEncryptionKey 和 KeyEncryptionKey 以禁用加密。 如果 Request 对象中的 EncryptionSettings 为 null,则现有设置保持不变。 bool (必需)
encryptionSettings 加密设置的集合,每个磁盘卷各有一个。 EncryptionSettingsElement[]
encryptionSettingsVersion 描述磁盘使用哪种类型的加密。 设置此字段后,无法覆盖它。 “1.0”对应于 AAD 应用的 Azure 磁盘加密。“1.1”对应于 Azure 磁盘加密。 字符串

EncryptionSettingsElement

Name Description Value
diskEncryptionKey 的 磁盘加密密钥的 密钥保管库 机密 URL 和保管库 ID KeyVaultAndSecretReference
keyEncryptionKey 密钥保管库密钥 URL 和密钥加密密钥的保管库 ID。 KeyEncryptionKey 是可选的,当提供用于解包磁盘加密密钥时。 KeyVaultAndKeyReference

ExtendedLocation

Name Description Value
名字 扩展位置的名称。 字符串
类型 扩展位置的类型。 “EdgeZone”

ImageDiskReference (图像磁盘引用)

Name Description Value
communityGalleryImageId 包含社区 Azure 计算库映像引用的相对 URI。 字符串
id 包含平台映像存储库、用户映像或 Azure 计算库映像引用的相对 URI。 字符串
伦 如果磁盘是从映像的数据磁盘创建的,则这是一个索引,指示要使用的映像中的数据磁盘。 对于 OS 磁盘,此字段为 null。 int
sharedGalleryImageId 包含直接共享 Azure 计算库映像引用的相对 URI。 字符串

KeyVaultAndKeyReference

Name Description Value
keyUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

KeyVaultAndSecretReference

Name Description Value
secretUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

SourceVault

Name Description Value
id 资源 ID 字符串

支持的功能

Name Description Value
加速网络 如此 如果从中创建 OS 磁盘的映像支持加速网络。 bool
体系结构 OS 磁盘支持的 CPU 体系结构。 “Arm64”
“x64”
diskController类型 OS 磁盘支持的磁盘控制器。 如果将其设置为 SCSI 或 SCSI、NVME 或 NVME、SCSI。 字符串
supportedSecurityOption 指支持创建受信任启动或机密 VM 的磁盘的安全功能 “TrustedLaunchAndConfidentialVMSupported”
'TrustedLaunchSupported' (受信任的启动支持)

TrackedResourceTags

Name Description Value

Terraform (AzAPI 提供程序)资源定义

可以使用目标操作部署磁盘资源类型:

  • 资源组 关于每个API版本中变更属性的列表,请参见 更改日志。

用法示例

Terraform 示例

部署托管磁盘的基本示例。

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "disk" {
  type      = "Microsoft.Compute/disks@2022-03-02"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      creationData = {
        createOption = "Empty"
      }
      diskSizeGB = 10
      encryption = {
        type = "EncryptionAtRestWithPlatformKey"
      }
      networkAccessPolicy = "AllowAll"
      osType              = ""
      publicNetworkAccess = "Enabled"
    }
    sku = {
      name = "Standard_LRS"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

Azure 验证模块

以下 Azure 验证模块 可用于部署此资源类型。

模块 Description
计算磁盘 计算磁盘的 AVM 资源模块

资源格式

若要创建 Microsoft.Compute/disks 资源,请将以下 Terraform 添加到模板中。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Compute/disks@2026-03-02"
  name = "string"
  parent_id = "string"
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = {
    extendedLocation = {
      name = "string"
      type = "string"
    }
    properties = {
      availabilityPolicy = {
        actionOnDiskDelay = "string"
      }
      burstingEnabled = bool
      completionPercent = int
      creationData = {
        createOption = "string"
        elasticSanResourceId = "string"
        galleryImageReference = {
          communityGalleryImageId = "string"
          id = "string"
          lun = int
          sharedGalleryImageId = "string"
        }
        imageReference = {
          communityGalleryImageId = "string"
          id = "string"
          lun = int
          sharedGalleryImageId = "string"
        }
        instantAccessDurationMinutes = int
        logicalSectorSize = int
        performancePlus = bool
        provisionedBandwidthCopySpeed = "string"
        securityDataUri = "string"
        securityMetadataUri = "string"
        sourceResourceId = "string"
        sourceUri = "string"
        storageAccountId = "string"
        uploadSizeBytes = int
      }
      dataAccessAuthMode = "string"
      diskAccessId = "string"
      diskIOPSReadOnly = int
      diskIOPSReadWrite = int
      diskMBpsReadOnly = int
      diskMBpsReadWrite = int
      diskSizeGB = int
      encryption = {
        diskEncryptionSetId = "string"
        type = "string"
      }
      encryptionSettingsCollection = {
        enabled = bool
        encryptionSettings = [
          {
            diskEncryptionKey = {
              secretUrl = "string"
              sourceVault = {
                id = "string"
              }
            }
            keyEncryptionKey = {
              keyUrl = "string"
              sourceVault = {
                id = "string"
              }
            }
          }
        ]
        encryptionSettingsVersion = "string"
      }
      hyperVGeneration = "string"
      maxShares = int
      networkAccessPolicy = "string"
      optimizedForFrequentAttach = bool
      osType = "string"
      publicNetworkAccess = "string"
      purchasePlan = {
        name = "string"
        product = "string"
        promotionCode = "string"
        publisher = "string"
      }
      securityProfile = {
        secureVMDiskEncryptionSetId = "string"
        securityType = "string"
      }
      supportedCapabilities = {
        acceleratedNetwork = bool
        architecture = "string"
        diskControllerTypes = "string"
        supportedSecurityOption = "string"
      }
      supportsHibernation = bool
      tier = "string"
    }
    sku = {
      name = "string"
    }
    zones = [
      "string"
    ]
  }
}

属性值

Microsoft.Compute/disks

Name Description Value
extendedLocation 将创建磁盘的扩展位置。 无法更改扩展位置。 ExtendedLocation
位置 资源所在的地理位置 字符串(必需)
名字 资源名称 字符串(必需)
性能 磁盘资源属性。 DiskProperties
sku 磁盘 SKU 名称。 可以是Standard_LRS、Premium_LRS、StandardSSD_LRS、UltraSSD_LRS、Premium_ZRS、StandardSSD_ZRS或PremiumV2_LRS。 DiskSku
tags 资源标记 标记名称和值的字典。
类型 资源类型 “Microsoft。计算/disks@2026-03-02”
区域 磁盘的逻辑区域列表。 string[]

可用性策略

Name Description Value
actionOnDiskDelay 确定如何处理 I/O 速度较慢的磁盘。 'AutomaticReattach'
“None”

CreationData

Name Description Value
createOption 这会枚举磁盘创建可能的源。 “Attach”
'Copy'
“CopyFromSanSnapshot”
“CopyStart”
“Empty”
“FromImage”
'Import'
“ImportSecure”
“还原”
'Upload'
“UploadPreparedSecure”(必需)
elasticSanResourceId 如果 createOption 为 CopyFromSanSnapshot,则是必需的。 这是源弹性 san 卷快照的 ARM ID。 字符串
galleryImageReference (图片参考) 从库映像创建时是必需的。 ImageDiskReference 的 id/sharedGalleryImageId/communityGalleryImageId 将是要从中创建磁盘的共享 galley 映像版本的 ARM ID。 ImageDiskReference (图像磁盘引用)
imageReference PIR 或用户映像的磁盘源信息。 ImageDiskReference (图像磁盘引用)
instantAccessDurationMinutes 对于从高级 SSD v2 或超级磁盘创建的快照,此属性确定保留快照以供即时访问以实现更快还原的时间(以分钟为单位)。 int

约束:
最小值 = 1
logicalSectorSize (逻辑扇区大小) 超级磁盘的逻辑扇区大小(以字节为单位)。 支持的值为 512 ad 4096。 4096 是默认值。 int
performancePlus 性能 将此标志设置为 true 以提升部署的磁盘的性能目标,请参阅此处的相应性能目标。 此标志只能在磁盘创建时设置,在启用后不能禁用。 bool
预置带宽复制速度 如果在快照上设置了此字段,并且 createOption 为 CopyStart,则会以更快的速度复制快照。 “增强”
“None”
securityDataUri 数据库 如果 createOption 为 ImportSecure,则这是要导入 VM 来宾状态的 Blob 的 URI。 字符串
securityMetadataUri 的 如果 createOption 为 ImportSecure,则这是要导入到机密 VM 的 VM 元数据中的 blob 的 URI。 字符串
源资源 ID 如果 createOption 为 Copy,则这是源快照或磁盘的 ARM ID。 字符串
sourceUri 如果 createOption 为 Import,则这是要导入到托管磁盘中的 Blob 的 URI。 字符串
storageAccountId 如果 createOption 为 Import,则为必需。 包含要作为磁盘导入的 Blob 的存储帐户的 Azure 资源管理器标识符。 字符串
uploadSize字节 如果 createOption 为 Upload,则这是上传内容的大小,包括 VHD 页脚。 此值应介于 20972032(VHD 页脚的 20 MiB + 512 字节)和35183298347520字节(VHD 页脚的 32 TiB + 512 字节)。 int

DiskProperties

Name Description Value
可用性策略 确定平台如何处理磁盘故障 可用性策略
bursting已启用 设置为 true 以启用超出磁盘预配性能目标的突发。 默认情况下禁用突发功能。 不适用于超级磁盘。 bool
completionPercent 通过 CopyStart作创建资源时后台副本完成的百分比。 int
creationData 磁盘源信息。 创建磁盘后,无法更改 CreationData 信息。 CreationData (必需)
dataAccessAuthMode 导出或上传到磁盘或快照时的其他身份验证要求。 'AzureActiveDirectory'
“None”
diskAccessId 磁盘上使用专用终结点的 DiskAccess 资源的 ARM ID。 字符串
diskIOPSReadOnly 将允许在所有 VM 中以 ReadOnly 身份装载共享磁盘的 IOPS 总数。 一个作可以在 4k 到 256k 字节之间传输。 int
diskIOPSReadWrite 此磁盘允许的 IOPS 数;只能为 UltraSSD 磁盘设置。 一个作可以在 4k 到 256k 字节之间传输。 int
diskMBpsReadOnly 磁盘MB ps只读 所有装载共享磁盘的 VM(MBps)的总吞吐量(MBps)将作为 ReadOnly 装载。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskMBpsReadWrite 此磁盘允许的带宽;只能为 UltraSSD 磁盘设置。 MBps 表示每秒数百万字节 - 此处的 MB 使用 ISO 表示法,其幂为 10。 int
diskSizeGB 磁盘大小 如果 creationData.createOption 为 Empty,则此字段是必需的,并指示要创建的磁盘的大小。 如果此字段可用于更新或创建其他选项,则表示调整大小。 仅当磁盘未附加到正在运行的 VM 时,才允许重设大小,并且只能增加磁盘的大小。 int
加密 加密属性可用于使用客户托管密钥或平台托管密钥加密静态数据。 加密
encryptionSettingsCollection 用于 Azure 磁盘加密的加密设置集合可以包含每个磁盘或快照的多个加密设置。 EncryptionSettingsCollection
hyperVGeneration 虚拟机监控程序的代次。 仅适用于 OS 磁盘。 'V1'
'V2'
最大分享数 可以同时附加到磁盘的最大虚拟机数量。 大于一个值表示可以同时装载到多个 VM 上的磁盘。 int
网络访问策略 (networkAccessPolicy) 通过网络访问磁盘的策略。 'AllowAll'
“AllowPrivate”
'DenyAll'
optimizedForFrequentAttach 将此属性设置为 true 可提高数据磁盘的可靠性和性能,这些磁盘通常(每天超过 5 次),方法是从一个虚拟机分离并附加到另一个虚拟机。 不应为未频繁分离和附加的磁盘设置此属性,因为它会导致磁盘与虚拟机的容错域不一致。 bool
osType 作系统类型。 'Linux'
“Windows”
公用网络访问 用于控制磁盘上的导出的策略。 “Disabled”
'Enabled'
购买计划 为从中创建 OS 磁盘的映像购买计划信息。 例如 - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer} 磁盘购买计划
securityProfile 包含资源的安全相关信息。 DiskSecurity配置文件
supportedCapabilities 创建 OS 磁盘的映像支持的功能列表。 支持的功能
支持休眠 指示磁盘上的 OS 支持休眠。 bool
分层 磁盘的性能层(例如 P4、S10)如下所述:https://azure.microsoft.com/pricing/details/managed-disks/。 不适用于超级磁盘。 字符串

磁盘购买计划

Name Description Value
名字 计划 ID。 字符串(必需)
产品 指定来自市场的映像的产品。 此值与 imageReference 元素下的 Offer 相同。 字符串(必需)
promotionCode 产品/服务促销代码。 字符串
发布服务器 发布者 ID。 字符串(必需)

DiskSecurity配置文件

Name Description Value
secureVMDiskEncryptionSetId 与使用客户托管密钥加密的机密 VM 支持的磁盘关联的磁盘加密集的 ResourceId 字符串
安全类型 指定 VM 的 SecurityType。 仅适用于 OS 磁盘。 “ConfidentialVM_DiskEncryptedWithCustomerKey”
“ConfidentialVM_DiskEncryptedWithPlatformKey”
“ConfidentialVM_NonPersistedTPM”
“ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey”
“TrustedLaunch”

DiskSku

Name Description Value
名字 SKU 名称。 'PremiumV2_LRS'
“Premium_LRS”
'Premium_ZRS'
'StandardSSD_LRS'
'StandardSSD_ZRS'
“Standard_LRS”
'UltraSSD_LRS'

Encryption

Name Description Value
diskEncryptionSetId 用于启用静态加密的磁盘加密集的 ResourceId。 字符串
类型 用于加密磁盘数据的密钥类型。 “EncryptionAtRestWithCustomerKey”
“EncryptionAtRestWithPlatformAndCustomerKeys”
“EncryptionAtRestWithPlatformKey”

EncryptionSettingsCollection

Name Description Value
enabled 将此标志设置为 true,并提供 DiskEncryptionKey 和可选 KeyEncryptionKey 以启用加密。 将此标志设置为 false,并删除 DiskEncryptionKey 和 KeyEncryptionKey 以禁用加密。 如果 Request 对象中的 EncryptionSettings 为 null,则现有设置保持不变。 bool (必需)
encryptionSettings 加密设置的集合,每个磁盘卷各有一个。 EncryptionSettingsElement[]
encryptionSettingsVersion 描述磁盘使用哪种类型的加密。 设置此字段后,无法覆盖它。 “1.0”对应于 AAD 应用的 Azure 磁盘加密。“1.1”对应于 Azure 磁盘加密。 字符串

EncryptionSettingsElement

Name Description Value
diskEncryptionKey 的 磁盘加密密钥的 密钥保管库 机密 URL 和保管库 ID KeyVaultAndSecretReference
keyEncryptionKey 密钥保管库密钥 URL 和密钥加密密钥的保管库 ID。 KeyEncryptionKey 是可选的,当提供用于解包磁盘加密密钥时。 KeyVaultAndKeyReference

ExtendedLocation

Name Description Value
名字 扩展位置的名称。 字符串
类型 扩展位置的类型。 “EdgeZone”

ImageDiskReference (图像磁盘引用)

Name Description Value
communityGalleryImageId 包含社区 Azure 计算库映像引用的相对 URI。 字符串
id 包含平台映像存储库、用户映像或 Azure 计算库映像引用的相对 URI。 字符串
伦 如果磁盘是从映像的数据磁盘创建的,则这是一个索引,指示要使用的映像中的数据磁盘。 对于 OS 磁盘,此字段为 null。 int
sharedGalleryImageId 包含直接共享 Azure 计算库映像引用的相对 URI。 字符串

KeyVaultAndKeyReference

Name Description Value
keyUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

KeyVaultAndSecretReference

Name Description Value
secretUrl 的 指向 KeyVault 中的密钥或机密的 URL 字符串(必需)
sourceVault (源保险库) 包含密钥或机密的 KeyVault 的资源 ID SourceVault (必需)

SourceVault

Name Description Value
id 资源 ID 字符串

支持的功能

Name Description Value
加速网络 如此 如果从中创建 OS 磁盘的映像支持加速网络。 bool
体系结构 OS 磁盘支持的 CPU 体系结构。 “Arm64”
“x64”
diskController类型 OS 磁盘支持的磁盘控制器。 如果将其设置为 SCSI 或 SCSI、NVME 或 NVME、SCSI。 字符串
supportedSecurityOption 指支持创建受信任启动或机密 VM 的磁盘的安全功能 “TrustedLaunchAndConfidentialVMSupported”
'TrustedLaunchSupported' (受信任的启动支持)

TrackedResourceTags

Name Description Value