botbook/node_modules/@azure/arm-resources/dist-esm/samples-dev/resourceGroupsExportTemplateSample.js
Rodrigo Rodriguez 6ae15fe3e5 Updated.
2024-09-04 13:13:15 -03:00

66 lines
No EOL
3 KiB
JavaScript

/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { __awaiter } from "tslib";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ResourceManagementClient } from "@azure/arm-resources";
import { DefaultAzureCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
/**
* 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
*/
function exportAResourceGroup() {
return __awaiter(this, void 0, void 0, function* () {
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 = yield client.resourceGroups.beginExportTemplateAndWait(resourceGroupName, parameters);
console.log(result);
});
}
/**
* 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
*/
function exportAResourceGroupWithFiltering() {
return __awaiter(this, void 0, void 0, function* () {
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 = yield client.resourceGroups.beginExportTemplateAndWait(resourceGroupName, parameters);
console.log(result);
});
}
function main() {
return __awaiter(this, void 0, void 0, function* () {
exportAResourceGroup();
exportAResourceGroupWithFiltering();
});
}
main().catch(console.error);
//# sourceMappingURL=resourceGroupsExportTemplateSample.js.map