ARM template for Shared disk create and attach is removing the existing data disk when attached - arm-template

When trying to add the shared disks to a existing VM with data disks, the existing disks are removed from the Virtual machine as part of ARM template deployment. Below is the ARM template.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"Shareddiskname": {
"type": "array",
"metadata": {
"description": "description"
}
},
"location": {
"type": "string",
"metadata": {
"description": "description"
}
},
"vmname": {
"type": "array",
"metadata": {
"description": "description"
}
}
},
"functions": [],
"variables": {},
"resources": [
{
"type": "Microsoft.Compute/disks",
"apiVersion": "2021-08-01",
"name": "[parameters('Shareddiskname')[copyIndex()].name]",
"location": "[parameters('location')]",
"sku": {
"name": "StandardSSD_LRS"
},
"copy": {
"name": "shrdcopy",
"count": "[length(parameters('Shareddiskname'))]"
},
"properties": {
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": "[parameters('Shareddiskname')[copyIndex()].diskSizeGB]",
"maxShares": "[parameters('Shareddiskname')[copyIndex()].maxShares]"
}
},
{
"name": "[parameters('vmname')[copyIndex()]]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-03-01",
"location": "[resourceGroup().location]",
"copy": {
"name": "vmcopy",
"count": "[length(parameters('vmname'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Compute/disks', parameters('Shareddiskname')[copyIndex()].name)]"
],
"properties": {
"storageProfile": {
"copy": [
{
"name": "dataDisks",
"count": "[length(parameters('Shareddiskname'))]",
"input": {
"name": "[parameters('Shareddiskname')[copyIndex('dataDisks')].name]",
"lun": "[parameters('Shareddiskname')[copyIndex('dataDisks')].lun]",
"createOption": "attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks',parameters('Shareddiskname')[copyIndex('dataDisks')].name)]"
}
}
}
]
}
}
}
],
"outputs": {}
}
validation of template with -whatif shows the below output-- its replacing the existing disk 01 and 02 with shared disks. How can I add the shared disks with existing data disks
~ Microsoft.Compute/virtualMachines/testvm01 [2021-03-01]
~ properties.storageProfile.dataDisks: [
~ 0:
- caching: "None"
- toBeDetached: false
- writeAcceleratorEnabled: false
~ lun: 0 => 2
~ name: "01" => "sharedsk-01"
~ 1:
- caching: "None"
- toBeDetached: false
- writeAcceleratorEnabled: false
~ lun: 1 => 3
~ name: "02" => "sharedsk-02"
]

Related

Assigning Static Ip to nic(copy loop) in ARM template

