Azure Linux VM Template - Parameter osProfile not allowed but without I can't connect - azure

I created a VM manually in Azure then used the automation script to generate a template to use from Visual Studio for a deployment however when I try to deploy it everything else works bar the VM which complains about the osProfile parameter, If I remove the osProfile section the deployment works but creates a VM I have no way to login to, all the examples I find say the osProfile I have should be fine so I'm a bit stuck
The template attached only works when the osProfile is commented out and then you can't login to the VM
Appreciate any suggestions as I've tried all sorts and am stumped now!
This is the error when the osProfile is included:
08:58:16 - Template deployment returned the following errors:
08:58:16 - 08:58:15 - Resource Microsoft.Compute/virtualMachines 'TheFaireyDevSolr' failed with message '{
08:58:16 - "error": {
08:58:16 - "code": "InvalidParameter",
08:58:16 - "target": "osProfile",
08:58:16 - "message": "Parameter 'osProfile' is not allowed."
08:58:16 - }
08:58:16 - }'
I updated the Password parameter to something more complex that I know meets the min reqs.
Below is the template json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "User name for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"disks_TheFaireyDevSolrDataDisk_name": {
"type": "string"
},
"disks_TheFaireyDevSolrOsDisk_name": {
"type": "string"
},
"virtualMachines_TheFaireyDevSolr_name": {
"type": "string"
},
"networkInterfaces_thefaireydevsolr_ni_name": {
"type": "string"
},
"networkSecurityGroups_TheFaireyDevSolr_nsg_name": {
"type": "string"
},
"publicIPAddresses_TheFaireyDevSolr_ip_name": {
"type": "string"
},
"virtualNetworks_TheFaireyDev_vnet_name": {
"type": "string"
},
"storageAccounts_thefaireydevmainstorage_name": {
"type": "string"
},
"extensions_Microsoft.Insights.VMDiagnosticsSettings_name": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Compute/disks",
"name": "[parameters('disks_TheFaireyDevSolrDataDisk_name')]",
"apiVersion": "2016-04-30-preview",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"accountType": "Standard_LRS",
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": 32
},
"dependsOn": []
},
{
"type": "Microsoft.Compute/disks",
"name": "[parameters('disks_TheFaireyDevSolrOsDisk_name')]",
"apiVersion": "2016-04-30-preview",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"accountType": "Standard_LRS",
"osType": "Linux",
"creationData": {
"createOption": "FromImage",
"imageReference": {
"id": "/Subscriptions/<YOUR SUBSCRIPTION ID>/Providers/Microsoft.Compute/Locations/uksouth/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/17.04/Versions/latest"
}
},
"diskSizeGB": 30
},
"dependsOn": []
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('virtualMachines_TheFaireyDevSolr_name')]",
"apiVersion": "2016-04-30-preview",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A1_v2"
},
"storageProfile": {
"osDisk": {
"osType": "Linux",
"name": "[parameters('disks_TheFaireyDevSolrOSDisk_name')]",
"createOption": "Attach",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"id": "[resourceId('Microsoft.Compute/disks', parameters('disks_TheFaireyDevSolrOsDisk_name'))]"
},
"diskSizeGB": 30
},
"dataDisks": [
{
"lun": 0,
"name": "[concat(parameters('virtualMachines_TheFaireyDevSolr_name'),'DataDisk')]",
"createOption": "Attach",
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"id": "[resourceId('Microsoft.Compute/disks', parameters('disks_TheFaireyDevSolrDataDisk_name'))]"
},
"diskSizeGB": 32
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachines_TheFaireyDevSolr_name')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_thefaireydevsolr_ni_name'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('https', '://', parameters('storageAccounts_thefaireydevmainstorage_name'), '.blob.core.windows.net', '/')]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/disks', parameters('disks_TheFaireyDevSolrOsDisk_name'))]",
"[resourceId('Microsoft.Compute/disks', parameters('disks_TheFaireyDevSolrDataDisk_name'))]",
"[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_thefaireydevsolr_ni_name'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_thefaireydevmainstorage_name'))]"
]
},
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('networkInterfaces_thefaireydevsolr_ni_name')]",
"apiVersion": "2017-03-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAddress": "10.0.0.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_TheFaireyDevSolr_ip_name'))]"
},
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_TheFaireyDev_vnet_name')), '/subnets/default')]"
}
}
}
],
"dnsSettings": {
"dnsServers": []
},
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_TheFaireyDevSolr_nsg_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_TheFaireyDevSolr_ip_name'))]",
"[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_TheFaireyDev_vnet_name'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_TheFaireyDevSolr_nsg_name'))]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[parameters('networkSecurityGroups_TheFaireyDevSolr_nsg_name')]",
"apiVersion": "2017-03-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"securityRules": [
{
"name": "default-allow-ssh",
"properties": {
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1000,
"direction": "Inbound"
}
}
]
},
"dependsOn": []
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddresses_TheFaireyDevSolr_ip_name')]",
"apiVersion": "2017-03-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4
},
"dependsOn": []
},
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworks_TheFaireyDev_vnet_name')]",
"apiVersion": "2017-03-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/24"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
],
"virtualNetworkPeerings": []
},
"dependsOn": []
},
{
"type": "Microsoft.Storage/storageAccounts",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "Storage",
"name": "[parameters('storageAccounts_thefaireydevmainstorage_name')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"tags": {},
"scale": null,
"properties": {},
"dependsOn": []
},
//{
// "type": "Microsoft.Compute/virtualMachines/extensions",
// "name": "[parameters('extensions_Microsoft.Insights.VMDiagnosticsSettings_name')]",
// "apiVersion": "2016-04-30-preview",
// "location": "[resourceGroup().location]",
// "scale": null,
// "properties": {
// "publisher": "Microsoft.OSTCExtensions",
// "type": "LinuxDiagnostic",
// "typeHandlerVersion": "2.3",
// "autoUpgradeMinorVersion": true,
// "settings": {
// "xmlCfg": "PFdhZENmZz48RGlhZ25vc3RpY01vbml0b3JDb25maWd1cmF0aW9uIG92ZXJhbGxRdW90YUluTUI9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0ludGVyZmFjZVxUb3RhbENvbGxpc2lvbnMiIHNhbXBsZVJhdGU9IlBUMTVTIiB1bml0PSJDb3VudCI+PGFubm90YXRpb24gZGlzcGxheU5hbWU9Ik5ldHdvcmsgY29sbGlzaW9ucyIgbG9jYWxlPSJlbi11cyIvPjwvUGVyZm9ybWFuY2VDb3VudGVyQ29uZmlndXJhdGlvbj48L1BlcmZvcm1hbmNlQ291bnRlcnM+PE1ldHJpY3MgcmVzb3VyY2VJZD0iL3N1YnNjcmlwdGlvbnMvNDkyMzY4ZWEtYTA2Mi00MGQ0LWI2YjUtZTU0ZGI5YTkxZDA2L3Jlc291cmNlR3JvdXBzL0F4aW9tRGV2L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29tcHV0ZS92aXJ0dWFsTWFjaGluZXMvQXhpb21EZXZTb2xyIj48TWV0cmljQWdncmVnYXRpb24gc2NoZWR1bGVkVHJhbnNmZXJQZXJpb2Q9IlBUMUgiLz48TWV0cmljQWdncmVnYXRpb24gc2NoZWR1bGVkVHJhbnNmZXJQZXJpb2Q9IlBUMU0iLz48L01ldHJpY3M+PC9EaWFnbm9zdGljTW9uaXRvckNvbmZpZ3VyYXRpb24+PC9XYWRDZmc+"
// },
// "protectedSettings": {}
// },
// "dependsOn": [
// "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachines_TheFaireyDevSolr_name'))]"
// ]
//}
],
"variables": {}
}
and the parameters json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"value": "thefairey"
},
"disks_TheFaireyDevSolrDataDisk_name": {
"value": "TheFaireyDevSolrDataDisk"
},
"disks_TheFaireyDevSolrOsDisk_name": {
"value": "TheFaireyDevSolrOsDisk"
},
"virtualMachines_TheFaireyDevSolr_name": {
"value": "TheFaireyDevSolr"
},
"networkInterfaces_thefaireydevsolr_ni_name": {
"value": "TheFaireyDevSolr-ni"
},
"networkSecurityGroups_TheFaireyDevSolr_nsg_name": {
"value": "TheFaireyDevSolr-nsg"
},
"publicIPAddresses_TheFaireyDevSolr_ip_name": {
"value": "TheFaireyDevSolr-ip"
},
"virtualNetworks_TheFaireyDev_vnet_name": {
"value": "TheFaireyDev-vnet"
},
"storageAccounts_thefaireydevmainstorage_name": {
"value": "thefaireydevmainstorage"
},
"extensions_Microsoft.Insights.VMDiagnosticsSettings_name": {
"value": "TheFaireyDevSolr/Microsoft.Insights.VMDiagnosticsSettings"
}
}
}
UPDATE
I started with a plain Ubuntu VM template from VS and started adding stuff and the problem regarding the osProfile starts happening as soon as I try to add a Managed Disk as the OS disk, I removed that but tried with a managed disk for the DataDisk and got the error "Addition of a managed disk to a VM with blob based disks is not supported"
Not sure if it helps but I believe the issue may be related to having a Managed Disk as the OS disk. Will continue to research and experiment!

