Microsoft.GuestConfiguration guestConfigurationAssignments 2018-01-20-preview

Bicep resource definition

The guestConfigurationAssignments resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Usage Examples

Bicep Samples

A basic example of deploying Applies a Guest Configuration Policy to a Virtual Machine.

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

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 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: '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
      }
    }
  }
}

resource guestConfigurationAssignment 'Microsoft.GuestConfiguration/guestConfigurationAssignments@2020-06-25' = {
  name: 'WhitelistedApplication'
  location: location
  scope: virtualMachine
  properties: {
    guestConfiguration: {
      assignmentType: ''
      configurationParameter: [
        {
          name: /* ERROR: Unparsed HCL syntax in LiteralNode */ {}
          value: 'NotePad,sql'
        }
      ]
      contentHash: ''
      contentUri: ''
      name: 'WhitelistedApplication'
      version: '1.*'
    }
  }
}

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

Azure Quickstart Samples

The following Azure Quickstart templates contain Bicep samples for deploying this resource type.

Bicep File Description
IIS VMs & SQL Server 2014 VM Create 1 or 2 IIS Windows 2012 R2 Web Servers and one back end SQL Server 2014 in VNET.
Windows VM with Azure secure baseline The template creates a virtual machine running Windows Server in a new virtual network, with a public IP address. Once the machine has deployed, the guest configuration extension is installed and the Azure secure baseline for Windows Server is applied. If the configuration of the machines drifts, you can re-apply the settings by deploying the template again.

Resource format

To create a Microsoft.GuestConfiguration/guestConfigurationAssignments resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.GuestConfiguration/guestConfigurationAssignments@2018-01-20-preview' = {
  scope: resourceSymbolicName or scope
  location: 'string'
  name: 'string'
  properties: {
    guestConfiguration: {
      configurationParameter: {
        value: [
          {}
        ]
      }
      kind: 'string'
      name: 'string'
      type: 'string'
    }
  }
}

Property Values

Microsoft.GuestConfiguration/guestConfigurationAssignments

Name Description Value
location Region where the VM is located. string
name The resource name string (required)
properties Properties of the Guest configuration assignment. GuestConfigurationAssignmentProperties
scope Use when creating a resource at a scope that is different than the deployment scope. Set this property to the symbolic name of a resource to apply the extension resource.

ConfigurationParameter

Name Description Value

ConfigurationParameterList

Name Description Value
value Represents the list for configuration parameters. ConfigurationParameter[]

GuestConfigurationAssignmentProperties

Name Description Value
guestConfiguration The guest configuration to assign. GuestConfigurationNavigation

GuestConfigurationNavigation

Name Description Value
configurationParameter The configuration parameters for the guest configuration. ConfigurationParameterList
kind Kind of the guest configuration. For example:DSC 'DSC'
name Name of the guest configuration. string
type Type of the guest configuration. string

ARM template resource definition

The guestConfigurationAssignments resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Usage Examples

Azure Quickstart Templates

The following Azure Quickstart templates deploy this resource type.

Template Description
IIS VMs & SQL Server 2014 VM

Deploy to Azure
Create 1 or 2 IIS Windows 2012 R2 Web Servers and one back end SQL Server 2014 in VNET.
Windows VM with Azure secure baseline

Deploy to Azure
The template creates a virtual machine running Windows Server in a new virtual network, with a public IP address. Once the machine has deployed, the guest configuration extension is installed and the Azure secure baseline for Windows Server is applied. If the configuration of the machines drifts, you can re-apply the settings by deploying the template again.

Resource format

To create a Microsoft.GuestConfiguration/guestConfigurationAssignments resource, add the following JSON to your template.

{
  "type": "Microsoft.GuestConfiguration/guestConfigurationAssignments",
  "apiVersion": "2018-01-20-preview",
  "name": "string",
  "location": "string",
  "properties": {
    "guestConfiguration": {
      "configurationParameter": {
        "value": [
          {
          }
        ]
      },
      "kind": "string",
      "name": "string",
      "type": "string"
    }
  }
}

Property Values

Microsoft.GuestConfiguration/guestConfigurationAssignments

Name Description Value
apiVersion The api version '2018-01-20-preview'
location Region where the VM is located. string
name The resource name string (required)
properties Properties of the Guest configuration assignment. GuestConfigurationAssignmentProperties
type The resource type 'Microsoft.GuestConfiguration/guestConfigurationAssignments'

ConfigurationParameter

Name Description Value

ConfigurationParameterList

Name Description Value
value Represents the list for configuration parameters. ConfigurationParameter[]

GuestConfigurationAssignmentProperties

Name Description Value
guestConfiguration The guest configuration to assign. GuestConfigurationNavigation

GuestConfigurationNavigation

Name Description Value
configurationParameter The configuration parameters for the guest configuration. ConfigurationParameterList
kind Kind of the guest configuration. For example:DSC 'DSC'
name Name of the guest configuration. string
type Type of the guest configuration. string

Terraform (AzAPI provider) resource definition

The guestConfigurationAssignments resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Usage Examples

Terraform Samples

A basic example of deploying Applies a Guest Configuration Policy to a Virtual Machine.

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    = ["*"]
}

Resource format

To create a Microsoft.GuestConfiguration/guestConfigurationAssignments resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.GuestConfiguration/guestConfigurationAssignments@2018-01-20-preview"
  name = "string"
  parent_id = "string"
  location = "string"
  body = {
    properties = {
      guestConfiguration = {
        configurationParameter = {
          value = [
            {
            }
          ]
        }
        kind = "string"
        name = "string"
        type = "string"
      }
    }
  }
}

Property Values

Microsoft.GuestConfiguration/guestConfigurationAssignments

Name Description Value
location Region where the VM is located. string
name The resource name string (required)
parent_id The ID of the resource to apply this extension resource to. string (required)
properties Properties of the Guest configuration assignment. GuestConfigurationAssignmentProperties
type The resource type "Microsoft.GuestConfiguration/guestConfigurationAssignments@2018-01-20-preview"

ConfigurationParameter

Name Description Value

ConfigurationParameterList

Name Description Value
value Represents the list for configuration parameters. ConfigurationParameter[]

GuestConfigurationAssignmentProperties

Name Description Value
guestConfiguration The guest configuration to assign. GuestConfigurationNavigation

GuestConfigurationNavigation

Name Description Value
configurationParameter The configuration parameters for the guest configuration. ConfigurationParameterList
kind Kind of the guest configuration. For example:DSC 'DSC'
name Name of the guest configuration. string
type Type of the guest configuration. string