frameworkResources/Scripts/CreateResourceGroup.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "address_prefixes": { "type": "String" }, "resource_group_name": { "type": "String" }, "location": { "type": "String" }, "vm_names": { "type": "array" }, "zone_name": { "type": "array" }, "publisher_name": { "type": "String" }, "offer_name": { "type": "String" }, "sku_name": { "type": "String" }, "version_name": { "type": "String" }, "os_name": { "type": "String" }, "storage_account_type": { "type": "String" }, "vm_size": { "type": "String" }, "custom_data": { "type": "String" }, "userName": { "type": "String" }, "password": { "type": "String" }, "privateIps": { "type": "array", "defaultValue": [] }, "create_public_ip": { "type": "bool" }, "rule_type": { "type": "String" }, "white_list_ips": { "type": "array", "defaultValue": [] }, "image_version": { "type": "string" }, "use_ncache_image": { "type": "bool", "defaultValue": false } }, "variables": { "vnetName": "[concat('NC-VNET-',parameters('resource_group_name'))]", "subnetName": "[concat('NC-SUBNET-', parameters('resource_group_name'))]", "securitygroupName": "[concat('NC-SG-', parameters('resource_group_name'))]", "publicIpName": "[concat('NC-PUBLIC_IP-',parameters('resource_group_name'))]", "networkInterfaceName": "[concat('NC-NIC-', parameters('resource_group_name'))]", "management_ports": "Management", "all": "All", "data": "Data" }, "resources": [ { "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2024-07-01", "name": "[variables('vnetName')]", "location": "[parameters('location')]", "properties": { "addressSpace": { "addressPrefixes": ["[parameters('address_prefixes')]"] }, "subnets": [ { "name": "[variables('subnetName')]", "type": "Microsoft.Network/virtualNetworks/subnets", "properties": { "addressPrefix": "[parameters('address_prefixes')]" }, "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets',variables('vnetName'),variables('subnetName'))]" } ] } }, { "type": "Microsoft.Network/networkSecurityGroups", "condition": "[not(parameters('create_public_ip'))]", "apiVersion": "2024-07-01", "name": "[variables('securitygroupName')]", "location": "[parameters('location')]" }, { "type": "Microsoft.Network/networkSecurityGroups", "condition": "[and(equals(parameters('rule_type'),variables('management_ports')),parameters('create_public_ip'))]", "apiVersion": "2024-07-01", "name": "[variables('securitygroupName')]", "location": "[parameters('location')]", "properties": { "securityRules": [ { "name": "NCachePorts_InBound", "properties": { "priority": 1003, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "8250-8260" } } ] } }, { "type": "Microsoft.Network/networkSecurityGroups", "condition": "[and(equals(parameters('rule_type'),variables('data')),parameters('create_public_ip'))]", "apiVersion": "2024-07-01", "name": "[variables('securitygroupName')]", "location": "[parameters('location')]", "properties": { "securityRules": [ { "name": "ClientPort_InBound", "properties": { "priority": 1002, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "9800" } }, { "name": "CacheManagementPort_InBound", "properties": { "priority": 1003, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "8300-8400" } } ] } }, { "condition": "[and(equals(parameters('rule_type'),variables('all')),parameters('create_public_ip'))]", "type": "Microsoft.Network/networkSecurityGroups", "apiVersion": "2024-07-01", "name": "[variables('securitygroupName')]", "location": "[parameters('location')]", "properties": { "securityRules": [ { "name": "CacheManagementPort_InBound", "properties": { "priority": 1000, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "8300-8310" } }, { "name": "CacheCluster_InBound", "properties": { "priority": 1001, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "7800-7810" } }, { "name": "ClientPort_InBound", "properties": { "priority": 1002, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "9800" } }, { "name": "NCachePorts_InBound", "properties": { "priority": 1003, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "8250-8260" } }, { "name": "BridgePort_InBound", "properties": { "priority": 1004, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "9900" } }, { "name": "BridgePorts_InBound", "properties": { "priority": 1005, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "10000-10010" } }, { "name": "PrometheusPort_InBound", "properties": { "priority": 1006, "destinationAddressPrefix": "*", "sourceAddressPrefixes": "[parameters('white_list_ips')]", "protocol": "Tcp", "access": "Allow", "direction": "InBound", "sourcePortRange": "*", "destinationPortRange": "9090" } } ] } }, { "type": "Microsoft.Network/publicIPAddresses", "condition": "[parameters('create_public_ip')]", "apiVersion": "2024-07-01", "name": "[concat(variables('publicIpName'),'-',parameters('vm_names')[copyIndex()])]", "location": "[parameters('location')]", "copy": { "name": "publicIpLoop", "count": "[length(parameters('vm_names'))]" }, "zones": "[parameters('zone_name')]", "sku": { "Name": "Standard" }, "properties": { "publicIPAllocationMethod": "Static" } }, { "condition": "[not(parameters('create_public_ip'))]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2024-07-01", "name": "[concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()])]", "dependsOn": [ "[resourceId('Microsoft.Network/networkSecurityGroups',variables('securitygroupName'))]" ], "copy": { "name": "nicLoop", "count": "[length(parameters('vm_names'))]" }, "location": "[parameters('location')]", "properties": { "enableAcceleratedNetworking": "false", "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('securitygroupName'))]" }, "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "[if(empty(parameters('privateIps')), 'Dynamic', 'Static')]", "privateIPAddress": "[if(empty(parameters('privateIps')), json('null'), parameters('privateIps')[copyIndex()])]", "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'),variables('subnetName'))]" } } } ] } }, { "condition": "[parameters('create_public_ip')]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2024-07-01", "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIpName'),'-',parameters('vm_names')[copyIndex()]))]", "[resourceId('Microsoft.Network/networkSecurityGroups',variables('securitygroupName'))]" ], "name": "[concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()])]", "copy": { "name": "nicLoop", "count": "[length(parameters('vm_names'))]" }, "location": "[parameters('location')]", "properties": { "enableAcceleratedNetworking": "false", "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('securitygroupName'))]" }, "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "[if(empty(parameters('privateIps')), 'Dynamic', 'Static')]", "privateIPAddress": "[if(empty(parameters('privateIps')), json('null'), parameters('privateIps')[copyIndex()])]", "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'),variables('subnetName'))]" }, "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIpName'), '-', parameters('vm_names')[copyIndex()]))]" } } } ] } }, { "condition": "[and(not(parameters('create_public_ip')),not(parameters('use_ncache_image')))]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2024-07-01", "name": "[parameters('vm_names')[copyIndex()]]", "zones": "[parameters('zone_name')]", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" ], "location": "[parameters('location')]", "copy": { "name": "vmLoop", "count": "[length(parameters('vm_names'))]" }, "tags": { "Caches": "demoCache", "ServerType": "NCache", "InstallMode": "server" }, "properties": { "osProfile": { "computerName": "[parameters('vm_names')[copyIndex()]]", "adminUsername": "[parameters('userName')]", "adminPassword": "[parameters('password')]" }, "hardwareProfile": { "vmSize": "[parameters('vm_size')]" }, "storageProfile": { "imageReference": { "publisher": "[parameters('publisher_name')]", "offer": "[parameters('offer_name')]", "sku": "[parameters('sku_name')]", "version": "[parameters('image_version')]" }, "osDisk": { "createOption": "FromImage", "osType": "[parameters('os_name')]", "managedDisk": { "storageAccountType": "[parameters('storage_account_type')]" } } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" } ] } } }, { "condition": "[and(parameters('create_public_ip'),not(parameters('use_ncache_image')))]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2024-07-01", "name": "[parameters('vm_names')[copyIndex()]]", "zones": "[parameters('zone_name')]", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]", "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIpName'),'-',parameters('vm_names')[copyIndex()]))]" ], "location": "[parameters('location')]", "copy": { "name": "vmLoop", "count": "[length(parameters('vm_names'))]" }, "tags": { "Caches": "demoCache", "ServerType": "NCache", "InstallMode": "server" }, "properties": { "osProfile": { "computerName": "[parameters('vm_names')[copyIndex()]]", "adminUsername": "[parameters('userName')]", "adminPassword": "[parameters('password')]" }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": false } }, "hardwareProfile": { "vmSize": "[parameters('vm_size')]" }, "storageProfile": { "imageReference": { "publisher": "[parameters('publisher_name')]", "offer": "[parameters('offer_name')]", "sku": "[parameters('sku_name')]", "version": "[parameters('image_version')]" }, "osDisk": { "createOption": "FromImage", "osType": "[parameters('os_name')]", "managedDisk": { "storageAccountType": "[parameters('storage_account_type')]" } } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" } ] } } }, { "condition": "[and(not(parameters('create_public_ip')),parameters('use_ncache_image'))]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2024-07-01", "plan": { "name": "[parameters('sku_name')]", "publisher": "[parameters('publisher_name')]", "product": "[parameters('offer_name')]" }, "name": "[parameters('vm_names')[copyIndex()]]", "zones": "[parameters('zone_name')]", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" ], "location": "[parameters('location')]", "copy": { "name": "vmLoop", "count": "[length(parameters('vm_names'))]" }, "tags": { "Caches": "demoCache", "ServerType": "NCache", "InstallMode": "server" }, "properties": { "osProfile": { "computerName": "[parameters('vm_names')[copyIndex()]]", "adminUsername": "[parameters('userName')]", "adminPassword": "[parameters('password')]", "customData": "[parameters('custom_data')]" }, "hardwareProfile": { "vmSize": "[parameters('vm_size')]" }, "storageProfile": { "imageReference": { "publisher": "[parameters('publisher_name')]", "offer": "[parameters('offer_name')]", "sku": "[parameters('sku_name')]", "version": "[parameters('image_version')]" }, "osDisk": { "createOption": "FromImage", "osType": "[parameters('os_name')]", "managedDisk": { "storageAccountType": "[parameters('storage_account_type')]" } } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" } ] } } }, { "condition": "[and(parameters('create_public_ip'),parameters('use_ncache_image'))]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2024-07-01", "plan": { "name": "[parameters('sku_name')]", "publisher": "[parameters('publisher_name')]", "product": "[parameters('offer_name')]" }, "name": "[parameters('vm_names')[copyIndex()]]", "zones": "[parameters('zone_name')]", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]", "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIpName'),'-',parameters('vm_names')[copyIndex()]))]" ], "location": "[parameters('location')]", "copy": { "name": "vmLoop", "count": "[length(parameters('vm_names'))]" }, "tags": { "Caches": "demoCache", "ServerType": "NCache", "InstallMode": "server" }, "properties": { "osProfile": { "computerName": "[parameters('vm_names')[copyIndex()]]", "adminUsername": "[parameters('userName')]", "adminPassword": "[parameters('password')]", "customData": "[parameters('custom_data')]" }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": false } }, "hardwareProfile": { "vmSize": "[parameters('vm_size')]" }, "storageProfile": { "imageReference": { "publisher": "[parameters('publisher_name')]", "offer": "[parameters('offer_name')]", "sku": "[parameters('sku_name')]", "version": "[parameters('image_version')]" }, "osDisk": { "createOption": "FromImage", "osType": "[parameters('os_name')]", "managedDisk": { "storageAccountType": "[parameters('storage_account_type')]" } } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),'-',parameters('vm_names')[copyIndex()]))]" } ] } } } ] } |