Ok worked it out, the automation script I guess isn't quite up to speed with Managed Disks which is fair enough as they are in preview, when I ran it it created a separate resource for the OS Managed disk.
In order to have a managed disk as the OS disk you need to define the storageProfile as follows:
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"osType": "Linux",
"name": "YourOSDiskName",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"diskSizeGB": 32
},
}
The important thing is that you don't need to define the managed disk as a separate resource, it appears the VM creation handles creation of the Managed disk resource and you just need to specify the storageAccountType for the disk.
After that everything appears to work correctly.
Trying to Attach a previously defined Managed Disk based on an OS image and specifying the id parameter in the managedDisk settings in the VM doesn't appear to work.
Hope this helps someone!

osProfile is required if the VHD is sysprepped & generalized - meaning when it starts you want to run through first time setup. If the image is not generalized then you can't specify the osProfile (e.g. user/pass) because it already exists.
re: ManagedDisks - you can use an implicit disk or explicit. If you wanted to use one of your own disk images your storageProfile would be:
"storageProfile": {
"imageReference": {
"id": "[parameters('imageResourceId')]"
}
}
If you want to use your own disk (say, created from a snapshot) you would use:
"storageProfile": {
"osDisk": {
"osType": "[parameters('osType')]",
"name": "[parameters('managedOsDiskName')]",
"createOption": "Attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', parameters('managedOsDiskName'))]"
},
"caching": "ReadWrite"
}
}
There are a lot of options available w/ managed disks... This doc isn't perfect but does help.

