Gengis Khan
Gengis Khan

Reputation: 183

Deploy Windows and Linux VM through ARM template in Azure

I want to deploy an azure resource manager template with 2 VMs, one Windows and the other Linux. I read about using copy variable, but that's basically deploying the same resource multiple times. I couldn't figure out a way to deploy 2 different instances of the same resource in the same template. Need your help. Thanks!

Upvotes: 0

Views: 924

Answers (2)

bmoore-msft
bmoore-msft

Reputation: 8717

If your VMs are largely identical except for the OS disk, take a look at this sample:

https://github.com/Azure/azure-quickstart-templates/blob/master/101-vm-simple-zones/azuredeploy.json#L194

If you wanted to add in something like Password vs. SSH authn, see: https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/azuredeploy.json#L298-L299

To use the copy loop, you'd need to have arrays for those conditionals, but when you start to add up the duplicate resources you would have (e.g. nics, PublicIps) dealing with the arrays and conditional in a copy loop may very well be simpler than duplicating the resources.

That help?

Upvotes: 1

4c74356b41
4c74356b41

Reputation: 72151

you could use a bunch of variables for that, but since windows and linux vm inputs are pretty different I suggest you do not do this, way to much customization. Easier just deploying 2 vms as 2 individual resources.

You can use arrays to achieve your goal:

"osType": [
    "windows",
    "linux"
]

and then you would have a bunch of variables like osimagewindows and osimagelinux and you would access them like this:

variables(concat('osimage', variables('osType')[copyIndex()]))

ps. Thats too much trouble for the value you are getting. do not bother (unless you want to do this as an exercise).

Upvotes: 2

Related Questions