I'm writing a powershell script to create VM using New-AzureRmResourceGroupDeployment cmdlet, which is as below.
New-AzureRmResourceGroupDeployment -Name VmDeployment `
-TemplateFile C:\template\template.json `
-TemplateParameterFile C:\template\parameters.json
This is used create a VM. In parameters.json
, there are some parameters like virtualMachineName
, networkInterfaceName
etc which are hardcoded.
Now I'm trying to automate these scripts , i.e they run on there own from a tool , when ever some condition is met.
My requirement here is , whenever this script runs, it has to increase the number in the VMName . Suppose the VM Name is now VMName1
, it has to be VMName2
when the script runs next time. Similarly VMName3
when the script runs next time. Since the virtualMachineName
parameter is hardcoded, this is not happening now. Is there anyway I can pass virtualMachineName
as a parameter in the script itself rather than taking it from the json file.
Any guidance is highly appreciated.Thanks!