I am trying to change dynamic private ip allocated VM to Static IP via ARM template.
It works for a single vm. But facing issue for multiple VM's deployment. I am trying nested deployment.
The error I am facing is: The template reference "nic-"somevmname"-01" is
not valid: could not find template resource or resource copy with this name.
I am not able to figure out what is wrong with the nested resource
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"VnetResourceGroup": {
"type": "string"
},
"VnetName": {
"type": "string"
},
"SubnetName": {
"type": "string"
},
"adminusername": {
"type": "string",
"metadata": {
"description": "Admin username for VM"
}
},
"adminpassword": {
"type": "string"
},
"vm-name": {
"type": "string",
"metadata": {
"description": ""
}
},
"virtualMachineCount": {
"type": "int",
"metadata": {
"description": "Number of Virtual machines to be deployed"
}
},
"vmSize": {
"type": "string",
"metadata": {
"description": "description"
}
},
"vm-image-name": {
"type": "string",
"metadata": {
"description": "description"
}
},
"vm-image-rg": {
"type": "string",
"metadata": {
"description": "description"
}
},
"dataDisksize": {
"type": "int"
},
"datadisks-count": {
"type": "int"
},
"osDiskType": {
"type": "string"
},
"osDiskSize": {
"type": "int",
"metadata": {
"description": "description"
}
},
"maxAvailabilityzones": {
"type": "int",
"metadata": {
"description": "description"
}
}
},
"variables": {
"ImageReferenceId": "[concat(subscription().id, '/resourceGroups/', parameters('vm-image-rg'), '/providers/Microsoft.Compute/images/', parameters('vm-image-name'))]",
"vnetId": "[concat(subscription().id, '/resourceGroups/', parameters('VnetResourceGroup'), '/providers/Microsoft.Network/virtualNetworks/', parameters('VnetName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('nic-',parameters('vm-name'),'-0', copyIndex(1))]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"copy": {
"name": "nicLoop",
"count": "[parameters('virtualMachineCount')]"
},
"properties": {
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vm-name'),'-0', copyIndex(1))]",
"apiVersion": "2020-06-01",
"location": "[resourceGroup().location]",
"zones": [
"[string(add(mod(copyIndex(0), parameters('maxAvailabilityzones')), 1))]"
],
"copy": {
"name": "virtualMachineLoop",
"count": "[parameters('virtualMachineCount')]"
},
"dependsOn": [
"nicLoop"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[concat(parameters('vm-name'),'-0', copyIndex(1))]",
"adminusername": "[parameters('adminusername')]",
"adminPassword": "[parameters('adminpassword')]"
},
"storageProfile": {
"copy": [
{
"name": "dataDisks",
"count": "[parameters('datadisks-count')]",
"input": {
"lun": "[copyIndex('dataDisks')]",
"name": "[concat('dataDisk',copyIndex('dataDisks',1),'-',parameters('vm-name'),'-0',copyIndex(1))]",
"createOption": "Empty",
"diskSizeGB": "[parameters('dataDisksize')]"
}
}
],
"imageReference": { "id": "[variables('ImageReferenceId')]" },
"osDisk": {
"name": "[concat('osdisk-',parameters('vm-name'),'-0', copyIndex(1))]",
"createOption": "FromImage",
"caching": "ReadWrite",
"diskSizeGB": "[parameters('osDiskSize')]",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat('nic-',parameters('vm-name'),'-0', copyIndex(1)))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "StaticIP",
"apiVersion": "2020-06-01",
"dependsOn": [
"nicLoop",
"virtualMachineLoop"
],
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"parameters": {
"SubnetRef": {
"value": "[variables('SubnetRef')]"
},
"virtualMachineCount": {
"value": "[parameters('virtualMachineCount')]"
},
"vm-name": {
"value": "[parameters('vm-name')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subnetRef": {
"type": "string"
},
"virtualMachineCount": {
"type": "int",
"metadata": {
"description": "Number of Virtual machines to be deployed"
}
},
"vm-name": {
"type": "string",
"metadata": {
"description": "description"
}
}
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('assignstaticip',copyIndex(1))]",
"apiVersion": "2020-05-01",
"location": "[resourceGroup().location]",
"copy": {
"name": "nicStaticIpLoop",
"count": "[parameters('virtualMachineCount')]"
},
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[reference(concat('nic-',parameters('vm-name'),'-0', copyIndex('nicStaticIpLoop',1))).ipConfigurations[0].properties.privateIPAddress]",
"subnet": {
"id": "[parameters('subnetRef')]"
}
}
}
]
}
}
]
}
}
}
],
"outputs": {
"vm-ipaddress": {
"type": "array",
"copy": {
"count": "[parameters('virtualMachineCount')]",
"input": "[reference(concat('nic-',parameters('vm-name'),'-0', copyIndex(1))).ipConfigurations[0].properties.privateIPAddress]"
}
},
"vm-name": {
"type": "array",
"copy": {
"count": "[parameters('virtualMachineCount')]",
"input": "[concat(parameters('vm-name'),'-0', copyIndex(1))]"
}
}
}
}
Thank you #Anonymouus, for sharing the update . And bring the question for how to change dynamic private ip allocated VM to Static IP via ARM template, It will be really helpful for the SO community for similar issue who encounter the same so that they can find & fix their problem by posting it as an answer .
As stated in the given Blog which is Author by #Praveen.
To change the dynamic IP to static IP through ARM TEMPLATE we can use the below example of template,
ARM TEMPLATE:-
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "[concat('StaticIp', copyIndex())]",
"dependsOn": [
"nicLoop"
],
"copy": {
"name": "ipLoop",
"count": "[parameters('ServerInstanceCount')]"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(parameters('ServerNamePrefix'),padLeft(copyIndex(),3,'0'),'-NIC')]",
"apiVersion": "2018-03-01",
"location": "[resourceGroup().location]",
"tags": "[parameters('tagValues')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[reference(concat(parameters('ServerNamePrefix'),padLeft(copyIndex(),3,'0'),'-NIC')).ipConfigurations[0].properties.privateIPAddress]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"enableAcceleratedNetworking": true
}
}
]
}
}
}
For more information please refer the below links:-
SO THREAD| Static ip addresses on Azure & Nested Copy loop using ARM Template.

Add VM to Recovery Services Vault in different Resource Group

