0

I'm trying to concatenate a disk name, but I'm having trouble. I can concat with the following, which has parameter first, with no issues

"Newvm02OSDiskName": "[concat(Parameters('Newvm02VMName'), '-osdisk')]"

But when I try to add "dsk-" at the front I get an error.

"Newvm02OSDiskName": "[concat('dsk-', (Parameters('Newvm02VMName'), '-osdisk'))]"

Can't see where I'm going wrong, help please :)

Thanks in advance

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
Norrin Rad
  • 881
  • 2
  • 18
  • 42

1 Answers1

1

Don't parenthesise the last 2 arguments:

"Newvm02OSDiskName": "[concat('dsk-', Parameters('Newvm02VMName'), '-osdisk')]"
Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
  • Perfect, Thanks :) – Norrin Rad Sep 12 '19 at 23:57
  • Sorry that was a bit premature from me, still getting an error. `"[concat('dsk-', Parameters('VMName'), '-osdisk')]",` doesn't work, is that right or have i made an error? – Norrin Rad Sep 13 '19 at 00:00
  • error ` { "code": "DiskProcessingError", "message": "One or more errors occurred while preparing VM disks. See disk instance view for details." }` – Norrin Rad Sep 13 '19 at 00:01
  • well, can you show the error its talking about? this `concat` is definitely valid. – 4c74356b41 Sep 13 '19 at 06:38
  • `New-AzureRmResourceGroupDeployment : 01:04:41 - Resource Microsoft.Compute/virtualMachines 'vm-new01' failed with message '{ "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'.", "details": [ { "code": "DiskProcessingError", "message": "One or more errors occurred while preparing VM disks. See disk instance view for details."` – Norrin Rad Sep 13 '19 at 07:34
  • @4c74356b41 Hope that's readable, but the error suggests it's the disks `"code": "DiskProcessingError", "message": "One or more errors occurred while preparing VM disks. See disk instance view for details."` I think – Norrin Rad Sep 13 '19 at 07:35
  • Don't put all this in comments. Add the error message and your template to the question. – Hong Ooi Sep 13 '19 at 07:37
  • @HongOoi Thanks for your help. The code you gave me worked, the error was related to the fact the disks already existed and I was using the create option not the attach option. Sorry for the confusion and thanks again for your help. – Norrin Rad Sep 13 '19 at 08:04