Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created March 25, 2020 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/7fe0cc1079e2244b3a749c8882bd99a1 to your computer and use it in GitHub Desktop.
Save rahulsahay19/7fe0cc1079e2244b3a749c8882bd99a1 to your computer and use it in GitHub Desktop.
template.json
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "String"
},
"networkInterfaceName": {
"type": "String"
},
"networkSecurityGroupName": {
"type": "String"
},
"networkSecurityGroupRules": {
"type": "Array"
},
"subnetName": {
"type": "String"
},
"virtualNetworkName": {
"type": "String"
},
"addressPrefixes": {
"type": "Array"
},
"subnets": {
"type": "Array"
},
"publicIpAddressName": {
"type": "String"
},
"publicIpAddressType": {
"type": "String"
},
"publicIpAddressSku": {
"type": "String"
},
"virtualMachineName": {
"type": "String"
},
"virtualMachineRG": {
"type": "String"
},
"osDiskType": {
"type": "String"
},
"virtualMachineSize": {
"type": "String"
},
"adminUsername": {
"type": "String"
},
"adminPassword": {
"type": "SecureString"
},
"diagnosticsStorageAccountName": {
"type": "String"
},
"diagnosticsStorageAccountId": {
"type": "String"
},
"diagnosticsStorageAccountType": {
"type": "String"
},
"diagnosticsStorageAccountKind": {
"type": "String"
},
"autoShutdownStatus": {
"type": "String"
},
"autoShutdownTime": {
"type": "String"
},
"autoShutdownTimeZone": {
"type": "String"
},
"autoShutdownNotificationStatus": {
"type": "String"
},
"autoShutdownNotificationLocale": {
"type": "String"
}
},
"variables": {
"nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]",
"vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2019-07-01",
"name": "[parameters('networkInterfaceName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]"
],
"tags": {
"demo": "azure"
},
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIpAddress": {
"id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
}
}
}
],
"networkSecurityGroup": {
"id": "[variables('nsgId')]"
}
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-02-01",
"name": "[parameters('networkSecurityGroupName')]",
"location": "[parameters('location')]",
"tags": {
"demo": "azure"
},
"properties": {
"securityRules": "[parameters('networkSecurityGroupRules')]"
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-04-01",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"tags": {
"demo": "azure"
},
"properties": {
"addressSpace": {
"addressPrefixes": "[parameters('addressPrefixes')]"
},
"subnets": "[parameters('subnets')]"
}
},
{
"type": "Microsoft.Network/publicIpAddresses",
"apiVersion": "2019-02-01",
"name": "[parameters('publicIpAddressName')]",
"location": "[parameters('location')]",
"tags": {
"demo": "azure"
},
"sku": {
"name": "[parameters('publicIpAddressSku')]"
},
"properties": {
"publicIpAllocationMethod": "[parameters('publicIpAddressType')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-07-01",
"name": "[parameters('virtualMachineName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('diagnosticsStorageAccountName'))]"
],
"tags": {
"demo": "azure"
},
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
},
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"enableAutomaticUpdates": true,
"provisionVmAgent": true
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('https://', parameters('diagnosticsStorageAccountName'), '.blob.core.windows.net/')]"
}
}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('diagnosticsStorageAccountName')]",
"location": "[parameters('location')]",
"tags": {
"demo": "azure"
},
"sku": {
"name": "[parameters('diagnosticsStorageAccountType')]"
},
"kind": "[parameters('diagnosticsStorageAccountKind')]",
"properties": {}
},
{
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"tags": {
"demo": "azure"
},
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"notificationLocale": "[parameters('autoShutdownNotificationLocale')]",
"timeInMinutes": "30"
}
}
}
],
"outputs": {
"adminUsername": {
"type": "String",
"value": "[parameters('adminUsername')]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment