-
-
Save arsenvlad/57a25b40a04898b2dcd9060a973ccfec to your computer and use it in GitHub Desktop.
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"location": { | |
"type": "string", | |
"metadata": { | |
"description": "Location for the deployment" | |
} | |
}, | |
"envName": { | |
"type": "string", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"vnetAddressPrefix": { | |
"type": "string", | |
"defaultValue": "10.0.0.0/16", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"sqlVmSize": { | |
"type": "string", | |
"defaultValue": "Standard_DS2_v2", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"adminUsername": { | |
"type": "string", | |
"defaultValue": "azureuser", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"adminPassword": { | |
"type": "securestring", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"citrixAddressPrefix": { | |
"type": "string", | |
"defaultValue": "10.0.1.0/24", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"webAddressPrefix": { | |
"type": "string", | |
"defaultValue": "10.0.2.0/24", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"msgAddressPrefix": { | |
"type": "string", | |
"defaultValue": "10.0.3.0/24", | |
"metadata": { | |
"description": "" | |
} | |
}, | |
"sqlAddressPrefix": { | |
"type": "string", | |
"defaultValue": "10.0.4.0/24", | |
"metadata": { | |
"description": "" | |
} | |
} | |
}, | |
"variables": { | |
"apiVersions": { | |
"resources": { | |
"deployments": "2016-09-01" | |
}, | |
"storage": { | |
"storageAccounts": "2016-05-01" | |
}, | |
"network": { | |
"virtualNetworks": "2016-09-01", | |
"networkInterfaces": "2016-09-01", | |
"loadBalancers": "2016-09-01", | |
"publicIPAddresses": "2016-09-01", | |
"networkSecurityGroups": "2016-09-01" | |
}, | |
"compute": { | |
"availabilitySets": "2016-03-30", | |
"virtualMachines": "2016-03-30", | |
"virtualMachineExtensions": "2016-03-30" | |
} | |
}, | |
"vnetName": "[concat('vnet-',parameters('envName'))]", | |
"subnetNetworkSecurityGroupName": "[concat(variables('vnetName'),'-','nsg')]", | |
"diagnosticsStorageAccountName": "[concat(uniquestring(resourceGroup().id),'diag')]", | |
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]", | |
"subnetSqlID": "[concat(variables('vnetID'), '/subnets/', 'sql')]", | |
"storageAccountName": "[concat(uniquestring(resourceGroup().id),'sa')]", | |
"storageAccountType": "Premium_LRS" | |
}, | |
"resources": [ | |
{ | |
"apiVersion": "[variables('apiVersions').network.networkSecurityGroups]", | |
"type": "Microsoft.Network/networkSecurityGroups", | |
"name": "[variables('subnetNetworkSecurityGroupName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"securityRules": [ | |
{ | |
"name": "rdp_rule", | |
"properties": { | |
"description": "Allow RDP access", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"destinationPortRange": "3389", | |
"sourceAddressPrefix": "Internet", | |
"destinationAddressPrefix": "*", | |
"access": "Allow", | |
"priority": 100, | |
"direction": "Inbound" | |
} | |
}, | |
{ | |
"name": "http_rule", | |
"properties": { | |
"description": "Allow HTTP access", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"destinationPortRange": "80", | |
"sourceAddressPrefix": "Internet", | |
"destinationAddressPrefix": "*", | |
"access": "Allow", | |
"priority": 101, | |
"direction": "Inbound" | |
} | |
}, | |
{ | |
"name": "https_rule", | |
"properties": { | |
"description": "Allow HTTPS access", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"destinationPortRange": "443", | |
"sourceAddressPrefix": "Internet", | |
"destinationAddressPrefix": "*", | |
"access": "Allow", | |
"priority": 102, | |
"direction": "Inbound" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').network.virtualNetworks]", | |
"type": "Microsoft.Network/virtualNetworks", | |
"name": "[variables('vnetName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/networkSecurityGroups/', variables('subnetNetworkSecurityGroupName'))]" | |
], | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[parameters('vnetAddressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "citrix", | |
"properties": { | |
"addressPrefix": "[parameters('citrixAddressPrefix')]", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('subnetNetworkSecurityGroupName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "web", | |
"properties": { | |
"addressPrefix": "[parameters('webAddressPrefix')]", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('subnetNetworkSecurityGroupName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "msg", | |
"properties": { | |
"addressPrefix": "[parameters('msgAddressPrefix')]", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('subnetNetworkSecurityGroupName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "sql", | |
"properties": { | |
"addressPrefix": "[parameters('sqlAddressPrefix')]", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('subnetNetworkSecurityGroupName'))]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').network.networkInterfaces]", | |
"type": "Microsoft.Network/networkInterfaces", | |
"name": "[concat(parameters('envName'),'-sql01-nic')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]", | |
"[concat('Microsoft.Network/publicIPAddresses/', parameters('envName'), '-publicip')]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ip1", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('envName'), '-publicip'))]" | |
}, | |
"subnet": { | |
"id": "[variables('subnetSqlID')]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').storage.storageAccounts]", | |
"type": "Microsoft.Storage/storageAccounts", | |
"name": "[variables('storageAccountName')]", | |
"location": "[parameters('location')]", | |
"kind": "Storage", | |
"sku": { | |
"name": "[variables('storageAccountType')]" | |
}, | |
"properties": { | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').storage.storageAccounts]", | |
"type": "Microsoft.Storage/storageAccounts", | |
"name": "[variables('diagnosticsStorageAccountName')]", | |
"location": "[parameters('location')]", | |
"kind": "Storage", | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"properties": { | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').network.publicIPAddresses]", | |
"type": "Microsoft.Network/publicIPAddresses", | |
"name": "[concat(parameters('envName'),'-publicip')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"publicIPAllocationMethod": "Dynamic", | |
"dnsSettings": { | |
"domainNameLabel": "[concat(parameters('envName'),'-',uniqueString(resourceGroup().id))]" | |
} | |
} | |
}, | |
{ | |
"apiVersion": "[variables('apiVersions').compute.virtualMachines]", | |
"type": "Microsoft.Compute/virtualMachines", | |
"name": "[concat(parameters('envName'),'-sql01')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/networkInterfaces/', parameters('envName'), '-sql01-nic')]", | |
"[concat('Microsoft.Storage/storageAccounts/', variables('diagnosticsStorageAccountName'))]", | |
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]" | |
], | |
"properties": { | |
"hardwareProfile": { | |
"vmSize": "[parameters('sqlVmSize')]" | |
}, | |
"osProfile": { | |
"computerName": "[concat(parameters('envName'),'-sql01')]", | |
"adminUserName": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPassword')]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "MicrosoftSQLServer", | |
"offer": "SQL2012SP3-WS2012R2", | |
"sku": "Express", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"name": "osdisk", | |
"vhd": { | |
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-osdisk.vhd')]" | |
}, | |
"caching": "ReadWrite", | |
"createOption": "FromImage" | |
}, | |
"dataDisks": [ | |
{ | |
"name": "datadisk1", | |
"vhd": { | |
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-datadisk1.vhd')]" | |
}, | |
"diskSizeGB": "512", | |
"lun": 0, | |
"caching": "None", | |
"createOption": "Empty" | |
}, | |
{ | |
"name": "datadisk2", | |
"vhd": { | |
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-datadisk2.vhd')]" | |
}, | |
"diskSizeGB": "1023", | |
"lun": 1, | |
"caching": "None", | |
"createOption": "Empty" | |
} | |
] | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(parameters('envName'),'-sql01-nic'))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": "true", | |
"storageUri": "[concat('http://', variables('diagnosticsStorageAccountName'), '.blob.core.windows.net')]" | |
} | |
} | |
} | |
} | |
], | |
"outputs": { | |
} | |
} |
arsenvlad
commented
Dec 6, 2016
{
"apiVersion": "[variables('apiVersions').storage.storageAccounts]",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('diagnosticsStorageAccountName')]",
"location": "[parameters('location')]",
"kind": "Storage",
"sku": {
"name": "Standard_LRS"
},
"properties": {
}
}
Add these two to variables:
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetSqlID": "[concat(variables('vnetID'), '/subnets/', 'sql')]"
Add this as an additional resource:
{
"apiVersion": "[variables('apiVersions').network.networkInterfaces]",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(parameters('envName'),'-sql01-nic')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ip1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetSqlID')]"
}
}
}
]
}
},
Add these to the parameters section:
"sqlVmSize": {
"type": "string",
"defaultValue": "Standard_DS2_v2",
"metadata": {
"description": ""
}
},
"adminUsername": {
"type": "string",
"defaultValue": "azureuser",
"metadata": {
"description": ""
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": ""
}
},
Add to variables:
"storageAccountName": "[concat(uniquestring(resourceGroup().id),'sa')]",
"storageAccountType": "Premium_LRS"
Add this dependsOn to the network interface for SQL01
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]"
],
Add this additional resource:
{
"apiVersion": "[variables('apiVersions').storage.storageAccounts]",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "Storage",
"sku": {
"name": "variables('storageAccountType')"
},
"properties": {
}
},
Add this into the osDisk object:
"name": "osdisk",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-osdisk.vhd')]"
},
Copy into the first data disk object:
"name": "datadisk1",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-datadisk1.vhd')]"
},
Copy into the second data disk object:
"name": "datadisk2",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', parameters('envName'), '-sql01-datadisk2.vhd')]"
},
Add this new resource for public IP
{
"apiVersion": "[variables('apiVersions').network.publicIPAddresses]",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(parameters('envName'),'-publicip')]",
"location": "[parameters('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[concat(parameters('envName'),'-',uniqueString(resourceGroup().id))]"
}
}
},
Add to networkInterfaces as dependsOn
"[concat('Microsoft.Network/publicIPAddresses/', parameters('envName'), '-publicip')]"
Add this to the networkInterface to give the public IP address
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('envName'), '-publicip'))]"
},