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.
  const { ComputeManagementClient } = require("@azure/arm-compute");
  const { DefaultAzureCredential } = require("@azure/identity");
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromABlobWithDiskEncryptionSet.json
   */
  async function createAVirtualMachineImageFromABlobWithDiskEncryptionSetResource() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          blobUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
          diskEncryptionSet: {
            id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
          },
          osState: "Generalized",
          osType: "Linux",
        },
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromABlobWithDiskEncryptionSetResource().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromABlob.json
   */
  async function createAVirtualMachineImageFromABlob() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          blobUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
          osState: "Generalized",
          osType: "Linux",
        },
        zoneResilient: true,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromABlob().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromAManagedDiskWithDiskEncryptionSet.json
   */
  async function createAVirtualMachineImageFromAManagedDiskWithDiskEncryptionSetResource() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          diskEncryptionSet: {
            id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
          },
          managedDisk: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk",
          },
          osState: "Generalized",
          osType: "Linux",
        },
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromAManagedDiskWithDiskEncryptionSetResource().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromAManagedDisk.json
   */
  async function createAVirtualMachineImageFromAManagedDisk() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          managedDisk: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk",
          },
          osState: "Generalized",
          osType: "Linux",
        },
        zoneResilient: true,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromAManagedDisk().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromASnapshotWithDiskEncryptionSet.json
   */
  async function createAVirtualMachineImageFromASnapshotWithDiskEncryptionSetResource() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          diskEncryptionSet: {
            id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
          },
          osState: "Generalized",
          osType: "Linux",
          snapshot: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot",
          },
        },
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromASnapshotWithDiskEncryptionSetResource().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromASnapshot.json
   */
  async function createAVirtualMachineImageFromASnapshot() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        osDisk: {
          osState: "Generalized",
          osType: "Linux",
          snapshot: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot",
          },
        },
        zoneResilient: false,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromASnapshot().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageFromAVM.json
   */
  async function createAVirtualMachineImageFromAnExistingVirtualMachine() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      sourceVirtualMachine: {
        id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageFromAnExistingVirtualMachine().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageThatIncludesADataDiskFromABlob.json
   */
  async function createAVirtualMachineImageThatIncludesADataDiskFromABlob() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        dataDisks: [
          {
            blobUri: "https://mystorageaccount.blob.core.windows.net/dataimages/dataimage.vhd",
            lun: 1,
          },
        ],
        osDisk: {
          blobUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
          osState: "Generalized",
          osType: "Linux",
        },
        zoneResilient: false,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageThatIncludesADataDiskFromABlob().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageThatIncludesADataDiskFromAManagedDisk.json
   */
  async function createAVirtualMachineImageThatIncludesADataDiskFromAManagedDisk() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        dataDisks: [
          {
            lun: 1,
            managedDisk: {
              id: "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk2",
            },
          },
        ],
        osDisk: {
          managedDisk: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk",
          },
          osState: "Generalized",
          osType: "Linux",
        },
        zoneResilient: false,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageThatIncludesADataDiskFromAManagedDisk().catch(console.error);
  
  /**
   * This sample demonstrates how to Create or update an image.
   *
   * @summary Create or update an image.
   * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/stable/2021-11-01/examples/compute/CreateAnImageThatIncludesADataDiskFromASnapshot.json
   */
  async function createAVirtualMachineImageThatIncludesADataDiskFromASnapshot() {
    const subscriptionId = "{subscription-id}";
    const resourceGroupName = "myResourceGroup";
    const imageName = "myImage";
    const parameters = {
      location: "West US",
      storageProfile: {
        dataDisks: [
          {
            lun: 1,
            snapshot: {
              id: "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot2",
            },
          },
        ],
        osDisk: {
          osState: "Generalized",
          osType: "Linux",
          snapshot: {
            id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot",
          },
        },
        zoneResilient: true,
      },
    };
    const credential = new DefaultAzureCredential();
    const client = new ComputeManagementClient(credential, subscriptionId);
    const result = await client.images.beginCreateOrUpdateAndWait(
      resourceGroupName,
      imageName,
      parameters
    );
    console.log(result);
  }
  
  createAVirtualMachineImageThatIncludesADataDiskFromASnapshot().catch(console.error);
  