summary import { VirtualMachineScaleSet , ComputeManagementClient } from "@msinternal/compute-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createAScaleSetWithDiskEncryptionSetResourceInOSDiskAndDataDisk ( ) { const subscriptionId = "{subscription-id}" ; const resourceGroupName = "myResourceGroup" ; const vmScaleSetName = "{vmss-name}" ; const parameters = { location : "westus" , overprovision : true , sku : { name : "Standard_DS1_v2" , capacity : 3 , tier : "Standard" } , upgradePolicy : { mode : "Manual" } , virtualMachineProfile : { networkProfile : { networkInterfaceConfigurations : [ { name : "{vmss-name}" , enableIPForwarding : true , ipConfigurations : [ { name : "{vmss-name}" , subnet : { id : "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}" } } ] , primary : true } ] } , osProfile : { adminPassword : "{your-password}" , adminUsername : "{your-username}" , computerNamePrefix : "{vmss-name}" } , storageProfile : { dataDisks : [ { caching : "ReadWrite" , createOption : "Empty" , diskSizeGB : 1023 , lun : 0 , managedDisk : { diskEncryptionSet : { id : "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}" } , storageAccountType : "Standard_LRS" } } ] , imageReference : { id : "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}" } , osDisk : { caching : "ReadWrite" , createOption : "FromImage" , managedDisk : { diskEncryptionSet : { id : "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}" } , storageAccountType : "Standard_LRS" } } } } } ; const credential = new DefaultAzureCredential ( ) ; const client = new ComputeManagementClient ( credential , subscriptionId ) ; const result = await client . virtualMachineScaleSets . beginCreateOrUpdateAndWait ( resourceGroupName , vmScaleSetName , parameters ) ; console . log ( result ) ; } createAScaleSetWithDiskEncryptionSetResourceInOSDiskAndDataDisk ( ) . catch ( console . error ) ;