Captura o grupo de recursos especificado como um modelo.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2021-04-01
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos. O nome diferencia maiúsculas de minúsculas.
|
subscriptionId
|
path |
True
|
string
|
A ID da assinatura do Microsoft Azure.
|
api-version
|
query |
True
|
string
|
A versão da API a ser usada para esta operação.
|
Corpo da solicitação
Nome |
Tipo |
Description |
options
|
string
|
As opções de modelo de exportação. Uma lista formatada em CSV que contém zero ou mais das seguintes opções: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'
|
resources
|
string[]
|
As IDs dos recursos pelos quais filtrar a exportação. Para exportar todos os recursos, forneça uma matriz com entrada única '*'.
|
Respostas
Nome |
Tipo |
Description |
200 OK
|
ResourceGroupExportResult
|
OK – retorna o resultado da exportação.
|
202 Accepted
|
|
Aceito
|
Other Status Codes
|
CloudError
|
Resposta de erro que descreve por que a operação falhou.
|
Segurança
azure_auth
Fluxo do OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Export a resource group
Solicitação de exemplo
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
Resposta de exemplo
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
Solicitação de exemplo
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
Resposta de exemplo
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')]"
}
}
]
}
}
Definições
CloudError
Uma resposta de erro para uma solicitação de gerenciamento de recursos.
Nome |
Tipo |
Description |
error
|
ErrorResponse
|
Resposta de erro
Resposta de erro comum para todas as APIs do Azure Resource Manager para retornar detalhes de erro de operações com falha. (Isso também segue o formato de resposta de erro OData.)
|
ErrorAdditionalInfo
As informações adicionais do erro de gerenciamento de recursos.
Nome |
Tipo |
Description |
info
|
object
|
As informações adicionais.
|
type
|
string
|
O tipo de informação adicional.
|
ErrorResponse
Resposta de erro
Nome |
Tipo |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
As informações adicionais do erro.
|
code
|
string
|
O código de erro.
|
details
|
ErrorResponse[]
|
Os detalhes do erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro.
|
ExportTemplateRequest
Exportar parâmetros de solicitação de modelo do grupo de recursos.
Nome |
Tipo |
Description |
options
|
string
|
As opções de modelo de exportação. Uma lista formatada em CSV que contém zero ou mais das seguintes opções: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'
|
resources
|
string[]
|
As IDs dos recursos pelos quais filtrar a exportação. Para exportar todos os recursos, forneça uma matriz com entrada única '*'.
|
ResourceGroupExportResult
Resultado da exportação do grupo de recursos.
Nome |
Tipo |
Description |
error
|
ErrorResponse
|
Resposta de erro
O erro de exportação de modelo.
|
template
|
object
|
O conteúdo do modelo.
|