|
| 1 | +--- |
| 2 | +title: Create the Resource Manager template |
| 3 | +weight: 3 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +## Azure Resource Manager template structure |
| 10 | + |
| 11 | +An Azure Resource Manager template consists of several key sections: |
| 12 | + |
| 13 | +- **$schema**: Defines the template language version |
| 14 | +- **contentVersion**: Your template's version number |
| 15 | +- **parameters**: Input values that customize the deployment |
| 16 | +- **variables**: Computed values used throughout the template |
| 17 | +- **resources**: Azure resources to create |
| 18 | +- **outputs**: Values returned after deployment |
| 19 | + |
| 20 | +## Create the template file |
| 21 | + |
| 22 | +Create a new file named `cobalt-vm-template.json` on your local machine. This template deploys a Cobalt 100 VM with all necessary networking components. |
| 23 | + |
| 24 | +```json |
| 25 | +{ |
| 26 | + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
| 27 | + "contentVersion": "1.0.0.0", |
| 28 | + "parameters": { |
| 29 | + "projectName": { |
| 30 | + "type": "string", |
| 31 | + "metadata": { |
| 32 | + "description": "Prefix for resource names" |
| 33 | + } |
| 34 | + }, |
| 35 | + "location": { |
| 36 | + "type": "string", |
| 37 | + "defaultValue": "[resourceGroup().location]", |
| 38 | + "metadata": { |
| 39 | + "description": "Azure region for resources" |
| 40 | + } |
| 41 | + }, |
| 42 | + "adminUsername": { |
| 43 | + "type": "string", |
| 44 | + "metadata": { |
| 45 | + "description": "Admin username for the VM" |
| 46 | + } |
| 47 | + }, |
| 48 | + "adminPublicKey": { |
| 49 | + "type": "string", |
| 50 | + "metadata": { |
| 51 | + "description": "SSH public key for authentication" |
| 52 | + } |
| 53 | + }, |
| 54 | + "vmSize": { |
| 55 | + "type": "string", |
| 56 | + "defaultValue": "Standard_D4ps_v6", |
| 57 | + "metadata": { |
| 58 | + "description": "Cobalt 100 VM size (Dpsv6 series)" |
| 59 | + } |
| 60 | + } |
| 61 | + }, |
| 62 | + "variables": { |
| 63 | + "vNetName": "[concat(parameters('projectName'), '-vnet')]", |
| 64 | + "vNetAddressPrefixes": "10.0.0.0/16", |
| 65 | + "vNetSubnetName": "default", |
| 66 | + "vNetSubnetAddressPrefix": "10.0.0.0/24", |
| 67 | + "vmName": "[concat(parameters('projectName'), '-vm')]", |
| 68 | + "publicIPAddressName": "[concat(parameters('projectName'), '-ip')]", |
| 69 | + "networkInterfaceName": "[concat(parameters('projectName'), '-nic')]", |
| 70 | + "networkSecurityGroupName": "[concat(parameters('projectName'), '-nsg')]", |
| 71 | + "networkSecurityGroupName2": "[concat(variables('vNetSubnetName'), '-nsg')]" |
| 72 | + }, |
| 73 | + "resources": [ |
| 74 | + { |
| 75 | + "type": "Microsoft.Network/networkSecurityGroups", |
| 76 | + "apiVersion": "2023-04-01", |
| 77 | + "name": "[variables('networkSecurityGroupName')]", |
| 78 | + "location": "[parameters('location')]", |
| 79 | + "properties": { |
| 80 | + "securityRules": [ |
| 81 | + { |
| 82 | + "name": "ssh_rule", |
| 83 | + "properties": { |
| 84 | + "description": "Allow SSH access", |
| 85 | + "protocol": "Tcp", |
| 86 | + "sourcePortRange": "*", |
| 87 | + "destinationPortRange": "22", |
| 88 | + "sourceAddressPrefix": "*", |
| 89 | + "destinationAddressPrefix": "*", |
| 90 | + "access": "Allow", |
| 91 | + "priority": 100, |
| 92 | + "direction": "Inbound" |
| 93 | + } |
| 94 | + } |
| 95 | + ] |
| 96 | + } |
| 97 | + }, |
| 98 | + { |
| 99 | + "type": "Microsoft.Network/publicIPAddresses", |
| 100 | + "apiVersion": "2023-04-01", |
| 101 | + "name": "[variables('publicIPAddressName')]", |
| 102 | + "location": "[parameters('location')]", |
| 103 | + "properties": { |
| 104 | + "publicIPAllocationMethod": "Dynamic" |
| 105 | + }, |
| 106 | + "sku": { |
| 107 | + "name": "Basic" |
| 108 | + } |
| 109 | + }, |
| 110 | + { |
| 111 | + "type": "Microsoft.Network/networkSecurityGroups", |
| 112 | + "apiVersion": "2023-04-01", |
| 113 | + "name": "[variables('networkSecurityGroupName2')]", |
| 114 | + "location": "[parameters('location')]", |
| 115 | + "properties": { |
| 116 | + "securityRules": [ |
| 117 | + { |
| 118 | + "name": "default-allow-ssh", |
| 119 | + "properties": { |
| 120 | + "priority": 100, |
| 121 | + "access": "Allow", |
| 122 | + "direction": "Inbound", |
| 123 | + "destinationPortRange": "22", |
| 124 | + "protocol": "Tcp", |
| 125 | + "sourceAddressPrefix": "*", |
| 126 | + "sourcePortRange": "*", |
| 127 | + "destinationAddressPrefix": "*" |
| 128 | + } |
| 129 | + } |
| 130 | + ] |
| 131 | + } |
| 132 | + }, |
| 133 | + { |
| 134 | + "type": "Microsoft.Network/virtualNetworks", |
| 135 | + "apiVersion": "2023-04-01", |
| 136 | + "name": "[variables('vNetName')]", |
| 137 | + "location": "[parameters('location')]", |
| 138 | + "dependsOn": [ |
| 139 | + "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName2'))]" |
| 140 | + ], |
| 141 | + "properties": { |
| 142 | + "addressSpace": { |
| 143 | + "addressPrefixes": [ |
| 144 | + "[variables('vNetAddressPrefixes')]" |
| 145 | + ] |
| 146 | + }, |
| 147 | + "subnets": [ |
| 148 | + { |
| 149 | + "name": "[variables('vNetSubnetName')]", |
| 150 | + "properties": { |
| 151 | + "addressPrefix": "[variables('vNetSubnetAddressPrefix')]", |
| 152 | + "networkSecurityGroup": { |
| 153 | + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName2'))]" |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | + ] |
| 158 | + } |
| 159 | + }, |
| 160 | + { |
| 161 | + "type": "Microsoft.Network/networkInterfaces", |
| 162 | + "apiVersion": "2023-04-01", |
| 163 | + "name": "[variables('networkInterfaceName')]", |
| 164 | + "location": "[parameters('location')]", |
| 165 | + "dependsOn": [ |
| 166 | + "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]", |
| 167 | + "[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]", |
| 168 | + "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" |
| 169 | + ], |
| 170 | + "properties": { |
| 171 | + "ipConfigurations": [ |
| 172 | + { |
| 173 | + "name": "ipconfig1", |
| 174 | + "properties": { |
| 175 | + "privateIPAllocationMethod": "Dynamic", |
| 176 | + "publicIPAddress": { |
| 177 | + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" |
| 178 | + }, |
| 179 | + "subnet": { |
| 180 | + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vNetName'), variables('vNetSubnetName'))]" |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + ], |
| 185 | + "networkSecurityGroup": { |
| 186 | + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" |
| 187 | + } |
| 188 | + } |
| 189 | + }, |
| 190 | + { |
| 191 | + "type": "Microsoft.Compute/virtualMachines", |
| 192 | + "apiVersion": "2023-03-01", |
| 193 | + "name": "[variables('vmName')]", |
| 194 | + "location": "[parameters('location')]", |
| 195 | + "dependsOn": [ |
| 196 | + "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]" |
| 197 | + ], |
| 198 | + "properties": { |
| 199 | + "hardwareProfile": { |
| 200 | + "vmSize": "[parameters('vmSize')]" |
| 201 | + }, |
| 202 | + "osProfile": { |
| 203 | + "computerName": "[variables('vmName')]", |
| 204 | + "adminUsername": "[parameters('adminUsername')]", |
| 205 | + "linuxConfiguration": { |
| 206 | + "disablePasswordAuthentication": true, |
| 207 | + "ssh": { |
| 208 | + "publicKeys": [ |
| 209 | + { |
| 210 | + "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", |
| 211 | + "keyData": "[parameters('adminPublicKey')]" |
| 212 | + } |
| 213 | + ] |
| 214 | + } |
| 215 | + } |
| 216 | + }, |
| 217 | + "storageProfile": { |
| 218 | + "imageReference": { |
| 219 | + "publisher": "Canonical", |
| 220 | + "offer": "ubuntu-24_04-lts", |
| 221 | + "sku": "server-arm64", |
| 222 | + "version": "latest" |
| 223 | + }, |
| 224 | + "osDisk": { |
| 225 | + "createOption": "FromImage", |
| 226 | + "managedDisk": { |
| 227 | + "storageAccountType": "Premium_LRS" |
| 228 | + } |
| 229 | + } |
| 230 | + }, |
| 231 | + "networkProfile": { |
| 232 | + "networkInterfaces": [ |
| 233 | + { |
| 234 | + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]" |
| 235 | + } |
| 236 | + ] |
| 237 | + } |
| 238 | + } |
| 239 | + } |
| 240 | + ], |
| 241 | + "outputs": { |
| 242 | + "vmName": { |
| 243 | + "type": "string", |
| 244 | + "value": "[variables('vmName')]" |
| 245 | + }, |
| 246 | + "resourceGroup": { |
| 247 | + "type": "string", |
| 248 | + "value": "[resourceGroup().name]" |
| 249 | + } |
| 250 | + } |
| 251 | +} |
| 252 | +``` |
| 253 | + |
| 254 | +## Key template elements for Cobalt 100 |
| 255 | + |
| 256 | +The template includes several Arm-specific configurations: |
| 257 | + |
| 258 | +**VM size**: The `vmSize` parameter defaults to `Standard_D4ps_v6`, which is part of the Dpsv6 series powered by Cobalt 100 processors. This series provides: |
| 259 | +- Four vCPUs |
| 260 | +- General-purpose compute capabilities |
| 261 | +- Arm64 architecture |
| 262 | + |
| 263 | +Other Cobalt 100 VM sizes include: |
| 264 | +- `Standard_D2ps_v6` (2 vCPUs) |
| 265 | +- `Standard_D8ps_v6` (8 vCPUs) |
| 266 | +- `Standard_D16ps_v6` (16 vCPUs) |
| 267 | + |
| 268 | +**Image reference**: The `storageProfile` section specifies the operating system image with Arm64 architecture. You can choose from various Arm64-compatible Linux distributions available in Azure. The template uses Ubuntu 24.04 LTS: |
| 269 | + |
| 270 | +```json |
| 271 | +"imageReference": { |
| 272 | + "publisher": "Canonical", |
| 273 | + "offer": "ubuntu-24_04-lts", |
| 274 | + "sku": "server-arm64", |
| 275 | + "version": "latest" |
| 276 | +} |
| 277 | +``` |
| 278 | + |
| 279 | +You can change the Arm64 image used in the `imageReference` section, for example: |
| 280 | +for Ubuntu 22.04 LTS: |
| 281 | +```json |
| 282 | +"imageReference": { |
| 283 | + "publisher": "Canonical", |
| 284 | + "offer": "0001-com-ubuntu-server-jammy", |
| 285 | + "sku": "22_04-lts-arm64", |
| 286 | + "version": "latest" |
| 287 | +} |
| 288 | +``` |
| 289 | + |
| 290 | +To find available Arm64 images for other Linux distributions, use: |
| 291 | +```bash |
| 292 | +az vm image list --all --architecture Arm64 --output table |
| 293 | +``` |
| 294 | + |
| 295 | +**SSH authentication**: The template configures SSH key authentication and disables password authentication for enhanced security: |
| 296 | + |
| 297 | +```json |
| 298 | +"linuxConfiguration": { |
| 299 | + "disablePasswordAuthentication": true, |
| 300 | + "ssh": { |
| 301 | + "publicKeys": [ |
| 302 | + { |
| 303 | + "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", |
| 304 | + "keyData": "[parameters('adminPublicKey')]" |
| 305 | + } |
| 306 | + ] |
| 307 | + } |
| 308 | +} |
| 309 | +``` |
| 310 | + |
| 311 | +## What you've accomplished and what's next |
| 312 | + |
| 313 | +You've created a complete Resource Manager template that defines the network infrastructure (virtual network, subnet, and network security groups), a public IP address for external access, a network interface, a Cobalt 100 VM with Ubuntu 24.04 LTS, and SSH key authentication for secure access. The template uses parameters for flexibility, allowing you to customize the deployment without modifying the template structure. In the next section, you'll deploy this template to Azure and connect to your new Cobalt 100 VM. |
0 commit comments