-
Notifications
You must be signed in to change notification settings - Fork 2
VM Template
The VM template object allows you to specify the configuration to deploy 1 or more VMs. This is where you can state how many of a VM type you require, what provisioners to use, firewall rules to create, as well as the OS type (unless defined globally).
All VM templates are defined within the "template" array at the root of the JSON template file, and requires a "type" value of "vm":
{
"template": [
{
"type": "vm"
}
]
}Below are the properties that are used in defining the VM template object
| Name | Type | Required | Description |
|---|---|---|---|
| count | int | yes | The number of VMs to deploy for the template; must be greater than or equal to 1 |
| firewall | firewall object | no | The local inbound/outbound firewall rules for the current VM template |
| os | OS object | no (when global os object defined) |
The local OS object for this VM template. Note: not required if a global OS object is present and appropriate |
| port | int | no | The port the VMs are to be load balancer against. Note: Only required if count > 1 and useLoadBalancer is true or not supplied |
| provisioners | string array | no | A string array of provisioner keys, that will be run in order given to provisioner each VM |
| tag | string | yes | The tag-name of this VM template. ie, if core then VMs deployed will have the name [rg-name]-core[index]
|
| useAvailabilitySet | boolean | no |
Default: true. Whether or not the VMs should be placed into an Availability Set |
| type | string | yes | Specifies the type of template object, can be either vmor vpn
|
| useLoadBalancer | boolean | no |
Default: true. Whether or not the VMs should be load balanced |
| usePublicIP | boolean | no | Whether or not the VMs should have a public IP address |
The following are a couple of simple examples of VM templates.
The following VM template will deploy 1 VM, with remoting enabled and the RDP port open. It will also have a public IP address.
If you want more than 1 VM, just increase the count value!
{
"template": [
{
"type": "vm",
"tag": "example",
"count": 1,
"usePublicIP": true,
"provisioners": [ "remoting" ],
"os": {
"size": "Standard_DS1_v2",
"type": "Windows",
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"skus": "2016-Datacenter"
},
"firewall": {
"rdp|in": true
}
}
],
"provisioners": {
"remoting": "dsc: @{remoting}"
}
}The following VM template will deploy 3 VMs. They will all have IIS and .NET installed, with the HTTP port allowed outbound. All of the VMs will also be automatically load balanced for you.
Remember: when load balancing the
"port"property is required
{
"template": [
{
"type": "vm",
"tag": "web",
"count": 3,
"port": 80,
"usePublicIP": true,
"provisioners": [ "web-server" ],
"os": {
"size": "Standard_DS1_v2",
"type": "Windows",
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"skus": "2016-Datacenter"
},
"firewall": {
"http|out": true
}
}
],
"provisioners": {
"web-server": "dsc: @{web-server}"
}
}Try navigating to
http://<public-ip>, and you'll see the default IIS webpage