|
| 1 | +{ |
| 2 | + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 3 | + "contentVersion": "1.0.0.0", |
| 4 | + "parameters": { |
| 5 | + "VMName": { |
| 6 | + "type": "string", |
| 7 | + "metadata": { |
| 8 | + "description": "VM Name and convention your company uses, be sure to entice naming EX. vm-fileshares-prod-eastus-003" |
| 9 | + }, |
| 10 | + "defaultValue": "vm-fileshares-prod-eastus-003" |
| 11 | + }, |
| 12 | + "virtualNetworkId": { |
| 13 | + "type": "string", |
| 14 | + "metadata": { |
| 15 | + "description": "Virtual Network Resource ID to Deploy Azure VM into" |
| 16 | + }, |
| 17 | + "defaultValue": "/subscriptions/{SUBID}/resourceGroups/{RG NAME}/providers/Microsoft.Network/virtualNetworks/{VNET NAME}" |
| 18 | + }, |
| 19 | + "subnetName": { |
| 20 | + "type": "string", |
| 21 | + "metadata": { |
| 22 | + "description": "Virtual Network Subnet Name to Deploy Azure VM into" |
| 23 | + } |
| 24 | + }, |
| 25 | + "MyConnectionIP": { |
| 26 | + "type": "string", |
| 27 | + "minLength": 7, |
| 28 | + "maxLength": 15, |
| 29 | + "metadata": { |
| 30 | + "description": "The Public IP I will be connecting from to administer and configure" |
| 31 | + }, |
| 32 | + "defaultValue": "XXX.XXX.XXX.XXX" |
| 33 | + }, |
| 34 | + "adminUsername": { |
| 35 | + "type": "string", |
| 36 | + "minLength": 1, |
| 37 | + "defaultValue": "webuser", |
| 38 | + "metadata": { |
| 39 | + "description": "Admin user name for Linux VM" |
| 40 | + } |
| 41 | + }, |
| 42 | + "authenticationType": { |
| 43 | + "type": "string", |
| 44 | + "defaultValue": "password", |
| 45 | + "allowedValues": [ |
| 46 | + "sshPublicKey", |
| 47 | + "password" |
| 48 | + ], |
| 49 | + "metadata": { |
| 50 | + "description": "Type of authentication to use on the Virtual Machine. SSH key is recommended." |
| 51 | + } |
| 52 | + }, |
| 53 | + "adminPasswordOrKey": { |
| 54 | + "type": "securestring", |
| 55 | + "metadata": { |
| 56 | + "description": "SSH Key or password for the Virtual Machine. SSH key is recommended." |
| 57 | + } |
| 58 | + }, |
| 59 | + "CloudInitB64Encoded": { |
| 60 | + "type": "securestring", |
| 61 | + "metadata": { |
| 62 | + "description": "Cloud Init Configuration as a Base 64 encoded string, decode to examine a few variables to change and encode and submit" |
| 63 | + }, |
| 64 | + "defaultValue": "I2Nsb3VkLWNvbmZpZwp0aW1lem9uZTogVVMvRWFzdGVybgoKcGFja2FnZXM6CiAgLSBnaXQKCnJ1bmNtZDoKICAtIGN1cmwgLXNTIC0tcmV0cnkgNSBodHRwczovL2dpdGh1Yi5jb20KICAtIGdpdCBjbG9uZSBodHRwczovL2dpdGh1Yi5jb20vdGVsZWtvbS1zZWN1cml0eS90cG90Y2UgL3Jvb3QvdHBvdAogIC0gL3Jvb3QvdHBvdC9pc28vaW5zdGFsbGVyL2luc3RhbGwuc2ggLS10eXBlPWF1dG8gLS1jb25mPS9yb290L3Rwb3QuY29uZgogIC0gcm0gL3Jvb3QvdHBvdC5jb25mCiAgLSAvc2Jpbi9zaHV0ZG93biAtciBub3cKCnBhc3N3b3JkOiB3M2IkZWNyZXRzMiEKY2hwYXNzd2Q6CiAgZXhwaXJlOiBmYWxzZQoKd3JpdGVfZmlsZXM6CiAgLSBjb250ZW50OiB8CiAgICAgICMgdHBvdCBjb25maWd1cmF0aW9uIGZpbGUKICAgICAgbXlDT05GX1RQT1RfRkxBVk9SPSdTVEFOREFSRCcKICAgICAgbXlDT05GX1dFQl9VU0VSPSd3ZWJ1c2VyJwogICAgICBteUNPTkZfV0VCX1BXPSd3M2IkZWNyZXRzMiEnCiAgICBvd25lcjogcm9vdDpyb290CiAgICBwYXRoOiAvcm9vdC90cG90LmNvbmYKICAgIHBlcm1pc3Npb25zOiAnMDYwMCc=" |
| 65 | + } |
| 66 | + }, |
| 67 | + "variables": { |
| 68 | + "vnetId": "[parameters('virtualNetworkId')]", |
| 69 | + "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]", |
| 70 | + "linuxConfiguration": { |
| 71 | + "disablePasswordAuthentication": true, |
| 72 | + "ssh": { |
| 73 | + "publicKeys": [ |
| 74 | + { |
| 75 | + "path": "[format('/home/{0}/.ssh/authorized_keys', parameters('adminUsername'))]", |
| 76 | + "keyData": "[parameters('adminPasswordOrKey')]" |
| 77 | + } |
| 78 | + ] |
| 79 | + } |
| 80 | + } |
| 81 | + }, |
| 82 | + "resources": [ |
| 83 | + { |
| 84 | + "name": "[concat(uniqueString(resourceGroup().id, deployment().name),'-nic')]", |
| 85 | + "type": "Microsoft.Network/networkInterfaces", |
| 86 | + "apiVersion": "2021-08-01", |
| 87 | + "location": "[resourceGroup().location]", |
| 88 | + "dependsOn": [ |
| 89 | + "[resourceId('Microsoft.Network/networkSecurityGroups/', concat(uniqueString(resourceGroup().id, deployment().name),'-nsg'))]", |
| 90 | + "[resourceId('Microsoft.Network/publicIpAddresses', concat(uniqueString(resourceGroup().id, deployment().name),'-pip'))]" |
| 91 | + ], |
| 92 | + "properties": { |
| 93 | + "ipConfigurations": [ |
| 94 | + { |
| 95 | + "name": "ipconfig1", |
| 96 | + "properties": { |
| 97 | + "subnet": { |
| 98 | + "id": "[variables('subnetRef')]" |
| 99 | + }, |
| 100 | + "privateIPAllocationMethod": "Dynamic", |
| 101 | + "publicIpAddress": { |
| 102 | + "id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', concat(uniqueString(resourceGroup().id, deployment().name),'-pip'))]", |
| 103 | + "properties": { |
| 104 | + "deleteOption": "Detach" |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + ], |
| 110 | + "enableAcceleratedNetworking": true, |
| 111 | + "networkSecurityGroup": { |
| 112 | + "id": "[resourceId('Microsoft.Network/networkSecurityGroups/', concat(uniqueString(resourceGroup().id, deployment().name),'-nsg'))]" |
| 113 | + } |
| 114 | + } |
| 115 | + }, |
| 116 | + { |
| 117 | + "name": "[concat(uniqueString(resourceGroup().id, deployment().name),'-nsg')]", |
| 118 | + "type": "Microsoft.Network/networkSecurityGroups", |
| 119 | + "apiVersion": "2019-02-01", |
| 120 | + "location": "[resourceGroup().location]", |
| 121 | + "properties": { |
| 122 | + "securityRules": [ |
| 123 | + { |
| 124 | + "name": "AllowAzureCloud22Inbound", |
| 125 | + "properties": { |
| 126 | + "protocol": "*", |
| 127 | + "sourcePortRange": "*", |
| 128 | + "destinationPortRange": "22", |
| 129 | + "sourceAddressPrefix": "AzureCloud", |
| 130 | + "destinationAddressPrefix": "*", |
| 131 | + "access": "Allow", |
| 132 | + "priority": 1011, |
| 133 | + "direction": "Inbound", |
| 134 | + "sourcePortRanges": [], |
| 135 | + "destinationPortRanges": [], |
| 136 | + "sourceAddressPrefixes": [], |
| 137 | + "destinationAddressPrefixes": [] |
| 138 | + } |
| 139 | + }, |
| 140 | + { |
| 141 | + "name": "AllowCustom64294Inbound", |
| 142 | + "properties": { |
| 143 | + "protocol": "*", |
| 144 | + "sourcePortRange": "*", |
| 145 | + "destinationPortRange": "64294", |
| 146 | + "sourceAddressPrefix": "[parameters('MyConnectionIP')]", |
| 147 | + "destinationAddressPrefix": "*", |
| 148 | + "access": "Allow", |
| 149 | + "priority": 1021, |
| 150 | + "direction": "Inbound", |
| 151 | + "sourcePortRanges": [], |
| 152 | + "destinationPortRanges": [], |
| 153 | + "sourceAddressPrefixes": [], |
| 154 | + "destinationAddressPrefixes": [] |
| 155 | + } |
| 156 | + }, |
| 157 | + { |
| 158 | + "name": "AllowSSHCustom64295Inbound", |
| 159 | + "properties": { |
| 160 | + "protocol": "*", |
| 161 | + "sourcePortRange": "*", |
| 162 | + "destinationPortRange": "64295", |
| 163 | + "sourceAddressPrefix": "[parameters('MyConnectionIP')]", |
| 164 | + "destinationAddressPrefix": "*", |
| 165 | + "access": "Allow", |
| 166 | + "priority": 1031, |
| 167 | + "direction": "Inbound", |
| 168 | + "sourcePortRanges": [], |
| 169 | + "destinationPortRanges": [], |
| 170 | + "sourceAddressPrefixes": [], |
| 171 | + "destinationAddressPrefixes": [] |
| 172 | + } |
| 173 | + }, |
| 174 | + { |
| 175 | + "name": "AllowAzureCloud64295Inbound", |
| 176 | + "properties": { |
| 177 | + "protocol": "*", |
| 178 | + "sourcePortRange": "*", |
| 179 | + "destinationPortRange": "64295", |
| 180 | + "sourceAddressPrefix": "AzureCloud", |
| 181 | + "destinationAddressPrefix": "*", |
| 182 | + "access": "Allow", |
| 183 | + "priority": 1041, |
| 184 | + "direction": "Inbound", |
| 185 | + "sourcePortRanges": [], |
| 186 | + "destinationPortRanges": [], |
| 187 | + "sourceAddressPrefixes": [], |
| 188 | + "destinationAddressPrefixes": [] |
| 189 | + } |
| 190 | + }, |
| 191 | + { |
| 192 | + "name": "AllowCustom64297Inbound", |
| 193 | + "properties": { |
| 194 | + "protocol": "*", |
| 195 | + "sourcePortRange": "*", |
| 196 | + "destinationPortRange": "64297", |
| 197 | + "sourceAddressPrefix": "[parameters('MyConnectionIP')]", |
| 198 | + "destinationAddressPrefix": "*", |
| 199 | + "access": "Allow", |
| 200 | + "priority": 1051, |
| 201 | + "direction": "Inbound", |
| 202 | + "sourcePortRanges": [], |
| 203 | + "destinationPortRanges": [], |
| 204 | + "sourceAddressPrefixes": [], |
| 205 | + "destinationAddressPrefixes": [] |
| 206 | + } |
| 207 | + }, |
| 208 | + { |
| 209 | + "name": "AllowAllHomeOfficeCustomAnyInbound", |
| 210 | + "properties": { |
| 211 | + "protocol": "*", |
| 212 | + "sourcePortRange": "*", |
| 213 | + "destinationPortRange": "*", |
| 214 | + "sourceAddressPrefix": "[parameters('MyConnectionIP')]", |
| 215 | + "destinationAddressPrefix": "*", |
| 216 | + "access": "Allow", |
| 217 | + "priority": 1061, |
| 218 | + "direction": "Inbound", |
| 219 | + "sourcePortRanges": [], |
| 220 | + "destinationPortRanges": [], |
| 221 | + "sourceAddressPrefixes": [], |
| 222 | + "destinationAddressPrefixes": [] |
| 223 | + } |
| 224 | + } |
| 225 | + ] |
| 226 | + } |
| 227 | + }, |
| 228 | + { |
| 229 | + "name": "[concat(uniqueString(resourceGroup().id, deployment().name),'-pip')]", |
| 230 | + "type": "Microsoft.Network/publicIpAddresses", |
| 231 | + "apiVersion": "2020-08-01", |
| 232 | + "location": "[resourceGroup().location]", |
| 233 | + "properties": { |
| 234 | + "publicIpAllocationMethod": "Static" |
| 235 | + }, |
| 236 | + "sku": { |
| 237 | + "name": "Standard" |
| 238 | + }, |
| 239 | + "zones": [ |
| 240 | + "1" |
| 241 | + ] |
| 242 | + }, |
| 243 | + { |
| 244 | + "name": "[parameters('VMName')]", |
| 245 | + "type": "Microsoft.Compute/virtualMachines", |
| 246 | + "apiVersion": "2022-03-01", |
| 247 | + "location": "[resourceGroup().location]", |
| 248 | + "dependsOn": [ |
| 249 | + "[resourceId('Microsoft.Network/networkInterfaces', concat(uniqueString(resourceGroup().id, deployment().name),'-nic'))]" |
| 250 | + ], |
| 251 | + "properties": { |
| 252 | + "hardwareProfile": { |
| 253 | + "vmSize": "Standard_D4s_v3" |
| 254 | + }, |
| 255 | + "storageProfile": { |
| 256 | + "osDisk": { |
| 257 | + "createOption": "fromImage", |
| 258 | + "managedDisk": { |
| 259 | + "storageAccountType": "StandardSSD_LRS" |
| 260 | + }, |
| 261 | + "deleteOption": "Delete" |
| 262 | + }, |
| 263 | + "imageReference": { |
| 264 | + "publisher": "debian", |
| 265 | + "offer": "debian-11", |
| 266 | + "sku": "11-gen2", |
| 267 | + "version": "latest" |
| 268 | + }, |
| 269 | + "dataDisks": [ |
| 270 | + { |
| 271 | + "name": "[concat(parameters('VMName'),'-datadisk')]", |
| 272 | + "diskSizeGB": 256, |
| 273 | + "lun": 0, |
| 274 | + "createOption": "Empty", |
| 275 | + "caching": "ReadWrite" |
| 276 | + } |
| 277 | + ] |
| 278 | + }, |
| 279 | + "networkProfile": { |
| 280 | + "networkInterfaces": [ |
| 281 | + { |
| 282 | + "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(uniqueString(resourceGroup().id, deployment().name),'-nic'))]", |
| 283 | + "properties": { |
| 284 | + "deleteOption": "Delete" |
| 285 | + } |
| 286 | + } |
| 287 | + ] |
| 288 | + }, |
| 289 | + "osProfile": { |
| 290 | + "computerName": "[parameters('VMName')]", |
| 291 | + "adminUsername": "[parameters('adminUsername')]", |
| 292 | + "adminPassword": "[parameters('adminPasswordOrKey')]", |
| 293 | + "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), null(), variables('linuxConfiguration'))]", |
| 294 | + "customData": "[parameters('CloudInitB64Encoded')]" |
| 295 | + }, |
| 296 | + "diagnosticsProfile": { |
| 297 | + "bootDiagnostics": { |
| 298 | + "enabled": true |
| 299 | + } |
| 300 | + } |
| 301 | + }, |
| 302 | + "zones": [ |
| 303 | + "1" |
| 304 | + ] |
| 305 | + } |
| 306 | + ], |
| 307 | + "outputs": {} |
| 308 | +} |
0 commit comments