Unable to create formula through ARM template in Dev Test Lab using image from Azure Compute Galleries
I created an ARM template to deploy the formula in the Dev Test Lab using image from Azure Compute Galleries as follows:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"formulaName": {
"defaultValue": "MyFormula",
"type": "String"
},
"labName": {
"defaultValue": "MyLab",
"type": "String"
},
"description": {
"defaultValue": "Example formula description",
"type": "String"
},
"offer": {
"defaultValue": "ODW00000.8.0.5.28.01offer"
"type": "String"
},
"publisher": {
"defaultValue": "ODW00000.8.0.5.28.01publishe"
"type": "String"
},
"sku": {
"defaultValue": "ODW00000.8.0.5.28.01sku"
"type": "String"
},
"size": {
"defaultValue": "Standard_D4s_v3",
"type": "String"
},
"userName": {
"type": "string",
"defaultValue": "Admin"
},
"password": {
"type": "securestring"
},
"diskType": {
"defaultValue": "StandardSSD",
"type": "String"
},
"osType": {
"defaultValue": "Windows",
"type": "String"
},
"version": {
"defaultValue": "latest",
"type": "String"
},
"labSubnetName": {
"defaultValue": "MyLabSubnet",
"type": "String"
},
"labVirtualNetworkId": {
"defaultValue": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Network/virtualNetworks/{vnet-name}",
"type": "String"
}
},
"variables": {
"formulaName": "[concat(parameters('labName'), '/', parameters('formulaName'))]"
},
"resources": [
{
"type": "Microsoft.DevTestLab/labs/formulas",
"apiVersion": "2018-09-15",
"name": "[variables('formulaName')]",
"properties": {
"description": "[parameters('description')]",
"formulaContent": {
"properties": {
"allowClaim": true,
"dataDiskParameters": [
{
"attachNewDataDiskOptions": {
"diskType": "[parameters('diskType')]"
}
}
],
"disallowPublicIpAddress": true,
"galleryImageReference": {
"osType": "[parameters('osType')]",
"publisher": "[parameters('publisher')]",
"offer": "[parameters('offer')]",
"sku": "[parameters('sku')]",
"version": "[parameters('version')]"
},
"size": "[parameters('size')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"labSubnetName": "[parameters('labSubnetName')]",
"labVirtualNetworkId": "[parameters('labVirtualNetworkId')]",
"networkInterface": {
"sharedPublicIpAddressConfiguration": {
"inboundNatRules": [
{
"transportProtocol": "tcp",
"backendPort": 3389
}
]
}
}
}
}
}
}
]
}
After deploying this ARM, the formula is created but it shows three values below
After clicking on Advance setting >> View ARM template, then the ARM template view as below
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"newVMName": {
"type": "string",
"defaultValue": "MyFormula"
},
"labName": {
"type": "string",
"defaultValue": "MyLab"
},
"size": {
"type": "string",
"defaultValue": "Standard_D4s_v3"
},
"userName": {
"type": "string",
"defaultValue": "Admin"
},
"password": {
"type": "securestring"
}
},
"variables": {
"labSubnetName": "DEVLAB-Subnet",
"labVirtualNetworkId": "[resourceId('Microsoft.DevTestLab/labs/virtualnetworks', parameters('labName'), variables('labVirtualNetworkName'))]",
"labVirtualNetworkName": "DEVLAB-Vnet",
"vmId": "[resourceId ('Microsoft.DevTestLab/labs/virtualmachines', parameters('labName'), parameters('newVMName'))]",
"vmName": "[concat(parameters('labName'), '/', parameters('newVMName'))]"
},
"resources": [
{
"apiVersion": "2018-10-15-preview",
"type": "Microsoft.DevTestLab/labs/virtualmachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"properties": {
"labVirtualNetworkId": "[variables('labVirtualNetworkId')]",
"notes": "t",
"size": "[parameters('size')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"isAuthenticationWithSshKey": false,
"labSubnetName": "[variables('labSubnetName')]",
"disallowPublicIpAddress": true,
"storageType": "StandardSSD",
"allowClaim": true,
"networkInterface": {
"sharedPublicIpAddressConfiguration": {
"inboundNatRules": [
{
"transportProtocol": "tcp",
"backendPort": 3389
}
]
}
}
}
}
],
"outputs": {
"labVMId": {
"type": "string",
"value": "[variables('vmId')]"
}
}
}
This is a template for creating a VM, but unfortunately, I was unable to make the VM because in this template there is no image parameter like sharedImageId is not present.
But when I tried to make the formula with the same image manually then after creation it showed me the image below:
After clicking on Advance setting >> View ARM template, then the ARM template view as below, Where we can see the sharedImageId keyword
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"newVMName": {
"type": "string",
"defaultValue": "ticketformula"
},
"labName": {
"type": "string",
"defaultValue": "DEVLAB"
},
"size": {
"type": "string",
"defaultValue": "Standard_D4s_v3"
},
"userName": {
"type": "string",
"defaultValue": "admin"
},
"password": {
"type": "securestring"
}
},
"variables": {
"labSubnetName": "DEVLAB-Subnet",
"labVirtualNetworkId": "[resourceId('Microsoft.DevTestLab/labs/virtualnetworks', parameters('labName'), variables('labVirtualNetworkName'))]",
"labVirtualNetworkName": "DEVLAB-Vnet",
"vmId": "[resourceId ('Microsoft.DevTestLab/labs/virtualmachines', parameters('labName'), parameters('newVMName'))]",
"vmName": "[concat(parameters('labName'), '/', parameters('newVMName'))]"
},
"resources": [
{
"apiVersion": "2018-10-15-preview",
"type": "Microsoft.DevTestLab/labs/virtualmachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"properties": {
"labVirtualNetworkId": "[variables('labVirtualNetworkId')]",
"notes": "t",
"sharedImageId": "/subscriptions/b2b47bb5-f3b7-4c27-XXXXXX/resourcegroups/devlab-rg/providers/microsoft.devtestlab/labs/devlab/sharedgalleries/baseimages/sharedimages/odw00000.8.0.5.28.01",
"size": "[parameters('size')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"isAuthenticationWithSshKey": false,
"labSubnetName": "[variables('labSubnetName')]",
"disallowPublicIpAddress": true,
"storageType": "StandardSSD",
"allowClaim": false,
"networkInterface": {
"sharedPublicIpAddressConfiguration": {
"inboundNatRules": [
{
"transportProtocol": "tcp",
"backendPort": 3389
}
]
}
}
}
}
],
"outputs": {
"labVMId": {
"type": "string",
"value": "[variables('vmId')]"
}
}
}
We can provision VM through this template using a formula we created manually.
I think something is wrong while creating the formula through the template
"galleryImageReference": {
"osType": "[parameters('osType')]",
"publisher": "[parameters('publisher')]",
"offer": "[parameters('offer')]",
"sku": "[parameters('sku')]",
"version": "[parameters('version')]"
}
My image location is in Azure compute galleries and we don't have any sharedImageId keyword in the official documentation https://video2.skills-academy.com/en-us/azure/templates/microsoft.devtestlab/labs/formulas?pivots=deployment-language-arm-template