d1d15bddf7b3d0c63d2f0822d02918ed

Saving Microsoft ARM Templates as JSON files on disk

If you are creating a brand new environment on Azure, you should be using Windows PowerShell and Resource Manager. Instead of creating and managing individual resources, use a template (resource model) to create a resource group that has the resources need to support your service. You can create your own templates or pick a template from the gallery.

If you’re starting off with the Azure Resource Manager (ARM), I recommend taking a look at what others have published. Then modify them to create a resource model that represents your service.

The following code will download the Azure Resource Manager (ARM) templates that are published and maintained by Microsoft.

Switch-AzureMode -Name AzureResourceManager
 
New-Item -path 'C:\Azure\Templates\' -type directory -Force

$microsoftTemplates = Get-AzureResourceGroupGalleryTemplate -Publisher 'Microsoft'
 
foreach ($item in $microsoftTemplates)
{
    $identity = $item.'Identity'
 
    Save-AzureResourceGroupGalleryTemplate -Identity $identity `
             -Path C:\Azure\Templates\ `
             -Force `
             -Verbose
}

NB: be sure that ‘C:\Azure\Templates\’ exists before running this script.

This list is growing fast. Microsoft is adding new features on a regular basis. And there’s no better way to learn, than to look at what’s already out there.

Next Steps

To learn more about using Windows PowerShell with Resource Manager:

2 responses to Saving #Azure Resource Manager Templates to JSON files on disk

  1. 

    This API is now deprecated. Replacement is not yet released but workaround scripts are available here: https://github.com/Azure/azure-powershell/issues/1064

    Like

Trackbacks and Pingbacks:

  1. Dew Drop – February 3, 2015 (#1946) | Morning Dew - February 3, 2015

    […] Saving #Azure Resource Manager Templates to JSON files on disk (Alexandre Brisebois) […]

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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