sdk/containerservice/arm-containerservice/samples-dev/managedClustersStopSample.ts (22 lines of code) (raw):

/* * 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. */ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { ContainerServiceClient } from "@azure/arm-containerservice"; import { DefaultAzureCredential } from "@azure/identity"; import "dotenv/config"; /** * This sample demonstrates how to This can only be performed on Azure Virtual Machine Scale set backed clusters. Stopping a cluster stops the control plane and agent nodes entirely, while maintaining all object and cluster state. A cluster does not accrue charges while it is stopped. See [stopping a cluster](https://docs.microsoft.com/azure/aks/start-stop-cluster) for more details about stopping a cluster. * * @summary This can only be performed on Azure Virtual Machine Scale set backed clusters. Stopping a cluster stops the control plane and agent nodes entirely, while maintaining all object and cluster state. A cluster does not accrue charges while it is stopped. See [stopping a cluster](https://docs.microsoft.com/azure/aks/start-stop-cluster) for more details about stopping a cluster. * x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/preview/2025-02-02-preview/examples/ManagedClustersStop.json */ async function stopManagedCluster(): Promise<void> { const subscriptionId = process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1"; const resourceName = "clustername1"; const credential = new DefaultAzureCredential(); const client = new ContainerServiceClient(credential, subscriptionId); const result = await client.managedClusters.beginStopAndWait( resourceGroupName, resourceName, ); console.log(result); } async function main(): Promise<void> { await stopManagedCluster(); } main().catch(console.error);