Capture le groupe de ressources spécifié en tant que modèle.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2021-04-01
Paramètres URI
Nom |
Dans |
Obligatoire |
Type |
Description |
resourceGroupName
|
path |
True
|
string
|
Nom du groupe de ressources. Le nom ne respecte pas la casse.
|
subscriptionId
|
path |
True
|
string
|
ID d’abonnement Microsoft Azure.
|
api-version
|
query |
True
|
string
|
Version de l’API à utiliser pour cette opération.
|
Corps de la demande
Nom |
Type |
Description |
options
|
string
|
Options de modèle d’exportation. Liste au format CSV contenant zéro ou plusieurs des éléments suivants : « IncludeParameterDefaultValue », « IncludeComments », « SkipResourceNameParameterization », « SkipAllParameterization »
|
resources
|
string[]
|
ID des ressources par lesquelles filtrer l’exportation. Pour exporter toutes les ressources, fournissez un tableau avec une entrée unique « * ».
|
Réponses
Nom |
Type |
Description |
200 OK
|
ResourceGroupExportResult
|
OK : retourne le résultat de l’exportation.
|
202 Accepted
|
|
Accepté
|
Other Status Codes
|
CloudError
|
Réponse d’erreur décrivant la raison de l’échec de l’opération.
|
Sécurité
azure_auth
Flux OAuth2 Azure Active Directory
Type:
oauth2
Flux:
implicit
URL d’autorisation:
https://login.microsoftonline.com/common/oauth2/authorize
Étendues
Nom |
Description |
user_impersonation
|
Emprunter l’identité de votre compte d’utilisateur
|
Exemples
Export a resource group
Exemple de requête
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
Exemple de réponse
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
Exemple de requête
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
Exemple de réponse
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')]"
}
}
]
}
}
Définitions
CloudError
Réponse d’erreur pour une demande de gestion des ressources.
Nom |
Type |
Description |
error
|
ErrorResponse
|
Réponse d’erreur
Réponse d’erreur courante pour toutes les API Azure Resource Manager pour retourner les détails de l’erreur concernant les opérations ayant échoué. (Cela suit également le format de réponse d’erreur OData.)
|
ErrorAdditionalInfo
Informations supplémentaires sur l’erreur de gestion des ressources.
Nom |
Type |
Description |
info
|
object
|
Informations supplémentaires
|
type
|
string
|
Type d’informations supplémentaires.
|
ErrorResponse
Réponse d’erreur
Nom |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Informations supplémentaires sur l’erreur.
|
code
|
string
|
Code d'erreur.
|
details
|
ErrorResponse[]
|
Détails de l’erreur.
|
message
|
string
|
Message d’erreur.
|
target
|
string
|
Cible d’erreur.
|
ExportTemplateRequest
Exporter les paramètres de demande de modèle de groupe de ressources.
Nom |
Type |
Description |
options
|
string
|
Options de modèle d’exportation. Liste au format CSV contenant zéro ou plusieurs des éléments suivants : « IncludeParameterDefaultValue », « IncludeComments », « SkipResourceNameParameterization », « SkipAllParameterization »
|
resources
|
string[]
|
ID des ressources par lesquelles filtrer l’exportation. Pour exporter toutes les ressources, fournissez un tableau avec une entrée unique « * ».
|
ResourceGroupExportResult
Résultat de l’exportation du groupe de ressources.
Nom |
Type |
Description |
error
|
ErrorResponse
|
Réponse d’erreur
Erreur d’exportation de modèle.
|
template
|
object
|
Contenu du modèle.
|