1
votes

I need to generate a unique hash in my ARM template for each azure virtual machines I create. I currently deploy all virtual machines inside the same resource group as I am using a shared image. This causes me a problem as I currently haven't found any way to generate unique name hashes for each deployment within a resource group.

I currently use this to generate my unique name but this only works inbetween resource groups. "unique_string": "[uniqueString(resourceGroup().id]",

Is there a way to do this per deployed instance?

2

2 Answers

1
votes

Well, generally it depends on how you deploy those. But you can use copyindex function (link).
You could use something like [uniqueString(resourceGroup().id, variables('vm1Name'))] or [uniqueString(deployment().name, parameters('vm1Name'))] (so it is unique for every deployment you create.

0
votes

I put datetime into tags and use tag for param of uniqueString

"uri": "[replace(parameters('prebuiltvms')[copyIndex()]['osDiskVhdUri'],'{unique}',uniqueString(parameters('prebuiltvms')[copyIndex()].tags.deploymentDate))]"