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

Microsoft.Maintenance 配置分配 2020-07-01-preview

Bicep 资源定义

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

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

用法示例

Bicep 示例

部署维护分配的基本示例。

param resourceName string = 'acctest0001'
param location string = 'westeurope'
@secure()
@description('The administrator password for the virtual machine')
param adminPassword string

resource virtualMachine 'Microsoft.Compute/virtualMachines@2023-03-01' = {
  name: resourceName
  location: location
  properties: {
    additionalCapabilities: {}
    applicationProfile: {
      galleryApplications: []
    }
    diagnosticsProfile: {
      bootDiagnostics: {
        enabled: false
        storageUri: ''
      }
    }
    extensionsTimeBudget: 'PT1H30M'
    hardwareProfile: {
      vmSize: 'Standard_F2'
    }
    networkProfile: {
      networkInterfaces: [
        {
          id: networkInterface.id
          properties: {
            primary: true
          }
        }
      ]
    }
    osProfile: {
      adminPassword: adminPassword
      adminUsername: 'adminuser'
      allowExtensionOperations: true
      computerName: resourceName
      linuxConfiguration: {
        disablePasswordAuthentication: false
        patchSettings: {
          assessmentMode: 'ImageDefault'
          patchMode: 'ImageDefault'
        }
        provisionVMAgent: true
        ssh: {
          publicKeys: []
        }
      }
      secrets: []
    }
    priority: 'Regular'
    storageProfile: {
      dataDisks: []
      imageReference: {
        offer: 'UbuntuServer'
        publisher: 'Canonical'
        sku: '16.04-LTS'
        version: 'latest'
      }
      osDisk: {
        caching: 'ReadWrite'
        createOption: 'FromImage'
        managedDisk: {
          storageAccountType: 'Standard_LRS'
        }
        osType: 'Linux'
        writeAcceleratorEnabled: false
      }
    }
  }
}

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-07-01' = {
  name: resourceName
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: [
        '10.0.0.0/16'
      ]
    }
    dhcpOptions: {
      dnsServers: []
    }
    subnets: []
  }
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-07-01' = {
  name: 'internal'
  parent: virtualNetwork
  properties: {
    addressPrefix: '10.0.2.0/24'
    delegations: []
    privateEndpointNetworkPolicies: 'Enabled'
    privateLinkServiceNetworkPolicies: 'Enabled'
    serviceEndpointPolicies: []
    serviceEndpoints: []
  }
}

resource configurationAssignment 'Microsoft.Maintenance/configurationAssignments@2022-07-01-preview' = {
  name: resourceName
  scope: virtualMachine
  properties: {
    maintenanceConfigurationId: maintenanceConfiguration.id
    resourceId: virtualMachine.id
  }
}

resource maintenanceConfiguration 'Microsoft.Maintenance/maintenanceConfigurations@2022-07-01-preview' = {
  name: resourceName
  location: location
  properties: {
    extensionProperties: {}
    maintenanceScope: 'SQLDB'
    namespace: 'Microsoft.Maintenance'
    visibility: 'Custom'
  }
}

resource networkInterface 'Microsoft.Network/networkInterfaces@2022-07-01' = {
  name: resourceName
  location: location
  properties: {
    enableAcceleratedNetworking: false
    enableIPForwarding: false
    ipConfigurations: [
      {
        name: 'testconfiguration1'
        properties: {
          primary: true
          privateIPAddressVersion: 'IPv4'
          privateIPAllocationMethod: 'Dynamic'
          subnet: {
            id: subnet.id
          }
        }
      }
    ]
  }
}

Azure 验证模块

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

模块 描述
维护配置分配 用于维护配置分配的 AVM 资源模块

资源格式

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

resource symbolicname 'Microsoft.Maintenance/configurationAssignments@2020-07-01-preview' = {
  scope: resourceSymbolicName or scope
  location: 'string'
  name: 'string'
  properties: {
    maintenanceConfigurationId: 'string'
    resourceId: 'string'
  }
}

属性值

Microsoft.Maintenance/configurationAssignments

名字 描述 价值
位置 资源的位置 字符串
名字 资源名称 string (必需)
性能 配置分配的属性 ConfigurationAssignmentProperties
作用域 在与部署范围不同的范围内创建资源时使用。 将此属性设置为资源的符号名称,以应用 扩展资源。

ConfigurationAssignmentProperties

名字 描述 价值
maintenanceConfigurationId 维护配置 ID 字符串
资源ID unique resourceId 字符串

ARM 模板资源定义

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

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

用法示例

资源格式

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

{
  "type": "Microsoft.Maintenance/configurationAssignments",
  "apiVersion": "2020-07-01-preview",
  "name": "string",
  "location": "string",
  "properties": {
    "maintenanceConfigurationId": "string",
    "resourceId": "string"
  }
}

属性值

Microsoft.Maintenance/configurationAssignments

