Belirtilen kaynak grubunu şablon olarak yakalar.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate?api-version=2021-04-01
URI Parametreleri
Name |
İçinde |
Gerekli |
Tür |
Description |
resourceGroupName
|
path |
True
|
string
|
Kaynak grubunun adı. Ad büyük/küçük harfe duyarlı değildir.
|
subscriptionId
|
path |
True
|
string
|
Microsoft Azure abonelik kimliği.
|
api-version
|
query |
True
|
string
|
Bu işlem için kullanılacak API sürümü.
|
İstek Gövdesi
Name |
Tür |
Description |
options
|
string
|
Şablon dışarı aktarma seçenekleri. Aşağıdakilerden sıfır veya daha fazlasını içeren CSV biçimli bir liste: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'
|
resources
|
string[]
|
Dışarı aktarmayı filtrelemek için kaynakların kimlikleri. Tüm kaynakları dışarı aktarmak için tek girişi '*' olan bir dizi sağlayın.
|
Yanıtlar
Name |
Tür |
Description |
200 OK
|
ResourceGroupExportResult
|
Tamam - Dışarı aktarma işleminin sonucunu döndürür.
|
202 Accepted
|
|
Kabul edildi
|
Other Status Codes
|
CloudError
|
İşlemin neden başarısız olduğunu açıklayan hata yanıtı.
|
Güvenlik
azure_auth
Azure Active Directory OAuth2 Flow
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
Name |
Description |
user_impersonation
|
kullanıcı hesabınızın kimliğine bürünme
|
Örnekler
Export a resource group
Örnek isteği
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
Örnek yanıt
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
Örnek isteği
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
Örnek yanıt
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')]"
}
}
]
}
}
Tanımlar
CloudError
Kaynak yönetimi isteği için hata yanıtı.
Name |
Tür |
Description |
error
|
ErrorResponse
|
Hata Yanıtı
Başarısız işlemlerin hata ayrıntılarını döndürmek için tüm Azure Resource Manager API'leri için genel hata yanıtı. (Bu, OData hata yanıtı biçimini de izler.)
|
ErrorAdditionalInfo
Kaynak yönetimi hatası ek bilgileri.
Name |
Tür |
Description |
info
|
object
|
Ek bilgiler.
|
type
|
string
|
Ek bilgi türü.
|
ErrorResponse
Hata Yanıtı
Name |
Tür |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Hata ek bilgileri.
|
code
|
string
|
Hata kodu.
|
details
|
ErrorResponse[]
|
Hata ayrıntıları.
|
message
|
string
|
Hata iletisi.
|
target
|
string
|
Hata hedefi.
|
ExportTemplateRequest
Kaynak grubu şablonu istek parametrelerini dışarı aktarın.
Name |
Tür |
Description |
options
|
string
|
Şablon dışarı aktarma seçenekleri. Aşağıdakilerden sıfır veya daha fazlasını içeren CSV biçimli bir liste: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'
|
resources
|
string[]
|
Dışarı aktarmayı filtrelemek için kaynakların kimlikleri. Tüm kaynakları dışarı aktarmak için tek girişi '*' olan bir dizi sağlayın.
|
ResourceGroupExportResult
Kaynak grubu dışarı aktarma sonucu.
Name |
Tür |
Description |
error
|
ErrorResponse
|
Hata Yanıtı
Şablon dışarı aktarma hatası.
|
template
|
object
|
Şablon içeriği.
|