Resource Groups - Export Template

Captures the specified resource group as a template.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2019-05-10

URI Parameters

Name In Required Type Description
subscriptionId
path True
  • string

The ID of the target subscription.

resourceGroupName
path True
  • string

The name of the resource group to export as a template.

Regex pattern: ^[-\w\._\(\)]+$

api-version
query True
  • string

The API version to use for this operation.

Request Body

Name Type Description
options
  • string

The export template options. A CSV-formatted list containing zero or more of the following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'

resources
  • string[]

The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'.

Responses

Name Type Description
200 OK

OK - Returns the result of the export.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Export a resource group
Export a resource group with filtering

Export a resource group

Sample Request

POST https://management.azure.com/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/exportTemplate?api-version=2019-05-10
{
  "resources": [
    "*"
  ],
  "options": "IncludeParameterDefaultValue,IncludeComments"
}

Sample Response

{
  "template": {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "myResourceType_myFirstResource_name": {
        "defaultValue": "myFirstResource",
        "type": "String"
      },
      "myResourceType_mySecondResource_name": {
        "defaultValue": "mySecondResource",
        "type": "String"
      },
      "myResourceType_myFirstResource_secret": {
        "defaultValue": null,
        "type": "SecureString"
      }
    },
    "variables": {},
    "resources": [
      {
        "type": "My.RP/myResourceType",
        "apiVersion": "2019-01-01",
        "name": "[parameters('myResourceType_myFirstResource_name')]",
        "location": "West US",
        "properties": {
          "secret": "[parameters('myResourceType_myFirstResource_secret')]"
        }
      },
      {
        "type": "My.RP/myResourceType",
        "apiVersion": "2019-01-01",
        "name": "[parameters('myResourceType_mySecondResource_name')]",
        "location": "West US",
        "properties": {
          "customProperty": "hello!"
        }
      }
    ]
  },
  "error": {
    "code": "ExportTemplateCompletedWithErrors",
    "message": "Export template operation completed with errors. Some resources were not exported. Please see details for more information.",
    "details": []
  }
}

Export a resource group with filtering

Sample Request

POST https://management.azure.com/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/exportTemplate?api-version=2019-05-10
{
  "resources": [
    "/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourceGroups/myResourceGroup/providers/My.RP/myResourceType/myFirstResource"
  ],
  "options": "SkipResourceNameParameterization"
}

Sample Response

{
  "template": {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "myResourceType_myFirstResource_secret": {
        "defaultValue": null,
        "type": "SecureString"
      }
    },
    "variables": {},
    "resources": [
      {
        "type": "My.RP/myResourceType",
        "apiVersion": "2019-01-01",
        "name": "myFirstResource",
        "location": "West US",
        "properties": {
          "secret": "[parameters('myResourceType_myFirstResource_secret')]"
        }
      }
    ]
  }
}

Definitions

ExportTemplateRequest

Export resource group template request parameters.

ResourceGroupExportResult

Resource group export result.

ResourceManagementErrorWithDetails

The detailed error message of resource management.

ExportTemplateRequest

Export resource group template request parameters.

Name Type Description
options
  • string

The export template options. A CSV-formatted list containing zero or more of the following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'

resources
  • string[]

The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'.

ResourceGroupExportResult

Resource group export result.

Name Type Description
error

The error.

template
  • object

The template content.

ResourceManagementErrorWithDetails

The detailed error message of resource management.

Name Type Description
code
  • string

The error code returned when exporting the template.

details

Validation error.

message
  • string

The error message describing the export error.

target
  • string

The target of the error.