名字 描述 价值
apiVersion API 版本 “2020-07-01-预览”
位置 资源的位置 字符串
名字 资源名称 string (必需)
性能 配置分配的属性 ConfigurationAssignmentProperties
类型 资源类型 “Microsoft.Maintenance/configurationAssignments”

ConfigurationAssignmentProperties

名字 描述 价值
maintenanceConfigurationId 维护配置 ID 字符串
资源ID unique resourceId 字符串

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

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

有关每个 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"
}

variable "admin_password" {
  type        = string
  description = "The administrator password for the virtual machine"
  sensitive   = true
}

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

resource "azapi_resource" "maintenanceConfiguration" {
  type      = "Microsoft.Maintenance/maintenanceConfigurations@2022-07-01-preview"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      extensionProperties = {
      }
      maintenanceScope = "SQLDB"
      namespace        = "Microsoft.Maintenance"
      visibility       = "Custom"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "virtualNetwork" {
  type      = "Microsoft.Network/virtualNetworks@2022-07-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      addressSpace = {
        addressPrefixes = [
          "10.0.0.0/16",
        ]
      }
      dhcpOptions = {
        dnsServers = [
        ]
      }
      subnets = [
      ]
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
  lifecycle {
    ignore_changes = [body.properties.subnets]
  }
}

resource "azapi_resource" "subnet" {
  type      = "Microsoft.Network/virtualNetworks/subnets@2022-07-01"
  parent_id = azapi_resource.virtualNetwork.id
  name      = "internal"
  body = {
    properties = {
      addressPrefix = "10.0.2.0/24"
      delegations = [
      ]
      privateEndpointNetworkPolicies    = "Enabled"
      privateLinkServiceNetworkPolicies = "Enabled"
      serviceEndpointPolicies = [
      ]
      serviceEndpoints = [
      ]
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "networkInterface" {
  type      = "Microsoft.Network/networkInterfaces@2022-07-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      enableAcceleratedNetworking = false
      enableIPForwarding          = false
      ipConfigurations = [
        {
          name = "testconfiguration1"
          properties = {
            primary                   = true
            privateIPAddressVersion   = "IPv4"
            privateIPAllocationMethod = "Dynamic"
            subnet = {
              id = azapi_resource.subnet.id
            }
          }
        },
      ]
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "virtualMachine" {
  type      = "Microsoft.Compute/virtualMachines@2023-03-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      additionalCapabilities = {
      }
      applicationProfile = {
        galleryApplications = [
        ]
      }
      diagnosticsProfile = {
        bootDiagnostics = {
          enabled    = false
          storageUri = ""
        }
      }
      extensionsTimeBudget = "PT1H30M"
      hardwareProfile = {
        vmSize = "Standard_F2"
      }
      networkProfile = {
        networkInterfaces = [
          {
            id = azapi_resource.networkInterface.id
            properties = {
              primary = true
            }
          },
        ]
      }
      osProfile = {
        adminPassword            = var.admin_password
        adminUsername            = "adminuser"
        allowExtensionOperations = true
        computerName             = var.resource_name
        linuxConfiguration = {
          disablePasswordAuthentication = false
          patchSettings = {
            assessmentMode = "ImageDefault"
            patchMode      = "ImageDefault"
          }
          provisionVMAgent = true
          ssh = {
            publicKeys = [
            ]
          }
        }
        secrets = [
        ]
      }
      priority = "Regular"
      storageProfile = {
        dataDisks = [
        ]
        imageReference = {
          offer     = "UbuntuServer"
          publisher = "Canonical"
          sku       = "16.04-LTS"
          version   = "latest"
        }
        osDisk = {
          caching      = "ReadWrite"
          createOption = "FromImage"
          managedDisk = {
            storageAccountType = "Standard_LRS"
          }
          osType                  = "Linux"
          writeAcceleratorEnabled = false
        }
      }
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "configurationAssignment" {
  type      = "Microsoft.Maintenance/configurationAssignments@2022-07-01-preview"
  parent_id = azapi_resource.virtualMachine.id
  name      = var.resource_name
  body = {
    location = "westeurope"
    properties = {
      maintenanceConfigurationId = azapi_resource.maintenanceConfiguration.id
      resourceId                 = azapi_resource.virtualMachine.id
    }
  }
  ignore_casing             = true
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

资源格式

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

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Maintenance/configurationAssignments@2020-07-01-preview"
  name = "string"
  parent_id = "string"
  location = "string"
  body = {
    properties = {
      maintenanceConfigurationId = "string"
      resourceId = "string"
    }
  }
}

属性值

Microsoft.Maintenance/configurationAssignments

名字 描述 价值
位置 资源的位置 字符串
名字 资源名称 string (必需)
parent_id 要向其应用此扩展资源的资源的 ID。 string (必需)
性能 配置分配的属性 ConfigurationAssignmentProperties
类型 资源类型 “Microsoft.Maintenance/configurationAssignments@2020-07-01-preview”

ConfigurationAssignmentProperties

名字 描述 价值
maintenanceConfigurationId 维护配置 ID 字符串
资源ID unique resourceId 字符串