A megadott erőforráscsoportot sablonként rögzíti.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2021-04-01
URI-paraméterek
Name |
In |
Kötelező |
Típus |
Description |
resourceGroupName
|
path |
True
|
string
|
Az erőforráscsoport neve. A név megkülönbözteti a kis- és nagybetűket.
|
subscriptionId
|
path |
True
|
string
|
A Microsoft Azure-előfizetés azonosítója.
|
api-version
|
query |
True
|
string
|
A művelethez használandó API-verzió.
|
Kérelem törzse
Name |
Típus |
Description |
options
|
string
|
Az exportálási sablon beállításai. CsV-formátumú lista, amely a következők közül legalább nullát tartalmaz: "IncludeParameterDefaultValue", "IncludeComments", "SkipResourceNameParameterization", "SkipAllParameterization"
|
resources
|
string[]
|
Az exportálás szűréséhez használt erőforrások azonosítói. Az összes erőforrás exportálásához adjon meg egy tömböt egyetlen "*" bejegyzéssel.
|
Válaszok
Name |
Típus |
Description |
200 OK
|
ResourceGroupExportResult
|
OK – Az exportálás eredményét adja vissza.
|
202 Accepted
|
|
Elfogadva
|
Other Status Codes
|
CloudError
|
Hibaválasz, amely leírja, hogy a művelet miért hiúsult meg.
|
Biztonság
azure_auth
Azure Active Directory OAuth2 Flow
Típus:
oauth2
Folyamat:
implicit
Engedélyezési URL:
https://login.microsoftonline.com/common/oauth2/authorize
Hatókörök
Name |
Description |
user_impersonation
|
felhasználói fiók megszemélyesítése
|
Példák
Export a resource group
Mintakérelem
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
Mintaválasz
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
Mintakérelem
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
Mintaválasz
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')]"
}
}
]
}
}
Definíciók
CloudError
Hibaválasz egy erőforrás-kezelési kérelemhez.
Name |
Típus |
Description |
error
|
ErrorResponse
|
Hibaválasz
Az összes Azure Resource Manager API gyakori hibaválasza a sikertelen műveletek hibaadatainak visszaadásához. (Ez az OData hibaválasz formátumát is követi.)
|
ErrorAdditionalInfo
Az erőforrás-kezelési hiba további információi.
Name |
Típus |
Description |
info
|
object
|
A további információk.
|
type
|
string
|
A további információtípus.
|
ErrorResponse
Hibaválasz
Name |
Típus |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
A hiba további információi.
|
code
|
string
|
A hibakód.
|
details
|
ErrorResponse[]
|
A hiba részletei.
|
message
|
string
|
A hibaüzenet.
|
target
|
string
|
A hibacél.
|
ExportTemplateRequest
Erőforráscsoport-sablonkérelem paramétereinek exportálása.
Name |
Típus |
Description |
options
|
string
|
Az exportálási sablon beállításai. CsV-formátumú lista, amely a következők közül legalább nullát tartalmaz: "IncludeParameterDefaultValue", "IncludeComments", "SkipResourceNameParameterization", "SkipAllParameterization"
|
resources
|
string[]
|
Az exportálás szűréséhez használt erőforrások azonosítói. Az összes erőforrás exportálásához adjon meg egy tömböt egyetlen "*" bejegyzéssel.
|
ResourceGroupExportResult
Az erőforráscsoport exportálási eredménye.
Name |
Típus |
Description |
error
|
ErrorResponse
|
Hibaválasz
A sablon exportálási hibája.
|
template
|
object
|
A sablon tartalma.
|