I'm fairly new to Azure ARM Templates so any help it's appreciated. I'm trying to deploy various vm's and at the same time configure the backup but I'm getting this error:
"InvalidTemplate","message":"Deployment template validation failed: 'The template resource '[concat(parameters('VMNames')[copyIndex()], '-' , 'BackupIntent')]' at line '195' and column '9' is not valid: The language expression property '0' can't be evaluated.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"VnetResourceGroup": {
"type": "String"
},
"VnetName": {
"type": "String"
},
"SubnetName": {
"type": "String"
},
"OSVersion": {
"defaultValue": "2016-Datacenter",
"allowedValues": [
"2016-Datacenter",
"2019-Datacenter",
"2022-datacenter",
"2022-datacenter-g2",
"2019-datacenter-gensecond",
"2016-datacenter-gensecond"
],
"type": "String",
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version."
}
},
"virtualMachineSize": {
"type": "String"
},
"AdminUsername": {
"defaultValue": "evtcladm",
"type": "String",
"metadata": {
"description": "Admin username for VM"
}
},
"AdminPassword": {
"type": "SecureString",
"metadata": {
"description": "Admin password for VM"
}
},
"backupVaultName": {
"defaultValue": "vault-corenet-01",
"allowedValues": [
"vault-corenet-01",
"vault-cps-01",
"Vault-Multi-VM",
"Vault-RecoveryMultiVM",
"vault-evt-cps-chile"
],
"type": "String",
"metadata": {
"description": "Recovery Vault to be used for backup"
}
},
"BackupPolicy": {
"defaultValue": "FASE1",
"type": "String"
},
"RSVResourceGroup": {
"type": "String"
},
"backupFabricName": {
"defaultValue": "Azure",
"type": "String"
},
"VMNames": {
"type": "String"
},
"numberOfInstances": {
"type": "Int",
"metadata": {
"description": "Number of VMs to deploy"
}
}
},
"variables": {
"v2Vm": "vm;iaasvmcontainerv2;",
"maxZones": 3,
"nicSuffix": "NIC",
"networkInterfaceName": "[concat(parameters('VMNames'), variables('nicSuffix'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2016-03-30",
"name": "[concat(variables('networkInterfaceName'), copyindex(1))]",
"location": "[resourceGroup().location]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId(parameters('VnetResourceGroup'),'Microsoft.Network/virtualNetworks/subnets',parameters('VnetName'),parameters('subnetName'))]"
}
}
}
]
},
"copy": {
"name": "nicLoop",
"count": "[parameters('numberOfInstances')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"name": "[concat(parameters('VMNames'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"nicLoop"
],
"zones": [
"[string(add(mod(copyIndex(0), variables('maxZones')), 1))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"osProfile": {
"computerName": "[concat(parameters('VMNames'), copyIndex(1))]",
"adminUsername": "[parameters('AdminUsername')]",
"adminPassword": "[parameters('AdminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('OSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('networkInterfaceName'), copyindex(1)))]"
}
]
}
},
"copy": {
"name": "virtualMachineLoop",
"count": "[parameters('numberOfInstances')]"
}
},
{
"apiVersion": "2017-05-10",
"name": "[concat(parameters('VMNames')[copyIndex()], '-' , 'BackupIntent')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('RSVResourceGroup')]",
"copy": {
"name": "AzureBackupLoop",
"count": "[length(parameters('VMNames'))]"
},
"dependsOn": [
"virtualMachineLoop"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "[concat(parameters('backupVaultName'), '/', 'Azure', '/', variables('v2Vm'), resourceGroup().name, ';', parameters('VMNames')[copyIndex()])]",
"apiVersion": "2017-07-01",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/backupProtectionIntent",
"properties": {
"friendlyName": "[concat(parameters('VMNames')[copyIndex()], 'BackupIntent')]",
"protectionIntentItemType": "AzureResourceItem",
"policyId": "[resourceId(parameters('RSVResourceGroup'), 'Microsoft.RecoveryServices/vaults/backupPolicies', parameters('backupVaultName'), parameters('BackupPolicy'))]",
"sourceResourceId": "[resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', parameters('VMNames')[copyIndex()])]"
}
}
]
}
}
}
]
}
Tested in my environment was getting same error as you are getting.
Solution
please remove sqaure bracket from [copyIndex()] and seprate with , for wherever you are using like below.
"name": "[concat(parameters('VMNames'),copyIndex(1),'_','BackupIntent')]",
instead of
"name": "[concat(parameters('VMNames')[copyIndex()], '-' , 'BackupIntent')]"