Related

getting error "The schedule should be created" while creating VM shutdown schedule using ARM template

I am getting the following error when I tried creating a shutdown schedule for VM in azure using the ARM template.
{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
"details": [
{
"code": "InvalidScheduleId",
"message": "The schedule should be created in subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, resource group shared-infra-rc-rg and with name shutdown-computevm-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx-pg-rc."
}
]
}
Part of my ARM template
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-03-01",
"name": "[variables('vmName')]",
"location": "[parameters('location')]",
"tags": {"envId":"[parameters('envId')]"},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('VmSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "[variables('osDiskType')]"
}
},
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "[parameters('ubuntuOSVersion')]",
"version": "latest"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPasswordOrKey')]",
"linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]",
"customData": "[parameters('customData')]"
}
}
},
{
"name": "[variables('autoshutdownScheduleName')]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2018-09-15",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]"
],
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]",
"notificationSettings": {
"status": "Disabled",
"notificationLocale": "en"
}
}
}
Other observations
all other resources are getting created except the schedule.
Edits
The name needs to be exactly 'shutdown-computevm-${vmName}'
bicep sample:
resource vmScheduledShutdown 'microsoft.devtestlab/schedules#2018-09-15' = {
name: 'shutdown-computevm-${vmName}'
location: Location
properties: {
status: 'Enabled'
taskType: 'ComputeVmShutdownTask'
dailyRecurrence: {
time: '0400'
}
timeZoneId: 'Central European Standard Time'
targetResourceId: resourceId('Microsoft.Compute/virtualMachines', vmName)
}
dependsOn:[
vm
]
}
We have tried to create VM with auto shutdown enabled using the below ARM template and we are able to deploy it successfully .
ARM template :-
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
"adminPassword": {
"type": "secureString",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"dnsLabelPrefix": {
"type": "string",
"defaultValue": "[toLower(format('{0}-{1}', parameters('vmName'), uniqueString(resourceGroup().id, parameters('vmName'))))]",
"metadata": {
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
}
},
"publicIpName": {
"type": "string",
"defaultValue": "myPublicIP",
"metadata": {
"description": "Name for the Public IP used to access the Virtual Machine."
}
},
"publicIPAllocationMethod": {
"type": "string",
"defaultValue": "Dynamic",
"allowedValues": [
"Dynamic",
"Static"
],
"metadata": {
"description": "Allocation method for the Public IP used to access the Virtual Machine."
}
},
"publicIpSku": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"Standard"
],
"metadata": {
"description": "SKU for the Public IP used to access the Virtual Machine."
}
},
"OSVersion": {
"type": "string",
"defaultValue": "2019-datacenter-gensecond",
"allowedValues": [
"2019-datacenter-gensecond",
"2019-datacenter-core-gensecond",
"2019-datacenter-core-smalldisk-gensecond",
"2019-datacenter-core-with-containers-gensecond",
"2019-datacenter-core-with-containers-smalldisk-g2",
"2019-datacenter-smalldisk-gensecond",
"2019-datacenter-with-containers-gensecond",
"2019-datacenter-with-containers-smalldisk-g2",
"2016-datacenter-gensecond"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched Gen2 image of this given Windows version."
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_D2s_v3",
"metadata": {
"description": "Size of the virtual machine."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"vmName": {
"type": "string",
"defaultValue": "simple-vm",
"metadata": {
"description": "Name of the virtual machine."
}
},
"autoShutdownStatus": {
"type": "string",
"defaultValue": "Enabled"
},
"autoShutdownTime": {
"type": "string",
"defaultValue": "19:00"
},
"autoShutdownTimeZone": {
"type": "string",
"defaultValue": "UTC"
},
"autoShutdownNotificationStatus": {
"type": "string",
"defaultValue": "Enabled"
},
"autoShutdownNotificationLocale": {
"type": "string",
"defaultValue": "en"
},
"autoShutdownNotificationEmail": {
"type": "string",
"defaultValue": "youremailID#microsoft.com"
}
},
"variables": {
"storageAccountName": "[format('bootdiags{0}', uniqueString(resourceGroup().id))]",
"nicName": "myVMNic",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"virtualNetworkName": "MyVNET",
"networkSecurityGroupName": "default-NSG"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage"
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2021-02-01",
"name": "[parameters('publicIpName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('publicIpSku')]"
},
"properties": {
"publicIPAllocationMethod": "[parameters('publicIPAllocationMethod')]",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsLabelPrefix')]"
}
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2021-02-01",
"name": "[variables('networkSecurityGroupName')]",
"location": "[parameters('location')]",
"properties": {
"securityRules": [
{
"name": "default-allow-3389",
"properties": {
"priority": 1000,
"access": "Allow",
"direction": "Inbound",
"destinationPortRange": "3389",
"protocol": "Tcp",
"sourcePortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*"
}
}
]
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2021-02-01",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
}
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
]
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2021-02-01",
"name": "[variables('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
}
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-03-01",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('OSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
}
},
"dataDisks": [
{
"diskSizeGB": 1023,
"lun": 0,
"createOption": "Empty"
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"name": "[concat('shutdown-computevm-', parameters('vmName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
],
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"notificationLocale": "[parameters('autoShutdownNotificationLocale')]",
"timeInMinutes": "30",
"emailRecipient": "[parameters('autoShutdownNotificationEmail')]"
}
}
}
],
"outputs": {
"hostname": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))).dnsSettings.fqdn]"
}
}
}
Sample OUTPUT for reference:-
Auto shut down enabled:
For more information refer this MS Q&A as suggested by JamesTran-MSFT

