VMProvision

ARM Template to Provision Ubuntu, Redhat, and CentOS Virtual Machines

By using this ARM Template    

    "Ubuntu-17.10",
    "Ubuntu-18.04-LTS",
    "RHEL-7.5",
    "RHEL-7.6",
    "Centos-7.3",  
    "Centos-7.5" Virtual Machines Will be Provisioned. New Virtual Network,Virtual Subnet,Network Security Group will be created.

View it in GitHub by using this link https://github.com/Eranachandran/Azure_VM_Provision_ARM

{
	"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"Location": {
			"type": "string",
			"allowedValues": [
				"westus",
				"westus2",
				"eastus",
				"eastus2",
				"australiaeast",
				"australiasoutheast",
				"brazilsouth",
				"canadacentral",
				"canadaeast",
				"centralindia",
				"centralus",
				"eastasia",
				"francecentral",
				"japaneast",
				"japanwest",
				"koreacentral",
				"koreasouth",
				"northcentralus",
				"northeurope",
				"southcentralus",
				"southindia",
				"southeastasia",
				"uksouth",
				"ukwest",
				"westcentralus",
				"westeurope",
				"westindia"
			]
		},
		"VirtualMachine_Name": {
			"type": "string",
			"metadata": {
				"description": "Name for the Virtual Machine to be provisioned. VM name is case-insensitive. Alphanumeric and hyphen are valid characters."
			},
			"minLength": 1,
			"maxLength": 64
		},
		"OperatingSystem": {
			"type": "string",
			"allowedValues": [
				"Ubuntu-17.10",
				"Ubuntu-18.04-LTS",
				"RHEL-7.5",
				"RHEL-7.6",
				"Centos-7.3",
				"Centos-7.5"
			],
			"metadata": {
				"description": "Select which version of VM need to be deployed"
			}
		},
		"VM_Username": {
			"type": "string",
			"metadata": {
				"description": "Username of the administrator account in the Virtual Machine. The username will be used to remote connect (login) to the VM when it is created. Username must only contain letters, numbers, underscores, hyphens and may not start with a hyphen or number."
			},
			"minLength": 1,
			"maxLength": 32
		},
		"VM_Password": {
			"type": "securestring",
			"metadata": {
				"description": "Password of the administrator account in the Virtual Machine. Password must have 3 of the following: 1 lowercase character, 1 uppercase character, 1 number and  1 special character that is not hyphen(-). "
			},
			"minLength": 12,
			"maxLength": 72
		},
		"VirtualMachine_Size": {
			"type": "string",
			"allowedValues": [
				"Basic_A0",
				"Basic_A1",
				"Basic_A2",
				"Basic_A3",
				"Basic_A4",
				"Standard_A0",
				"Standard_A1",
				"Standard_A2",
				"Standard_A3",
				"Standard_A4",
				"Standard_A5",
				"Standard_A6",
				"Standard_A7",
				"Standard_D2_v3",
				"Standard_D4_v3",
				"Standard_D8_v3",
				"Standard_D1_v2",
				"Standard_D2_v2",
				"Standard_D3_v2",
				"Standard_D4_v2",
				"Standard_A1_v2",
				"Standard_A2_v2",
				"Standard_A4_v2",
				"Standard_A8_v2"
			]
		},
		"PublicIPAddress_Type": {
			"type": "string",
			"allowedValues": [
				"Static",
				"Dynamic"
			]
		}
	},
	"variables": {
		"storageaccount_name": "[concat('tsstoragedisks', take(uniquestring(parameters('VirtualMachine_Name'), deployment().name), 6))]",
		"diagnostics_storageaccount_name": "[concat('tsstoragediag', take(uniquestring(parameters('VirtualMachine_Name'),deployment().name), 6))]",
		"virtualnetwork_name": "[concat('tsvnet', take(uniquestring(parameters('VirtualMachine_Name'), deployment().name), 6))]",
		"subnet_name": "default",
		"networkinterface_name": "[concat(parameters('VirtualMachine_Name'), take(uniquestring(parameters('VirtualMachine_Name'), deployment().name), 3))]",
		"networksecuritygroup_name": "[concat(parameters('VirtualMachine_Name'), '-nsg')]",
		"publicipaddress_name": "[concat(parameters('VirtualMachine_Name'), '-ip')]",
		"vnetId": "[resourceId(resourcegroup().name,'Microsoft.Network/virtualNetworks', variables('virtualnetwork_name'))]",
		"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnet_name'))]",
		"address_prefix": "172.17.2.0/24",
		"subnet_prefix": "172.17.2.0/24",
		"redhatOffer": "RHEL",
		"redhatSku": "(parameters('OperatingSystem')",
		"redhatPublisher": "RedHat",
		"centosOffer": "CentOS-HPC",
		"centosSku": "(parameters('OperatingSystem')",
		"centosPublisher": "OpenLogic",
		"ubuntuOffer": "UbuntuServer",
		"ubuntuSku": "(parameters('OperatingSystem')",
		"ubuntuPublisher": "Canonical"
	},
	"resources": [{
			"name": "[variables('networkinterface_name')]",
			"type": "Microsoft.Network/networkInterfaces",
			"apiVersion": "2018-04-01",
			"location": "[parameters('Location')]",
			"dependsOn": [
				"[concat('Microsoft.Network/networkSecurityGroups/', variables('networksecuritygroup_name'))]",
				"[concat('Microsoft.Network/virtualNetworks/', variables('virtualnetwork_name'))]",
				"[concat('Microsoft.Network/publicIpAddresses/', variables('publicipaddress_name'))]"
			],
			"properties": {
				"ipConfigurations": [{
					"name": "ipconfig1",
					"properties": {
						"subnet": {
							"id": "[variables('subnetRef')]"
						},
						"privateIPAllocationMethod": "Dynamic",
						"publicIpAddress": {
							"id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', variables('publicipaddress_name'))]"
						}
					}
				}],
				"networkSecurityGroup": {
					"id": "[resourceId(resourcegroup().name, 'Microsoft.Network/networkSecurityGroups', variables('networksecuritygroup_name'))]"
				}
			}
		},
		{
			"name": "[variables('networksecuritygroup_name')]",
			"type": "Microsoft.Network/networkSecurityGroups",
			"apiVersion": "2018-08-01",
			"location": "[parameters('Location')]",
			"properties": {
				"securityRules": [{
					"name": "SSH",
					"properties": {
						"priority": "300",
						"protocol": "TCP",
						"access": "Allow",
						"direction": "Inbound",
						"sourceApplicationSecurityGroups": [],
						"destinationApplicationSecurityGroups": [],
						"sourceAddressPrefix": "*",
						"sourcePortRange": "*",
						"destinationAddressPrefix": "*",
						"destinationPortRange": "22"
					}
				}]
			}
		},
		{
			"name": "[variables('virtualnetwork_name')]",
			"type": "Microsoft.Network/virtualNetworks",
			"apiVersion": "2018-08-01",
			"location": "[parameters('Location')]",
			"properties": {
				"addressSpace": {
					"addressPrefixes": [
						"[variables('address_prefix')]"
					]
				},
				"subnets": [{
					"name": "[variables('subnet_name')]",
					"properties": {
						"addressPrefix": "[variables('subnet_prefix')]"
					}
				}]
			}
		},
		{
			"name": "[variables('publicipaddress_name')]",
			"type": "Microsoft.Network/publicIpAddresses",
			"apiVersion": "2018-08-01",
			"location": "[parameters('Location')]",
			"properties": {
				"publicIpAllocationMethod": "[parameters('PublicIPAddress_Type')]"
			},
			"sku": {
				"name": "Basic"
			}
		},
		{
			"name": "[variables('storageaccount_name')]",
			"type": "Microsoft.Storage/storageAccounts",
			"apiVersion": "2018-07-01",
			"kind": "Storage",
			"location": "[parameters('Location')]",
			"sku": {
				"name": "Standard_LRS"
			},
			"properties": {}
		},
		{
			"name": "[variables('diagnostics_storageaccount_name')]",
			"type": "Microsoft.Storage/storageAccounts",
			"apiVersion": "2018-07-01",
			"kind": "Storage",
			"location": "[parameters('Location')]",
			"sku": {
				"name": "Standard_LRS"
			},
			"properties": {}
		},
		{
			"name": "[parameters('VirtualMachine_Name')]",
			"type": "Microsoft.Compute/virtualMachines",
			"apiVersion": "2018-06-01",
			"location": "[parameters('Location')]",
			"dependsOn": [
				"[concat('Microsoft.Storage/storageAccounts/', variables('storageaccount_name'))]",
				"[concat('Microsoft.Network/networkInterfaces/', variables('networkinterface_name'))]"
			],
			"properties": {
				"hardwareProfile": {
					"vmSize": "[parameters('VirtualMachine_Size')]"
				},
				"storageProfile": {
					"osDisk": {
						"createOption": "fromImage",
						"vhd": {
							"uri": "[concat(concat(concat('https://', variables('storageaccount_name'), '.blob.core.windows.net/'), 'vhds/'), parameters('VirtualMachine_Name'), '.vhd')]"
						},
						"name": "[parameters('VirtualMachine_Name')]"
					},
					"imageReference": {
						"publisher": "[if(equals(parameters('OperatingSystem'), 'Ubuntu-17.10'),variables('ubuntuPublisher'), if(equals(parameters('OperatingSystem'), 'Ubuntu-18.04-LTS'),variables('ubuntuPublisher'), if(equals(parameters('OperatingSystem'), 'RHEL-7.5'),variables('redhatPublisher'), if(equals(parameters('OperatingSystem'), 'RHEL-7.6'),variables('redhatPublisher'), if(equals(parameters('OperatingSystem'), 'Centos-7.3'),variables('centosPublisher'), variables('centosPublisher'))))))]",
						"offer": "[if(equals(parameters('OperatingSystem'), 'Ubuntu-17.10'),variables('ubuntuOffer'), if(equals(parameters('OperatingSystem'), 'Ubuntu-18.04-LTS'),variables('ubuntuOffer'), if(equals(parameters('OperatingSystem'), 'RHEL-7.5'),variables('redhatOffer'), if(equals(parameters('OperatingSystem'), 'RHEL-7.6'),variables('redhatOffer'), if(equals(parameters('OperatingSystem'), 'Centos-7.3'),variables('centosOffer'), variables('centosOffer'))))))]",
						"sku": "[if(equals(parameters('OperatingSystem'), 'Ubuntu-17.10'),'17.10', if(equals(parameters('OperatingSystem'), 'Ubuntu-18.04-LTS'),'18.04-LTS', if(equals(parameters('OperatingSystem'), 'RHEL-7.5'),'7.5', if(equals(parameters('OperatingSystem'), 'RHEL-7.6'),'7-RAW', if(equals(parameters('OperatingSystem'), 'Centos-7.3'),'7.3', '7.4')))))]",
						"version": "latest"
					}
				},
				"networkProfile": {
					"networkInterfaces": [{
						"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkinterface_name'))]"
					}]
				},
				"osProfile": {
					"computerName": "[parameters('VirtualMachine_Name')]",
					"adminUsername": "[parameters('VM_Username')]",
					"adminPassword": "[parameters('VM_Password')]"
				}
			}
		}
	]
}
Posts created 12

Leave a Reply

Your email address will not be published. Required fields are marked *

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top