Arm templates copy loop conditionally check index

Is there option copy iteration check conditionally in ARM templates? Example if copy index is zero set another value?
My ARM Code:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"storageAccountName": {
"type": "string"
},
"mediaServicesAccountName": {
"type": "string"
}
},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-01-01",
"name": "[concat('storage', copyIndex(), uniqueString(resourceGroup().id))]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"copy": {
"name": "storagecopy",
"count": 3
}
},
{
"type": "Microsoft.Media/mediaservices",
"apiVersion": "2020-05-01",
"name": "[parameters('mediaServicesAccountName')]",
"location": "[parameters('location')]",
"properties": {
"storageAccounts": [
{
"type": "Primary", # Primary if copyIndex is zero otherwise Secondary
"id": "[resourceId('Microsoft.Storage/storageAccounts', concat('storage', copyIndex(), uniqueString(resourceGroup().id)))]"
}
]
},
"identity": {
"type": "SystemAssigned"
},
"dependsOn": ["storagecopy"]
}
],
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.3.126.58533",
"templateHash": "2006367938138350540"
}
}
}
In above code I am creating 3 storage accounts and after that I am creating azure media service, I need to map storage accounts to azure media service dynamically. Under properties, I need to use copy loop and set Primary if index is zero else Secondary for defined number of storages.
Below Block implementation is required for copy loop condition:
"storageAccounts": [
{
"type": "Primary", # Primary if copyIndex is zero otherwise Secondary
"id": "[resourceId('Microsoft.Storage/storageAccounts', concat('storage', copyIndex(), uniqueString(resourceGroup().id)))]"
}
]
You need to make a separate loop over storageAccounts property:
{
"type": "Microsoft.Media/mediaservices",
"apiVersion": "2020-05-01",
...
"properties": {
"copy": [
{
"name": "storageAccounts",
"count": "3",
"input": {
"type": "[if(equals(copyIndex('storageAccounts'), 0), 'Primary', 'Secondary']", # Primary if copyIndex is zero otherwise Secondary
"id": "[resourceId('Microsoft.Storage/storageAccounts', concat('storage', copyIndex('storageAccounts'), uniqueString(resourceGroup().id)))]"
}
}
]
}
}
See more information here: Property iteration in ARM templates

ARM template fails when creating event hub in multiple regions with multiple auth rules

