Using Azure Resource Manager templates (JSON format) is an easy and reliable way to deploy resources on Azure. It allows for codifying the infrastructure and version controlling every change to it a.k.a. Infrastructure-as-Code (IaC).
A single template can deploy hundreds of resources, however there are limits on the physical size and parameters (see Template limits section). From a maintainability perspective, it may not always be a good idea to build one gigantic template. There is a lot of good material written on the single vs nested templates.
Now that we have decided to build a nested template and probably quickly scrambled an example together, we might next stumble upon how to run this sample, since references to nested templates are required to be accessible publicly.
A very commonly used way is to host it on the public Git repository and hard reference the URIs, however templates are also hosted on an Azure storage account as an alternative approach described here.
Discussed below is another alternative, which comes handy when experimenting, learning and testing changes quickly without having to push code either on Git or on a storage account.
-
Install Node.js (if you don’t have it already!) - https://nodejs.org/en/download/
Download and run, it has pre-built installer so not much to do!
-
Install http-server and NPM package - https://www.npmjs.com/package/http-server
npm install -g http-server
-
Download and unzip ngrok on your local machine let’s say c:\ngrok
- Download a sample copy of the nested scripts from https://github.com/kunalbabre/nested-arm-template-101 into
c:\nested-arm-template-101
- Open
c:\nested-arm-template-101
folder in command prompt - Type
http-server
and hit enter - Next note the port number it is running on - you will get something like http://127.0.0.1:`8080` where
8080
is the port where our site is getting served locally - Now open a second command prompt window
- Type
cd c:\ngrok
and hit enter - Type
Ngork.exe http 8080
and hit enter to serve the files externally - Next note the unique subdomain name - you will get something like https://
c1a178dc
.ngrok.io, copyc1a178dc
- Open the PowerShell script
c:\nested-arm-template-101\sampleDeploy.ps1
in PowerShell ISE - Replace
<ngrok-subDomainName>
with one you noted in step 8 above
- Run (hit
F5
) - Provide your Azure account details (
Login-AzureRmAccount
command on PowerShell required only once) - Once the script has been successfully deployed you will be able to see the App Service Plan and the Website created under Azure portal
- Browser to the website http://
c1a178dc
-test-site-name.azurewebsites.net/