1

I am deploying VMs using a template and parameter file. I would like to override the parameter files virtualMachineName, so I can dynamically name each VM without needing 10 different parameter files. What is the correct syntax to do so?

Currently I have:

New-AzureRmResourceGroupDeployment -ResourceGroupName "myRSG" -TemplateFile $server1TmpFile  -TemplateParameterFile $serverParamFile -virtualMachineName "AS1FTW12"  -networkInterfaceName "AS1FTW12NIC" -networkSecurityGroupName "MyNSGName"

This will produce an error: New-AzureRmResourceGroupDeployment : A parameter cannot be found that matches parameter name 'virtualMachineName'

I am authoring the script using PowerShell Tools for Visual Studio 2017. My installed PowerShell AzureRM version is 5.1.1 according to Get-Module AzureRM.

Shawn Hodgson
  • 33
  • 1
  • 8

1 Answers1

7

This Works with AzureRM 5.1.1, you can test with the following setup:

template:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "paramTest": {
            "type": "string"
        }
    },
    "resources": [],
    "outputs": {
        "result": {
            "type": "string",
            "value": "[parameters('paramTest')]"
        }
    }
}

parameters:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "paramTest": {
            "value": "GEN-UNIQUE"
        }
    }
}

Powershell:

New-AzureRmResourceGroupDeployment -ResourceGroupName rg -TemplateFile template.json -TemplateParameterFile param.json -paramTest somevalue

results in output value equal to the one passed from powershell

Your error indicates that the parameter name is wrong, doublé check it

4c74356b41
  • 69,186
  • 6
  • 100
  • 141