I have an ARM template that creates Event Hub namespaces in two regions (eastus and westus2) with a event hub and multiple auth rules (on the even hub). This was working until ~16-Nov-2020 12:00PM.
Arm template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location-region1": {
"type": "string",
"defaultValue": "eastus",
"metadata": {
"description": "Name of an azure region"
}
},
"location-region2": {
"type": "string",
"defaultValue": "westus2",
"metadata": {
"description": "Name of an Azure region"
}
},
"appName": {
"type": "string",
"defaultValue": "jklm",
"metadata": {
"description": "Short name of the app or service"
}
},
"uniqueSuffix": {
"type": "string",
"defaultValue": "tst",
"metadata": {
"description": "Unique Suffix to use for the azure resources of the app or service"
}
},
"environment": {
"type": "string",
"defaultValue": "int",
"allowedValues": [
"poc",
"dev",
"int",
"uat",
"prod"
],
"metadata": {
"description": "The name of the environment"
}
},
"progressRecordsEventHubName": {
"type": "string",
"defaultValue": "progressrecords"
}
},
"variables": {
"eventHubNMApiVersion": "2018-01-01-preview",
"eventHubApiVersion": "2017-04-01",
"parentResourceGroupName": "[resourceGroup().name]",
"regionCount": 2,
"location": [
"[parameters('location-region1')]",
"[parameters('location-region2')]"
],
"appName": "[concat(parameters('appName'),'-',parameters('uniqueSuffix'),'-')]",
"copy": [
{
"name": "regionSuffix",
"count": "[variables('regionCount')]",
"input": "[concat('r',copyIndex('regionSuffix',1))]"
},
{
"name": "eventHubName",
"count": "[variables('regionCount')]",
"input": "[concat(variables('appName'),'ehub-',variables('regionSuffix')[copyIndex('eventHubName')],'-',parameters('environment'))]"
}
]
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "[variables('eventHubNMApiVersion')]",
"name": "[variables('eventHubName')[copyIndex()]]",
"copy": {
"name": "resourceLoop",
"count": "[variables('regionCount')]"
},
"location": "[variables('location')[copyIndex()]]",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 1
},
"properties": {
"zoneRedundant": false,
"isAutoInflateEnabled": true,
"maximumThroughputUnits": 1,
"kafkaEnabled": true
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex()], '/',parameters('progressRecordsEventHubName'))]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('eventHubName')[copyIndex()])]"
],
"properties": {
"messageRetentionInDays": 3,
"partitionCount": 1,
"status": "Active"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
],
"properties": {
"rights": [
"Listen"
]
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Send')]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()], parameters('progressRecordsEventHubName'))]"
],
"properties": {
"rights": [
"Send"
]
}
}
]
}
]
}
],
"functions": [
],
"outputs": {}
}
Now this template fails when I run Test-AzureRmResourceGroupDeployment (add -Debug to see real error)
Error:
Test-AzureRmResourceGroupDeployment : Encountered internal server error. Diagnostic information: timestamp '20201119T072227Z' ......
After some troubleshooting I identified that removing the second auth rule in the template fixes the issue.
I actually need more than 1 auth rule. What could be causing the above template to fail? I can't seem to find anything wrong with it.
Below you can find successful template - With 1 auth rule on the Event Hub
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location-region1": {
"type": "string",
"defaultValue": "eastus"
},
"location-region2": {
"type": "string",
"defaultValue": "westus2"
},
"appName": {
"type": "string",
"defaultValue": "jklm",
"metadata": {
"description": "Short name of the app or service"
}
},
"uniqueSuffix": {
"type": "string",
"defaultValue": "tst",
"metadata": {
"description": "Unique Suffix to use for the azure resources of the app or service"
}
},
"environment": {
"type": "string",
"defaultValue": "int",
"allowedValues": [
"poc",
"dev",
"int",
"uat",
"prod"
],
"metadata": {
"description": "The name of the environment"
}
},
"progressRecordsEventHubName": {
"type": "string",
"defaultValue": "progressrecords"
}
},
"variables": {
"eventHubNMApiVersion": "2018-01-01-preview",
"eventHubApiVersion": "2017-04-01",
"parentResourceGroupName": "[resourceGroup().name]",
"regionCount": 2,
"location": [
"[parameters('location-region1')]",
"[parameters('location-region2')]"
],
"appName": "[concat(parameters('appName'),'-',parameters('uniqueSuffix'),'-')]",
"copy": [
{
"name": "regionSuffix",
"count": "[variables('regionCount')]",
"input": "[concat('r',copyIndex('regionSuffix',1))]"
},
{
"name": "eventHubName",
"count": "[variables('regionCount')]",
"input": "[concat(variables('appName'),'ehub-',variables('regionSuffix')[copyIndex('eventHubName')],'-',parameters('environment'))]"
}
]
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "[variables('eventHubNMApiVersion')]",
"name": "[variables('eventHubName')[copyIndex()]]",
"copy": {
"name": "resourceLoop",
"count": "[variables('regionCount')]"
},
"location": "[variables('location')[copyIndex()]]",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 1
},
"properties": {
"zoneRedundant": false,
"isAutoInflateEnabled": true,
"maximumThroughputUnits": 1,
"kafkaEnabled": true
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex()], '/',parameters('progressRecordsEventHubName'))]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('eventHubName')[copyIndex()])]"
],
"properties": {
"messageRetentionInDays": 3,
"partitionCount": 1,
"status": "Active"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
],
"properties": {
"rights": [
"Listen"
]
}
}
]
}
]
}
],
"functions": [
],
"outputs": {}
}
Worked with Azure support on this. There was an issue on the Azure side. It auto resolved today (11/19/2020). Template no longer fails with multiple auth rules.
This article may be useful: https://www.rickvandenbosch.net/blog/error-creating-service-bus-authorization-rules-using-arm/.
I think the template is not expecting the same resource twice, because these Listen, Send authorization rules can be combined like below:
"resources": [
{
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "[variables('eventHubApiVersion')]",
"name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
"location": "[variables('location')[copyIndex()]]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
],
"properties": {
"rights": [
"Listen",
"Send"
]
}
},

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

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": "PFdhZENmZz48RGlhZ25vc3RpY01vbml0b3JDb25maWd1cmF0aW9uIG92ZXJhbGxRdW90YUluTUI9IjQwOTYiPjxEaWFnbm9zdGljSW5mcmF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nMiIHNhbXBsZVJhdGU9IlBUMTVTIiB1bml0PSJDb3VudCI+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.

Resources