How Do You Create the PowerShell Script, the Template.json and the Parameters.json Necessary to Utilize ARM?

Problem scenario
To use ARM templates you know know you should have three text files: 1) a PowerShell script 2) a template.json file and 3) a parameters.json file.

How do you create these for a given resource (e.g., a storage account, VM, or Function App)?

Solution
1.  In the Azure Portal web UI, start the process of creating a resource.  Right before you click "Create", and there may be a few intermediate steps before you get there, click on the nearby hyperlink that says "Download a template for automation" (or for a Function App it may say "Automation options").

2.  You can click on "Template" near the top.  The JSON should be copied into a file called template.json.

3.  You can click on "Parameters" near the top.  The JSON should be copied into a file called parameters.json.

4.  Click on "PowerShell" near the top.  This is the PowerShell you should use.  You should modify two PowerShell stanzas to have explicit paths to the template.json and parameters.json files:

 $templateFilePath = "C:\path\to\template.json",
 $parametersFilePath = "C:\path\to\parameters.json"

5.  Now you can run the PowerShell script to use ARM templates for the resource you were about to create.  Infastructure as a code is great for simplifying your standards and keeping a record of the configuration deployed.

Leave a comment

Your email address will not be published.