You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next, define two parameters, `adminUsername` and `adminPassword`. Parameters are values you specify at the time of deployment. The `adminUsername` parameter is simply a `string` type, but because `adminPassword` is a secret, give it type `securestring`. Later, these parameters are passed into the scale set configuration.
33
35
34
36
```json
@@ -41,7 +43,9 @@ Next, define two parameters, `adminUsername` and `adminPassword`. Parameters are
41
43
}
42
44
},
43
45
```
46
+
44
47
## Define variables
48
+
45
49
Resource Manager templates also let you define variables to be used later in the template. The example doesn't use any variables, so the JSON object is empty.
46
50
47
51
```json
@@ -52,7 +56,9 @@ Resource Manager templates also let you define variables to be used later in the
52
56
Next is the resources section of the template. Here, you define what you actually want to deploy. Unlike `parameters` and `variables` (which are JSON objects), `resources` is a JSON list of JSON objects.
53
57
54
58
```json
55
-
"resources": [
59
+
"resources": [
60
+
...
61
+
]
56
62
```
57
63
58
64
All resources require `type`, `name`, `apiVersion`, and `location` properties. This example's first resource has type [Microsoft.Network/virtualNetwork](/azure/templates/microsoft.network/virtualnetworks), name `myVnet`, and apiVersion `2018-11-01`. (To find the latest API version for a resource type, see the [Azure Resource Manager template reference](/azure/templates/).)
@@ -66,13 +72,15 @@ All resources require `type`, `name`, `apiVersion`, and `location` properties. T
66
72
```
67
73
68
74
## Specify location
75
+
69
76
To specify the location for the virtual network, use a [Resource Manager template function](../azure-resource-manager/templates/template-functions.md). This function must be enclosed in quotes and square brackets like this: `"[<template-function>]"`. In this case, use the `resourceGroup` function. It takes in no arguments and returns a JSON object with metadata about the resource group this deployment is being deployed to. The resource group is set by the user at the time of deployment. This value is then indexed into this JSON object with `.location` to get the location from the JSON object.
70
77
71
78
```json
72
79
"location": "[resourceGroup().location]",
73
80
```
74
81
75
82
## Specify virtual network properties
83
+
76
84
Each Resource Manager resource has its own `properties` section for configurations specific to the resource. In this case, specify that the virtual network should have one subnet using the private IP address range `10.0.0.0/16`. A scale set is always contained within one subnet. It cannot span subnets.
77
85
78
86
```json
@@ -96,6 +104,7 @@ Each Resource Manager resource has its own `properties` section for configuratio
96
104
```
97
105
98
106
## Add dependsOn list
107
+
99
108
In addition to the required `type`, `name`, `apiVersion`, and `location` properties, each resource can have an optional `dependsOn` list of strings. This list specifies which other resources from this deployment must finish before deploying this resource.
100
109
101
110
In this case, there is only one element in the list, the virtual network from the previous example. You specify this dependency because the scale set needs the network to exist before creating any VMs. This way, the scale set can give these VMs private IP addresses from the IP address range previously specified in the network properties. The format of each string in the dependsOn list is `<type>/<name>`. Use the same `type` and `name` used previously in the virtual network resource definition.
@@ -116,7 +125,9 @@ In this case, there is only one element in the list, the virtual network from th
116
125
## Specify scale set properties
117
126
118
127
Scale sets have many properties for customizing the VMs in the scale set. For a full list of these properties, see the [template reference](/azure/templates/microsoft.compute/virtualmachinescalesets). For this tutorial, only a few commonly used properties are set.
128
+
119
129
### Supply VM size and capacity
130
+
120
131
The scale set needs to know what size of VM to create ("sku name") and how many such VMs to create ("sku capacity"). To see which VM sizes are available, see the [VM Sizes documentation](../virtual-machines/sizes.md).
121
132
122
133
```json
@@ -127,6 +138,7 @@ The scale set needs to know what size of VM to create ("sku name") and how many
127
138
```
128
139
129
140
### Choose type of updates
141
+
130
142
The scale set also needs to know how to handle updates on the scale set. Currently, there are three options, `Manual`, `Rolling` and `Automatic`. For more information on the differences between the two, see the documentation on [how to upgrade a scale set](./virtual-machine-scale-sets-upgrade-policy.md).
131
143
132
144
```json
@@ -138,6 +150,7 @@ The scale set also needs to know how to handle updates on the scale set. Current
138
150
```
139
151
140
152
### Choose VM operating system
153
+
141
154
The scale set needs to know what operating system to put on the VMs. Here, create the VMs with a fully patched Ubuntu 16.04-LTS image.
142
155
143
156
```json
@@ -150,9 +163,11 @@ The scale set needs to know what operating system to put on the VMs. Here, creat
150
163
"version": "latest"
151
164
}
152
165
},
166
+
}
153
167
```
154
168
155
169
### Specify computerNamePrefix
170
+
156
171
The scale set deploys multiple VMs. Instead of specifying each VM name, specify `computerNamePrefix`. The scale set appends an index to the prefix for each VM, so VM names have the form `<computerNamePrefix>_<auto-generated-index>`.
157
172
158
173
In the following snippet, use the parameters from before to set the administrator username and password for all VMs in the scale set. This process uses the `parameters` template function. This function takes in a string that specifies which parameter to refer to and outputs the value for that parameter.
@@ -173,32 +188,26 @@ You can get the ID of the virtual network containing the subnet by using the `re
173
188
However, the identifier of the virtual network is not enough. Provide the specific subnet that the scale set VMs should be in. To do this, concatenate `/subnets/mySubnet` to the ID of the virtual network. The result is the fully qualified ID of the subnet. Do this concatenation with the `concat` function, which takes in a series of strings and returns their concatenation.
0 commit comments