Bicep 资源定义
可以使用目标操作部署 guestConfigurationAssignments 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
若要创建 Microsoft.GuestConfiguration/guestConfigurationAssignments 资源,请将以下 Bicep 添加到模板。
resource symbolicname 'Microsoft.GuestConfiguration/guestConfigurationAssignments@2024-04-05' = {
scope: resourceSymbolicName or scope
location: 'string'
name: 'string'
properties: {
context: 'string'
guestConfiguration: {
assignmentType: 'string'
configurationParameter: [
{
name: 'string'
value: 'string'
}
]
configurationProtectedParameter: [
{
name: 'string'
value: 'string'
}
]
contentHash: 'string'
contentManagedIdentity: 'string'
contentUri: 'string'
kind: 'string'
name: 'string'
version: 'string'
}
latestAssignmentReport: {
assignment: {
configuration: {}
}
resources: [
{
reasons: [
{}
]
}
]
vm: {}
}
vmssVMList: [
{}
]
}
}
属性值
Microsoft.GuestConfiguration/guestConfigurationAssignments
作业信息
| 名字 |
描述 |
价值 |
| 配置 |
有关配置的信息。 |
配置信息 |
分配报告
AssignmentReportResource
AssignmentReportResourceComplianceReason
配置信息
ConfigurationParameter
| 名字 |
描述 |
价值 |
| 名字 |
配置参数的名称。 |
字符串 |
| 价值 |
配置参数的值。 |
字符串 |
GuestConfigurationAssignmentProperties
GuestConfigurationNavigation
| 名字 |
描述 |
价值 |
| assignmentType |
指定配置分配类型和执行。 可能的值为 Audit、DeployAndAutoCorrect、ApplyAndAutoCorrect 和 ApplyAndMonitor。 |
“ApplyAndAutoCorrect” “ApplyAndMonitor” “Audit” “DeployAndAutoCorrect” |
| configurationParameter |
来宾配置的配置参数。 |
ConfigurationParameter[] |
| configurationProtectedParameter 的 |
来宾配置的受保护配置参数。 |
ConfigurationParameter[] |
| 内容哈希 |
来宾配置包和配置参数的组合哈希。 |
字符串 |
| contentManagedIdentity |
具有来宾配置包和配置参数存储访问权限的托管标识。 |
字符串 |
| contentUri 的 |
上传来宾配置包的存储的 URI。 |
字符串 |
| 类 |
来宾配置的种类。 例如:DSC |
“DSC” |
| 名字 |
来宾配置的名称。 |
字符串 |
| 版本 |
来宾配置的版本。 |
字符串 |
VMInfo
VmssvmInfo
用法示例
Azure 快速入门示例
以下 Azure 快速入门模板 包含用于部署此资源类型的 Bicep 示例。
| Bicep 文件 |
描述 |
|
SQL Server 2014 VM & IIS VM |
在 VNET 中创建 1 或 2 个 IIS Windows 2012 R2 Web 服务器和一个后端 SQL Server 2014。 |
| 使用 Azure 安全基线 Windows VM |
该模板使用公共 IP 地址在新虚拟网络中创建运行 Windows Server 的虚拟机。 部署计算机后,将安装来宾配置扩展,并应用 Windows Server 的 Azure 安全基线。 如果计算机配置偏移,可以通过再次部署模板来重新应用设置。 |
ARM 模板资源定义
可以使用目标操作部署 guestConfigurationAssignments 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
若要创建 Microsoft.GuestConfiguration/guestConfigurationAssignments 资源,请将以下 JSON 添加到模板。
{
"type": "Microsoft.GuestConfiguration/guestConfigurationAssignments",
"apiVersion": "2024-04-05",
"name": "string",
"location": "string",
"properties": {
"context": "string",
"guestConfiguration": {
"assignmentType": "string",
"configurationParameter": [
{
"name": "string",
"value": "string"
}
],
"configurationProtectedParameter": [
{
"name": "string",
"value": "string"
}
],
"contentHash": "string",
"contentManagedIdentity": "string",
"contentUri": "string",
"kind": "string",
"name": "string",
"version": "string"
},
"latestAssignmentReport": {
"assignment": {
"configuration": {
}
},
"resources": [
{
"reasons": [
{
}
]
}
],
"vm": {
}
},
"vmssVMList": [
{
}
]
}
}
属性值
Microsoft.GuestConfiguration/guestConfigurationAssignments
| 名字 |
描述 |
价值 |
| apiVersion |
API 版本 |
'2024-04-05' |
| 位置 |
VM 所在的区域。 |
字符串 |
| 名字 |
资源名称 |
string (必需) |
| 性能 |
来宾配置分配的属性。 |
GuestConfigurationAssignmentProperties |
| 类型 |
资源类型 |
“Microsoft.GuestConfiguration/guestConfigurationAssignments” |
作业信息
| 名字 |
描述 |
价值 |
| 配置 |
有关配置的信息。 |
配置信息 |
分配报告
AssignmentReportResource
AssignmentReportResourceComplianceReason
配置信息
ConfigurationParameter
| 名字 |
描述 |
价值 |
| 名字 |
配置参数的名称。 |
字符串 |
| 价值 |
配置参数的值。 |
字符串 |
GuestConfigurationAssignmentProperties
GuestConfigurationNavigation
| 名字 |
描述 |
价值 |
| assignmentType |
指定配置分配类型和执行。 可能的值为 Audit、DeployAndAutoCorrect、ApplyAndAutoCorrect 和 ApplyAndMonitor。 |
“ApplyAndAutoCorrect” “ApplyAndMonitor” “Audit” “DeployAndAutoCorrect” |
| configurationParameter |
来宾配置的配置参数。 |
ConfigurationParameter[] |
| configurationProtectedParameter 的 |
来宾配置的受保护配置参数。 |
ConfigurationParameter[] |
| 内容哈希 |
来宾配置包和配置参数的组合哈希。 |
字符串 |
| contentManagedIdentity |
具有来宾配置包和配置参数存储访问权限的托管标识。 |
字符串 |
| contentUri 的 |
上传来宾配置包的存储的 URI。 |
字符串 |
| 类 |
来宾配置的种类。 例如:DSC |
“DSC” |
| 名字 |
来宾配置的名称。 |
字符串 |
| 版本 |
来宾配置的版本。 |
字符串 |
VMInfo
VmssvmInfo
用法示例
Azure 快速入门模板
以下 Azure 快速入门模板 部署此资源类型。
| 模板 |
描述 |
SQL Server 2014 VM & IIS VM
|
在 VNET 中创建 1 或 2 个 IIS Windows 2012 R2 Web 服务器和一个后端 SQL Server 2014。 |
使用 Azure 安全基线 Windows VM
|
该模板使用公共 IP 地址在新虚拟网络中创建运行 Windows Server 的虚拟机。 部署计算机后,将安装来宾配置扩展,并应用 Windows Server 的 Azure 安全基线。 如果计算机配置偏移,可以通过再次部署模板来重新应用设置。 |
可以使用目标操作部署 guestConfigurationAssignments 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
若要创建 Microsoft.GuestConfiguration/guestConfigurationAssignments 资源,请将以下 Terraform 添加到模板。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.GuestConfiguration/guestConfigurationAssignments@2024-04-05"
name = "string"
parent_id = "string"
location = "string"
body = {
properties = {
context = "string"
guestConfiguration = {
assignmentType = "string"
configurationParameter = [
{
name = "string"
value = "string"
}
]
configurationProtectedParameter = [
{
name = "string"
value = "string"
}
]
contentHash = "string"
contentManagedIdentity = "string"
contentUri = "string"
kind = "string"
name = "string"
version = "string"
}
latestAssignmentReport = {
assignment = {
configuration = {
}
}
resources = [
{
reasons = [
{
}
]
}
]
vm = {
}
}
vmssVMList = [
{
}
]
}
}
}
属性值
Microsoft.GuestConfiguration/guestConfigurationAssignments
| 名字 |
描述 |
价值 |
| 位置 |
VM 所在的区域。 |
字符串 |
| 名字 |
资源名称 |
string (必需) |
| parent_id |
要向其应用此扩展资源的资源的 ID。 |
string (必需) |
| 性能 |
来宾配置分配的属性。 |
GuestConfigurationAssignmentProperties |
| 类型 |
资源类型 |
“Microsoft.GuestConfiguration/guestConfigurationAssignments@2024-04-05” |
作业信息
| 名字 |
描述 |
价值 |
| 配置 |
有关配置的信息。 |
配置信息 |
分配报告
AssignmentReportResource
AssignmentReportResourceComplianceReason
配置信息
ConfigurationParameter
| 名字 |
描述 |
价值 |
| 名字 |
配置参数的名称。 |
字符串 |
| 价值 |
配置参数的值。 |
字符串 |
GuestConfigurationAssignmentProperties
GuestConfigurationNavigation
| 名字 |
描述 |
价值 |
| assignmentType |
指定配置分配类型和执行。 可能的值为 Audit、DeployAndAutoCorrect、ApplyAndAutoCorrect 和 ApplyAndMonitor。 |
“ApplyAndAutoCorrect” “ApplyAndMonitor” “Audit” “DeployAndAutoCorrect” |
| configurationParameter |
来宾配置的配置参数。 |
ConfigurationParameter[] |
| configurationProtectedParameter 的 |
来宾配置的受保护配置参数。 |
ConfigurationParameter[] |
| 内容哈希 |
来宾配置包和配置参数的组合哈希。 |
字符串 |
| contentManagedIdentity |
具有来宾配置包和配置参数存储访问权限的托管标识。 |
字符串 |
| contentUri 的 |
上传来宾配置包的存储的 URI。 |
字符串 |
| 类 |
来宾配置的种类。 例如:DSC |
“DSC” |
| 名字 |
来宾配置的名称。 |
字符串 |
| 版本 |
来宾配置的版本。 |
字符串 |
VMInfo
VmssvmInfo
用法示例
部署的基本示例 将客户机配置策略应用于虚拟机。
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" "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 = "internal"
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 = "acctestvmdro23"
secrets = [
]
windowsConfiguration = {
enableAutomaticUpdates = true
patchSettings = {
assessmentMode = "ImageDefault"
enableHotpatching = false
patchMode = "AutomaticByOS"
}
provisionVMAgent = true
winRM = {
listeners = [
]
}
}
}
priority = "Regular"
storageProfile = {
dataDisks = [
]
imageReference = {
offer = "WindowsServer"
publisher = "MicrosoftWindowsServer"
sku = "2016-Datacenter"
version = "latest"
}
osDisk = {
caching = "ReadWrite"
createOption = "FromImage"
managedDisk = {
storageAccountType = "Standard_LRS"
}
osType = "Windows"
writeAcceleratorEnabled = false
}
}
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
resource "azapi_resource" "guestConfigurationAssignment" {
type = "Microsoft.GuestConfiguration/guestConfigurationAssignments@2020-06-25"
parent_id = azapi_resource.virtualMachine.id
name = "WhitelistedApplication"
location = var.location
body = {
properties = {
guestConfiguration = {
assignmentType = ""
configurationParameter = [
{
name = "[InstalledApplication]bwhitelistedapp;Name"
value = "NotePad,sql"
},
]
contentHash = ""
contentUri = ""
name = "WhitelistedApplication"
version = "1.*"
}
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}