The requested size for resource '' is currently not available in location '' zones

The Problem
I am receiving the following error when attempting to deploy a Windows 10 VM of size F1S on Azure using my action pack license:
The template deployment failed with error: 'The resource with id:
'/subscriptions/7d01bbc6-ef9b-4ad6-8c6e-baea1e0bd02d/resourceGroups/AzTech/providers/Microsoft.Compute/virtualMachines/Windows10'
failed validation with message: 'The requested size for resource
'/subscriptions/7d01bbc6-ef9b-4ad6-8c6e-baea1e0bd02d/resourceGroups/AzTech/providers/Microsoft.Compute/virtualMachines/Windows10'
is currently not available in location 'eastus' zones '' for
subscription '...'. Please try
another size or deploy to a different location or zones. See
https://aka.ms/azureskunotavailable for details.'.'. (Code:
InvalidTemplateDeployment)
Attempted Solutions
First, I've ensured availability. According to this documentation, Fs-series are available in all regions.
Second, following troubleshooting steps here, I am able to confirm availability for EastUS when running Get-AzureRmComputeResourceSku | where {$_.Locations -icontains "eastus"}:
Last, I have attempted the solution here, but selecting HDD did not work.
Additional Info
In case it's useful, the template for this VM is here:
{
"$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"
}
},
"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": [
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2019-07-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[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('networkSecurityGroupName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-02-01",
"location": "[parameters('location')]",
"properties": {
"securityRules": "[parameters('networkSecurityGroupRules')]"
}
},
{
"name": "[parameters('virtualNetworkName')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-09-01",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": "[parameters('addressPrefixes')]"
},
"subnets": "[parameters('subnets')]"
}
},
{
"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": "2019-07-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": {
"publisher": "MicrosoftWindowsDesktop",
"offer": "Windows-10",
"sku": "19h2-pro",
"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
}
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
Edit 1
Following one suggestion, running Get-AzVMSize -Location 'eastus' confirms that F1s should be available:
I believe to get what is actually available for your subscription\location combination you should use:
Get-AzVMSize -Location %location%
Since Get-AzComputeResourceSku returns all the possible SKUs available for the location disregarding limitations of your subscription
Edit: In this case the issue was with the fact that the template was deploying a spot instance, not a regular vm, by removing the spot instance OP was able to use the desired VM size.
Spot VMs are not available for all subscriptions and I presume this is your issue here, please look at the table:
To create desired Spot VM please switch to a subscription which allows it.

Deploy Azure VM , ARM template with basic software

I am trying to create Azure VM with ARM template with basic software, I've written ARM template for this but I am unable to deploy VM in this template.
Please refer below error :-
{"code":"DeploymentFailed","message":"At least one resource deployment
operation failed. Please list deployment operations for details.
Please see https://aka.ms/arm-debug for usage
details.","details":[{"code":"BadRequest","message":"{\r\n \"error\":
{\r\n \"code\": \"InvalidTemplate\",\r\n \"message\": \"Unable to
process template language expressions for resource
'/subscriptions/b312b990-e271-4a63-a63a-d6768e1c7aad/resourceGroups/rohittestrg/providers/Microsoft.Compute/virtualMachines/mydevboxvm1'
at line '110' and column '9'. 'The template parameter ' ' is not
found. Please see https://aka.ms/arm-template/#parameters for usage
details.'\"\r\n }\r\n}"}]}.
I used this link for reference
https://raw.githubusercontent.com/FBoucher/SimpleDevBox/master/azure-deploy.json
Powershell script:
https://raw.githubusercontent.com/rt7055/Testrepo/master/simpledevbox.ps1?token=AtI3tjSPO7YLVq2xI2zPwznWAZPiWzd2ks5cWbmOwA%3D%3D
I am trying to do this on Windows server.
This would be great if you can provide solution for this.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters":{
"scriptURL": {
"type":"string"
},
"adminUsername": {
"type":"string"
},
"adminPassword": {
"type":"string"
}
},
"variables": {
"scriptURL":" https://raw.githubusercontent.com/rt7055/Testrepo/master/simpledevbox.ps1?token=AtI3to3qKSHYNEZh9tfMfXZQ-P4zRULeks5cWZ5kwA%3D%3D "
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[toLower('mydevboxstoragekata')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "mydevbox Storage Account"
},
"properties": {
"accountType":"Standard_LRS"
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "mydevbox-PublicIP",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "PublicIPAddress"
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "mydevbox-VirtualNetwork",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualNetwork"
},
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "mydevbox-VirtualNetwork-Subnet",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/networkInterfaces",
"name": "mydevbox-NetworkInterface",
"location": "[resourceGroup().location]",
"dependsOn": [
"Microsoft.Network/publicIPAddresses/mydevbox-PublicIP",
"Microsoft.Network/virtualNetworks/mydevbox-VirtualNetwork"
],
"tags": {
"displayName": "mydevbox Network Interface"
},
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', 'mydevbox-PublicIP')]"
},
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', 'mydevbox-VirtualNetwork'), '/subnets/mydevbox-VirtualNetwork-Subnet')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "mydevboxvm1",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', toLower('mydevboxstoragekata'))]",
"Microsoft.Network/networkInterfaces/mydevbox-NetworkInterface"
],
"tags": {
"displayName": "mydevboxvm1"
},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A1"
},
"osProfile": {
"computerName": "mydevboxvm1",
"adminUsername": "[parameters('')]",
"adminPassword": "[parameters('')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2012-R2-Datacenter",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks":[
{
"diskSizeGB": 1023,
"lun": 0,
"createOption": "Empty"}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', 'mydevbox-NetworkInterface')]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('http://', toLower('mydevboxstoragekata'), '.blob.core.windows.net')]"
}
}
},
"resources": [
{
"apiVersion": "2017-03-30",
"type": "extensions",
"name": "config-app",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', 'mydevboxvm1')]"
],
"tags": {
"displayName": "config-app"
},
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[variables('scriptURL')]"
]
},
"protectedSettings": {
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', './simpledevbox.ps1')]"
}
}
}
]
}
],
"outputs": {}
}
You forgot to pass parameter names here:
"adminUsername": "[parameters('')]",
"adminPassword": "[parameters('')]"
this should be this:
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"

