{ "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "type": "string" }, "imageName": { "type": "string" }, "networkInterfaceName": { "type": "string" }, "networkSecurityGroupId": { "type": "string" }, "subnetName": { "type": "string" }, "virtualNetworkId": { "type": "string" }, "publicIpAddressName": { "type": "string" }, "publicIpAddressType": { "type": "string" }, "publicIpAddressSku": { "type": "string" }, "virtualMachineName": { "type": "string" }, "virtualMachineComputerName": { "type": "string" }, "virtualMachineRG": { "type": "string" }, "osDiskType": { "type": "string" }, "virtualMachineSize": { "type": "string" }, "adminUsername": { "type": "string" }, "adminPublicKey": { "type": "secureString" }, "autoShutdownStatus": { "type": "string" }, "autoShutdownTime": { "type": "string" }, "autoShutdownTimeZone": { "type": "string" }, "autoShutdownNotificationStatus": { "type": "string" }, "autoShutdownNotificationLocale": { "type": "string" }, "autoShutdownNotificationEmail": { "type": "string" } }, "variables": { "nsgId": "[parameters('networkSecurityGroupId')]", "vnetId": "[parameters('virtualNetworkId')]", "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]" }, "resources": [ { "name": "[parameters('networkInterfaceName')]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2018-10-01", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]" ], "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')]" } } }, { "name": "[parameters('publicIpAddressName')]", "type": "Microsoft.Network/publicIpAddresses", "apiVersion": "2019-02-01", "location": "[parameters('location')]", "properties": { "publicIpAllocationMethod": "[parameters('publicIpAddressType')]" }, "sku": { "name": "[parameters('publicIpAddressSku')]" } }, { "name": "[parameters('virtualMachineName')]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2020-12-01", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]" ], "properties": { "hardwareProfile": { "vmSize": "[parameters('virtualMachineSize')]" }, "storageProfile": { "osDisk": { "createOption": "fromImage", "managedDisk": { "storageAccountType": "[parameters('osDiskType')]" } }, "imageReference": { "id": "/subscriptions/14b6e880-753e-4a5f-8618-c0786702aa1c/resourceGroups/MsOps-Horizon-rg/providers/Microsoft.Compute/images/[parameters('imageName')]" } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" } ] }, "osProfile": { "computerName": "[parameters('virtualMachineComputerName')]", "adminUsername": "[parameters('adminUsername')]", "linuxConfiguration": { "disablePasswordAuthentication": true, "ssh": { "publicKeys": [ { "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", "keyData": "[parameters('adminPublicKey')]" } ] } } }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": true } } } }, { "name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]", "type": "Microsoft.DevTestLab/schedules", "apiVersion": "2017-04-26-preview", "location": "[parameters('location')]", "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]" ], "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", "emailRecipient": "[parameters('autoShutdownNotificationEmail')]" } } }, { "name": "microsoft.custom-script-linux-20210212103314", "apiVersion": "2015-01-01", "type": "Microsoft.Resources/deployments", "properties": { "mode": "incremental", "templateLink": { "uri": "https://catalogartifact.azureedge.net/publicartifactsmigration/microsoft.custom-script-linux-arm.2.0.56/Artifacts/MainTemplate.json" }, "parameters": { "vmName": { "value": "MsOps-Demo1" }, "location": { "value": "westeurope" }, "fileUris": { "value": [ "https://msopsdatasa.blob.core.windows.net/demo1uat/startup.sh?sp=r&se=2021-02-12T17:32:50Z&sv=2019-12-12&sr=b&sig=ur9ysJekXUusCiqQKpau561KIjP3zWuIHKDCmQobhyQ%3D" ] }, "commandToExecute": { "value": "sudo -u demo1uat bash -lc \"cd /home/demo1uat; ./startup.sh\"" } } }, "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]" ] } ], "outputs": { "adminUsername": { "type": "string", "value": "[parameters('adminUsername')]" } } }