text: /*
   * 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.
  /**
   * This sample demonstrates how to Creates or updates a managed cluster.
   *
   * @summary Creates or updates a managed cluster.
   * x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/stable/2022-01-01/examples/ManagedClustersCreate_Snapshot.json
   */
  const { ContainerServiceClient } = require("@azure/arm-containerservice");
  const { DefaultAzureCredential } = require("@azure/identity");
  
  async function createManagedClusterUsingAnAgentPoolSnapshot() {
    const subscriptionId = "subid1";
    const resourceGroupName = "rg1";
    const resourceName = "clustername1";
    const parameters = {
      addonProfiles: {},
      agentPoolProfiles: [
        {
          name: "nodepool1",
          type: "VirtualMachineScaleSets",
          count: 3,
          creationData: {
            sourceResourceId:
              "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1",
          },
          enableFips: true,
          enableNodePublicIP: true,
          mode: "System",
          osType: "Linux",
          vmSize: "Standard_DS2_v2",
        },
      ],
      autoScalerProfile: { scaleDownDelayAfterAdd: "15m", scanInterval: "20s" },
      diskEncryptionSetID:
        "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des",
      dnsPrefix: "dnsprefix1",
      enablePodSecurityPolicy: false,
      enableRbac: true,
      kubernetesVersion: "",
      linuxProfile: {
        adminUsername: "azureuser",
        ssh: { publicKeys: [{ keyData: "keydata" }] },
      },
      location: "location1",
      networkProfile: {
        loadBalancerProfile: { managedOutboundIPs: { count: 2 } },
        loadBalancerSku: "standard",
        outboundType: "loadBalancer",
      },
      servicePrincipalProfile: { clientId: "clientid", secret: "secret" },
      sku: { name: "Basic", tier: "Free" },
      tags: { archv2: "", tier: "production" },
      windowsProfile: {
        adminPassword: "replacePassword1234$",
        adminUsername: "azureuser",
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ContainerServiceClient(credential, subscriptionId);
    const result = await client.managedClusters.beginCreateOrUpdateAndWait(
      resourceGroupName,
      resourceName,
      parameters
    );
    console.log(result);
  }
  
  createManagedClusterUsingAnAgentPoolSnapshot().catch(console.error);
  