Addition of a managed disk to a VM with blob based disks is not supported

I am trying to deploy VM from managed image and data disk using the following with the API version "2015-06-15" for the VM. I am unable to attach the data disk to the VM when I run below ARM template. I tried the preview as well but the preview API version doesn't support the storage account. I have commented on the same while trying the preview API version and latest version.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"customVmName": {
"type": "string",
"metadata": {
"description": "This is the name of the your VM"
}
},
"osDiskVhdUri": {
"type": "string",
"metadata": {
"description": "Uri of the your user image"
}
},
"adminUserName": {
"type": "string",
"metadata": {
"description": "User Name for the Virtual Machine"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine"
}
},
"userImageStorageAccountName": {
"type": "string",
"metadata": {
"description": "This is the name of the your storage account"
}
},
"osType": {
"type": "string",
"allowedValues": [
"Windows",
"Linux"
],
"metadata": {
"description": "This is the OS that your VM will be running"
}
},
"vmSize": {
"type": "string",
"metadata": {
"description": "This is the size of your VM"
}
},
"ExistingVnet": {
"allowedValues": [ "new", "existing" ],
"type": "string",
"metadata": {
"description": "Select if this template needs a new VNet or will reference an existing VNet"
}
},
"ExistingVnetName": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "New or Existing VNet Name"
}
},
"ExistingSubnetName": {
"type": "string",
"defaultValue": "subnet",
"metadata": {
"description": "Subnet Name"
}
},
"existingdiagnosticsStorageAccountName": {
"type": "string"
}
},
"variables": {
"vmName": "[parameters('customVmName')]",
"nicName": "[parameters('customVmName')]",
"apiVersion": "2015-06-15",
"vnetID": "[resourceId('ISE-MarkW', 'Microsoft.Network/virtualNetworks', parameters('ExistingVnetName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('ExistingSubnetName'))]",
},
"resources": [
{
"apiVersion": "2016-06-01",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"type": "Microsoft.Compute/disks",
"name": "[concat(variables('vmName'),'-datadisk1')]",
"apiVersion": "2017-03-30",
"location": "[resourceGroup().location]",
"sku": {
"name": "Premium_LRS"
},
"properties": {
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": 128
}
},
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"osDisk": {
"name": "[concat(variables('vmName'),'-osDisk')]",
"osType": "[parameters('osType')]",
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "[parameters('osDiskVhdUri')]"
},
"vhd": {
"uri": "[concat(reference(concat('/subscriptions/xxxx/resourceGroups/inflabimages-rg/providers/Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob, 'vhds/',variables('vmName'), uniquestring(resourceGroup().id), 'osDisk.vhd')]"
}
},
"dataDisks": [
{
"lun": 0,
"name": "[concat(variables('vmName'),'-datadisk1')]",
"createOption": "Attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
},
"caching": "ReadWrite"
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('http://', parameters('existingdiagnosticsStorageAccountName'), '.blob.core.windows.net')]"
}
}
}
}
]
}
I am getting VM deployment failed below message
"error": {
"code": "OperationNotAllowed",
"message": "Addition of a managed disk to a VM with blob based disks is not supported.",
"target": "dataDisk"
}
you are not using managed disk for OS disk, sample for managed disk with data disks:
"imageReference": {
"id": "[resourceId('Microsoft.Compute/images', variables('imageName'))]"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
},
"dataDisks": [
{
"lun": 2,
"createOption": "Empty",
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"diskSizeGB": 128
}
]
I was able to attach the data disk by using image reference instead of using the VHD URI with API version 2018-06-01.
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
"[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
],
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySets_name'))]"
},
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"id": "[parameters('virtualMachines_image')]"
},
"osDisk": {
"name": "[concat(variables('vmName'),'-osDisk')]",
"osType": "[parameters('osType')]",
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {
"storageAccountType":"Premium_LRS"
}
},
"dataDisks": [
{
"lun": 1,
"name": "[concat(variables('vmName'),'-datadisk1')]",
"createOption": "Attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]",
"storageAccountType":"Premium_LRS"
},
"caching": "None"
}
]
},

