Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Save-AzureResourceGroupGalleryTemplate

Save-AzureResourceGroupGalleryTemplate

microsoft.azure.commands.resources.dll

Synopsis

Saves a gallery template to a JSON file

Syntax

Save-AzureResourceGroupGalleryTemplate [-Identity] [-Path] [-Force] [<CommonParameters>]

Detailed Description

The Save-AzureResourceGroupGalleryTemplate cmdlet saves a template from the Azure template gallery as a JSON file on disk and returns the path to the saved file. You can to use the template to create Azure resource groups and deploymentsA resource is a user-managed entity, such as a website, database server, or database. A resource group is a collection of resources that are deployed as a unit. You can create resources individually and add them to resource groups. However, typically, you create a resource group by using a template.A template is a JSON string that defines a resource group for a complex entity, such as a web hosting site or web portal. The template defines the resources that are typically needed for the entity, such as websites, databases, and storage accounts, and includes parameters for user-defined values, such as the names and properties of the resources. To get a resource group template, use the Get-AzureResourceGroupGalleryTemplate cmdlet to get a gallery template and then use the Save-AzureResourceGroupGalleryTemplate cmdlet to save the template as a JSON file. Or, you can create your own templates, either from scratch or by editing a gallery template. To verify the syntax of a template, use the Test-AzureResourceGroupTemplate cmdlet.To use a template to create a resource group, use the New-AzureResourceGroup or New-AzureResourceGroupDeployment cmdlets. Just identify the template and provide values for its parameters.

Parameters

-Identity <String>

Specifies the identity of the gallery item. This parameter is required. The gallery item identity is also used as the name of the template file on disk with a .JSON file name extension.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Path <String>

Specifies the path to the directory in which the template is saved. This parameter is optional. The default is the current directory.

Aliases

None

Required?

false

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Force <SwitchParameter>

Suppresses the confirmation prompt. By default, if you specify a path and file name that already exists, Save-AzureResourceGroupGalleryTemplate prompts before overwriting the file.

Aliases

None

Required?

false

Position

2

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

None

Return Type

System.Management.Automation.PSCustomObject

Notes

The Save-AzureResourceGroupGalleryTemplate cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.

Examples

-------------------------- Example 1: Save a template --------------------------

This command saves the Microsoft.WebSite.0.1.0-preview1 template to the current directory as Microsoft.WebSite.0.1.0-preview1.json.

PS C:\>Save-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSite.0.1.0-preview1
Path:

C:\ Microsoft.WebSite.0.1.0-preview1.json

-------------------------- Example 2: Pipe a gallery item to SaveAzureResourceGroupGalleryTemplate --------------------------

This command pipes the Microsoft.WebSite.0.1.0-preview1 gallery item from the Get-AzureResourceGroupGalleryTemplate cmdlet to the Save-AzureResourceGroupGalleryTemplate cmdlet. The command uses the Path parameter to save the JSON template in an alternate directory. Because the command uses the Passthru parameter, the cmdlet returns True to indicate that the save operation succeeded.

PS C:\>Get-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSite.0.1.0-preview1 | Save-AzureResourceGroupGalleryTemplate -Path $home\Documents\MyTemplates
Path

C:\Users\User01\Documents\MyTemplates\ Microsoft.WebSite.0.1.0-preview1.json

-------------------------- Example 3: Save and use a gallery template --------------------------

This example shows how to use a saved gallery template to create a new resource group.

PS C:\> The first command uses the Save-AzureResourceGalleryTemplate cmdlet to save a template to disk. The cmdlet returns the path to the JSON file.
PS C:\>Save-AzureResourceGroupGalleryTemplate -Identity TechInfoSystems.GalleryServerPro.0.1.0-preview1 -Path $home\Documents\MyTemplates
Path

C:\Users\User01\Documents\MyTemplates\TechInfoSystems.GalleryServerPro.0.1.0-preview1.json

The second command uses the New-AzureResourceGroup cmdlet to create a new resource group based on the template. To specify the saved template, the command uses the TemplateFile parameter, which takes a path to a JSON file on disk. To specify the template parameters, the command uses the TemplateParameterFile parameter, which takes a path to a JSON file of parameters and parameter values.The command returns the newly created resource group.
PS C:\>New-AzureResourceGroup -Name ContosoRG02 -Location 'South Central US' -DeploymentName DeployWeb1 –StorageAccountName contosostorage01 -TemplateFile $home\Documents\MyTemplates\TechInfoSystems.GalleryServerPro.0.1.0-preview1.json -TemplateParameterFile $home\Documents\MyTemplates\TechInfoParameters.json

Online Version