{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/subscriptionDeploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "tenantPrefix": { "type": "string", "defaultValue": "M365x268088", "metadata": { "description": "Prefix of the M365 Demo tenant. The part in front of .onmicrosoft.com" } } }, "functions": [], "variables": { "rgName": "[concat('rg-',parameters('tenantPrefix'))]", "vnetName": "[concat('vnet-',parameters('tenantPrefix'))]", "vmName": "[concat('vm-',parameters('tenantPrefix'))]" }, "resources": [ { "type": "Microsoft.Resources/resourceGroups", "apiVersion": "2020-06-01", "name": "[variables('rgName')]", "location": "[deployment().location]", "tags": { "Note": "subscription level deployment" }, "properties": {} }, { "name": "deploy-vnet", "type": "Microsoft.Resources/deployments", "apiVersion": "2020-10-01", "resourceGroup": "[variables('rgName')]", "dependsOn": [ "[resourceId('Microsoft.Resources/resourceGroups',variables('rgName'))]" ], "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": {}, "resources": [ { "name": "[variables('vnetName')]", "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2019-11-01", "location": "[resourceGroup().location]", "tags": {}, "properties": { "addressSpace": { "addressPrefixes": [ "10.100.200.0/24" ] }, "subnets": [ { "name": "Subnet-1", "properties": { "addressPrefix": "10.100.200.0/24" } } ] } } ], "outputs": {} } } }, { "name": "[concat('deployment-',variables('vmName'),'-dc')]", "type": "Microsoft.Resources/deployments", "apiVersion": "2020-10-01", "resourceGroup": "[variables('rgName')]", "dependsOn": [ "[resourceId('Microsoft.Resources/deployments','deploy-vnet')]" ], "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": {}, "resources": [ { "name": "[concat('pip-',variables('vmName'),'-dc')]", "type": "Microsoft.Network/publicIPAddresses", "apiVersion": "2019-11-01", "location": "[resourceGroup().location]", "tags": {}, "properties": { "publicIPAllocationMethod": "Dynamic", "dnsSettings": {} } }, { "name": "[concat('nsg-',variables('vmName'),'-dc')]", "type": "Microsoft.Network/networkSecurityGroups", "apiVersion": "2018-08-01", "location": "[resourceGroup().location]", "properties": { "securityRules": [ { "name": "nsgRule1", "properties": { "description": "description", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "3389", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*", "access": "Allow", "priority": 100, "direction": "Inbound" } } ] } }, { "name": "[concat('nic-',variables('vmName'),'-dc')]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2019-11-01", "location": "[resourceGroup().location]", "tags": {}, "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses', concat('pip-',variables('vmName'),'-dc'))]", "[resourceId('Microsoft.Network/networkSecurityGroups', concat('nsg-',variables('vmName'),'-dc'))]" ], "properties": { "ipConfigurations": [ { "name": "ipConfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat('pip-',variables('vmName'),'-dc'))]" }, "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), 'subnet-1')]" } } } ], "networkSecurityGroups": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups',concat('nsg-',variables('vmName'),'-dc'))]" } } }, { "name": "[concat(variables('vmName'),'-dc')]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2019-07-01", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces', concat('nic-',variables('vmName'),'-dc'))]" ], "tags": {}, "properties": { "hardwareProfile": { "vmSize": "Standard_B1_ms" }, "osProfile": { "computerName": "[concat(variables('vmName'),'-dc')]", "adminUsername": "adminUsername", "adminPassword": "adminPassword" }, "storageProfile": { "imageReference": { "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2019-Datacenter", "version": "latest" }, "osDisk": { "name": "[concat('osdisk-',variables('vmName'),'-dc')]", "caching": "ReadWrite", "createOption": "FromImage" } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces', concat('nic-',variables('vmName'),'-dc'))]" } ] } } }, { "name": "[concat(variables('vmName'),'-dc','/customScript1')]", "type": "Microsoft.Compute/virtualMachines/extensions", "apiVersion": "2019-07-01", "location": "[resourceGroup().location]", "tags": {}, "dependsOn": [ "[resourceId('Microsoft.Compute/virtualMachines', concat(variables('vmName'),'-dc'))]" ], "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.10", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "https://raw.githubusercontent.com/KennethMLdk/DemoInfrastructure/main/scripts/dcScript.ps1" ] }, "protectedSettings": { "commandToExecute": "[concat('powershell -ExecutionPolicy Bypass -file dcScript.ps1 ', parameters('tenantPrefix') )]" } } } ], "outputs": {} } } } ], "outputs": {} }