InvalidResourceReference when deploying ARM template for VM

I downloaded ARM template from Azure for deploying VM. I did not modify the script in any way. When I run the deploy.ps1 script I get the following error
New-AzureRmResourceGroupDeployment : 1:05:56 PM - Resource Microsoft.Network/networkInterfaces 'win2016vm293' failed
with message '{
"error": {
"code": "InvalidResourceReference",
"message": "Resource /subscriptions/<subscriptionId>/resourceGroups/win2016vm2/providers/Micros
oft.Network/networkSecurityGroups/Win2016vm2-nsg referenced by resource /subscriptions/<subscriptionId>/resourceGroups/Win2016FromScript/providers/Microsoft.Network/networkInterfaces/win2016vm293 was not found.
Please make sure that the referenced resource exists, and that both resources are in the same region.",
"details": []
}
}'
The following is the template.js file.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"virtualMachineSize": {
"type": "string"
},
"adminUsername": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"addressPrefix": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"subnetPrefix": {
"type": "string"
},
"publicIpAddressName": {
"type": "string"
},
"publicIpAddressType": {
"type": "string"
},
"publicIpAddressSku": {
"type": "string"
},
"autoShutdownStatus": {
"type": "string"
},
"autoShutdownTime": {
"type": "string"
},
"autoShutdownTimeZone": {
"type": "string"
},
"autoShutdownNotificationStatus": {
"type": "string"
}
},
"variables": {
"vnetId": "[resourceId('win2016vm2','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2018-04-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"provisionVmAgent": "true"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
},
"dataDisks": []
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
}
}
},
{
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"timeInMinutes": "30"
}
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
},
{
"name": "[parameters('virtualNetworkName')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"subnets": [
{
"name": "[parameters('subnetName')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix')]"
}
}
]
}
},
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2018-04-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]",
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIpAddress": {
"id": "[resourceId('win2016vm2','Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
}
}
}
],
"enableAcceleratedNetworking": true,
"networkSecurityGroup": {
"id": "[resourceId('win2016vm2', 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]"
}
}
},
{
"name": "[parameters('publicIpAddressName')]",
"type": "Microsoft.Network/publicIpAddresses",
"apiVersion": "2017-08-01",
"location": "[parameters('location')]",
"properties": {
"publicIpAllocationMethod": "[parameters('publicIpAddressType')]"
},
"sku": {
"name": "[parameters('publicIpAddressSku')]"
}
},
{
"name": "[parameters('networkSecurityGroupName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2018-01-01",
"location": "[parameters('location')]",
"properties": {
"securityRules": [
{
"name": "RDP",
"properties": {
"priority": 300,
"protocol": "TCP",
"access": "Allow",
"direction": "Inbound",
"sourceApplicationSecurityGroups": [],
"destinationApplicationSecurityGroups": [],
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "*",
"destinationPortRange": "3389"
}
}
]
}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
After running the script I see that only Win2016vm2-nsg (Network security group), as well as the IP and the VNet resources are created.
In the template, the section for creating Microsoft.Network/networkInterfaces contains dependsOn section with networkSecurityGroups resource name in it, which seems correct. So I'm not sure what is wrong here.
Your template is using hardcoded resourceGroup name for several resources, you need to amend that, change 'win2016vm2' to a resourceGroup you are deploying to, or remove resourceGroup from resourceId() function altogether.

Resources