Create Azure JSON parameter files w/PowerShell


Many of you already know the most efficient way to deploy resources in the Microsoft Azure cloud is using Resource Manager templates. There are many sources to download a lot of templates like Azure Quickstart Templates portal or GitHub , but what about Parameter files?

What is JSON

  • The JSON file structure is ugly and unclear, but this is only option for complex embedded objects. The CSV obviously does not fit here Emoj. Actually JSON file is multi-level hash table. Specifically, JSON parameter files have four levels in depth! Even with paid editors like Visual Studio there is very easy to slip up and miss any of mandatory characters (,{}[]:").

  • With the​​ ​New-AzParamsJson function from my Azure Automation Az-Module we will automate JSON parameter files creation.

  • The function is very flexible and allows to create parameter files in many convenient ways with the guarantee that files will be proper!

Blank JSON

  • To create proper blank JSON with no parameters at all, run the function with one mandatory parameter -JsonPath only. The parameter is positional and can be omitted.

New-AzParamsJson -JsonPath C:\AzureDeploy\blank.params.json
New-AzParamsJson C:\AzureDeploy\blank.params.json


JSON from user input

  • If you have a JSON template, all required parameters is in the ”parameters”: { } section. These parameters are expected in the JSON parameters file. Those parameters that have defaultValue property set, like vmSize parameter in this template, may, but must not present.

  • Just populate hash table with required parameters and their values and pass it to -Params parameter of the New-AzParamsJson.

New-AzParamsJson -JsonPath C:\AzureDeploy\azvm1.params.json -Params @{'vmName' = 'azvm1'; 'vmSize' = 'Standard_D2_v3'; 'storageAccount' = 'azstg01lrs';}
  • The function returns reference to the created JSON file. To view its content as well, pipeline the output to the Get-Content cmdlet.
New-AzParamsJson -JsonPath C:\AzureDeploy\azvm1.params.json -Params @{'vmName' = 'azvm1'; 'vmSize' = 'Standard_D2_v3'; 'storageAccount' = 'azstg01lrs';} | Get-Content


JSON from a Template

  • There is option to create JSON parameters file from any existing JSON template. This method has one huge advantage, there is no need to know in advance what parameters do you need, they retrieved from the template! The drawback is the parameters will not be populated with values Emoj, you will have to edit the file after that.
New-AzParamsJson C:\AzureDeploy\Vm_Vhd_OSDisk.params.json -TemplatePath C:\AzureDeploy\Vm_Vhd_OSDisk.json
  • The pipeline is supported.
Get-Item C:\AzureDeploy\Vm_Vhd2_OSDisk_DataDisk.json | New-AzParamsJson C:\AzureDeploy\Vm_Vhd2_OSDisk_DataDisk.params | Get-Content
  • The .json file extension can be safely omitted, it will be added automatically.


Multiple JSON

  • As a bonus, I have created the following one-liner. It recursively retrieves only JSON templates from all subfolders of the parent directory and for each of them creates its JSON parameters file with the same name plus .params.json within the same folder. Cool?
Get-ChildItem C:\AzureDeploy\ -Filter *.json -Recurse | ? { $_.BaseName -inotmatch '\.param(s|eters)$' } | % { New-AzParamsJson "$($_.DirectoryName)\$($_.BaseName).params" -TemplatePath $_.FullName }



  • For more details about the function, please take a look at the content based help and examples.
Get-Alias –Definition New-AzParamsJson
Get-Help New-AzParamsJson -Full
Get-Help New-AzParamsJson -Examples
Get-Help New-AzParamsJson -Parameter Params
  • All JSON files (template as well as parameter files) used and created during examples are here for your reference.

  • In the upcoming article I will show you how to create PowerShell script to deploy Azure VM from JSON template and parameters file using New-AzParamsJson and some other functions from my Az-Module. Stay tuned.

You might also like

How to find orphaned VHD files in the Azure
Add a data disk to an Azure VM
Azure Automation – Increase Azure VM disks
Get-AzSubnet – PowerShell based IPAM for the Azure IaaS cloud

2 thoughts on “Create Azure JSON parameter files w/PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s