Hello,
I’m trying to pass parameters to an existing Azure template parameter file (JSON). The files are located on a storage container in Azure. For testing purposes, I’m starting off with only two parameters: location and vmName.
Here is the code I’m working with:
$location = "eastus"
$vmName = "tst-win-sqlpoc"
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroup -Name win2016Deployment `
-TemplateUri "https://storage.blob.core.windows.net/templates/createWin2016VM.json" `
-TemplateParameterUri "https://storage.blob.core.windows.net/templates/createWin2016Parameters.json" `
-location $location -virtualMachineName $vmName
However, it’s not detecting the values I supplied and continues using the values already in the file:
-location : The term '-location' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:8 char:5
+ -location $location -virtualMachineName $vmName
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-location:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any help would be great?!
Thanks,
Frank
Hi Frank,
Looking at the New-AzResourceGroupDeployment Cmdlet, it does not look like there are parameters for -Location or -VirtualMachineName or maybe I am misunderstanding your question.
Also, try to avoid using back ticks, use splatting instead.
$Params = @{
ResourceGroupName = $resourceGroup
Name = "win2016Deployment"
TemplateUri = "https://storage.blob.core.windows.net/templates/createWin2016VM.json"
TemplateParameterUri = "https://storage.blob.core.windows.net/templates/createWin2016Parameters.json"
}
New-AzResourceGroupDeployment @Params
pwshliquori
Hi pwshliquori,
Thanks for the feedback and recommendation about splatting! I changed the code to use splatting as follows:
[pre]
$params = @{
ResourceGroupName = “rg-name-poc”;
Name = “win2016Deployment”;
TemplateUri = “https://azure.blob.core.windows.net/templates/createWin2016VM.json”;
TemplateParameterUri = “https://azure.blob.core.windows.net/templates/createWin2016Parameters.json”;
}
New-AzResourceGroupDeployment @params
[/pre]
However, I’d like to edit the parameter file that Azure uses to build the Windows 2016 Server VM. Some of the JSON parameter contents include:
networkInterfaceName
location
virtualMachineName
adminUsername
How do I pass values to these parameters?
Thanks!
Take a look here. It looks like Microsoft has an example using the az cli to update a resource using the parameters you provided.
https://docs.microsoft.com/en-us/azure/architecture/building-blocks/extending-templates/update-resource
I am not sure if there is a Cmdlet in the Az PowerShell module to do the same thing. These are the Cmdlets available for the Az PowerShell module as it pertains to resource group deployments.
Get-Command -Noun AzResourceGroupDeployment
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-AzResourceGroupDeployment 1.2.1 Az.Resources
Cmdlet New-AzResourceGroupDeployment 1.2.1 Az.Resources
Cmdlet Remove-AzResourceGroupDeployment 1.2.1 Az.Resources
Cmdlet Stop-AzResourceGroupDeployment 1.2.1 Az.Resources
Cmdlet Test-AzResourceGroupDeployment 1.2.1 Az.Resources
pwshliquori
Doesn’t appear to be. Thx for your help!