Captures the specified resource group as a template.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2021-04-01
URI Parameters
Name |
In |
Required |
Type |
Description |
resourceGroupName
|
path |
True
|
string
|
The name of the resource group. The name is case insensitive.
|
subscriptionId
|
path |
True
|
string
|
The Microsoft Azure subscription ID.
|
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
|
ResourceGroupExportResult
|
OK - Returns the result of the export.
|
202 Accepted
|
|
Accepted
|
Other Status Codes
|
CloudError
|
Error response describing why the operation failed.
|
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
Sample request
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/exportTemplate?api-version=2021-04-01
{
"resources": [
"*"
],
"options": "IncludeParameterDefaultValue,IncludeComments"
}
package armresources_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json
func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armresources.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{
Options: to.Ptr("IncludeParameterDefaultValue,IncludeComments"),
Resources: []*string{
to.Ptr("*")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceGroupExportResult = armresources.ResourceGroupExportResult{
// Error: &armresources.ErrorResponse{
// Code: to.Ptr("ExportTemplateCompletedWithErrors"),
// Message: to.Ptr("Export template operation completed with errors. Some resources were not exported. Please see details for more information."),
// Details: []*armresources.ErrorResponse{
// },
// },
// Template: map[string]any{
// "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
// "contentVersion": "1.0.0.0",
// "parameters":map[string]any{
// "myResourceType_myFirstResource_name":map[string]any{
// "type": "String",
// "defaultValue": "myFirstResource",
// },
// "myResourceType_myFirstResource_secret":map[string]any{
// "type": "SecureString",
// "defaultValue": nil,
// },
// "myResourceType_mySecondResource_name":map[string]any{
// "type": "String",
// "defaultValue": "mySecondResource",
// },
// },
// "resources":[]any{
// map[string]any{
// "name": "[parameters('myResourceType_myFirstResource_name')]",
// "type": "My.RP/myResourceType",
// "apiVersion": "2019-01-01",
// "location": "West US",
// "properties":map[string]any{
// "secret": "[parameters('myResourceType_myFirstResource_secret')]",
// },
// },
// map[string]any{
// "name": "[parameters('myResourceType_mySecondResource_name')]",
// "type": "My.RP/myResourceType",
// "apiVersion": "2019-01-01",
// "location": "West US",
// "properties":map[string]any{
// "customProperty": "hello!",
// },
// },
// },
// "variables":map[string]any{
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ResourceManagementClient } = require("@azure/arm-resources");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Captures the specified resource group as a template.
*
* @summary Captures the specified resource group as a template.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json
*/
async function exportAResourceGroup() {
const subscriptionId =
process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "my-resource-group";
const parameters = {
options: "IncludeParameterDefaultValue,IncludeComments",
resources: ["*"],
};
const credential = new DefaultAzureCredential();
const client = new ResourceManagementClient(credential, subscriptionId);
const result = await client.resourceGroups.beginExportTemplateAndWait(
resourceGroupName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/c9bbccf4-e16a-4eb7-befb-2e2e5195c347?api-version=2018-08-01
{
"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/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/exportTemplate?api-version=2021-04-01
{
"resources": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource"
],
"options": "SkipResourceNameParameterization"
}
package armresources_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json
func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroupWithFiltering() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armresources.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{
Options: to.Ptr("SkipResourceNameParameterization"),
Resources: []*string{
to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceGroupExportResult = armresources.ResourceGroupExportResult{
// Template: map[string]any{
// "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
// "contentVersion": "1.0.0.0",
// "parameters":map[string]any{
// "myResourceType_myFirstResource_secret":map[string]any{
// "type": "SecureString",
// "defaultValue": nil,
// },
// },
// "resources":[]any{
// map[string]any{
// "name": "myFirstResource",
// "type": "My.RP/myResourceType",
// "apiVersion": "2019-01-01",
// "location": "West US",
// "properties":map[string]any{
// "secret": "[parameters('myResourceType_myFirstResource_secret')]",
// },
// },
// },
// "variables":map[string]any{
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ResourceManagementClient } = require("@azure/arm-resources");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Captures the specified resource group as a template.
*
* @summary Captures the specified resource group as a template.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json
*/
async function exportAResourceGroupWithFiltering() {
const subscriptionId =
process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "my-resource-group";
const parameters = {
options: "SkipResourceNameParameterization",
resources: [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource",
],
};
const credential = new DefaultAzureCredential();
const client = new ResourceManagementClient(credential, subscriptionId);
const result = await client.resourceGroups.beginExportTemplateAndWait(
resourceGroupName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/c9bbccf4-e16a-4eb7-befb-2e2e5195c347?api-version=2018-08-01
{
"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
CloudError
An error response for a resource management request.
Name |
Type |
Description |
error
|
ErrorResponse
|
Error Response
Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)
|
ErrorAdditionalInfo
The resource management error additional info.
Name |
Type |
Description |
info
|
object
|
The additional info.
|
type
|
string
|
The additional info type.
|
ErrorResponse
Error Response
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
code
|
string
|
The error code.
|
details
|
ErrorResponse[]
|
The error details.
|
message
|
string
|
The error message.
|
target
|
string
|
The error target.
|
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
|
ErrorResponse
|
Error Response
The template export error.
|
template
|
object
|
The template content.
|