0

I want to Specify OS Disk Name while Creating VMSS using PowerShell to overcome the random OS Disk name like "VMSSNAME_1686_disk1_b5f021da0ba7409fbe7d028bdd50".

Command :

Set-AzVmssStorageProfile $vmssConfig `
              -OsDiskCreateOption "FromImage" `
              -ImageReferenceId $galleryImage.Id -OsDiskName $OSDiskName
            
# Set up information for authenticating with the virtual machine
Set-AzVmssOsProfile $vmssConfig `
              -AdminUsername $username `
              -AdminPassword $Password `
              -ComputerNamePrefix "UKSSPAG"
            
# Attach the virtual network to the config object
Add-AzVmssNetworkInterfaceConfiguration -VirtualMachineScaleSet $vmssConfig -Name "NICConfig" -Primary $true -IPConfiguration $ipConfig 
            
# Create the scale set with the config object (this step might take a few minutes)
New-AzVmss -ResourceGroupName $resourceGroup -VMScaleSetName $scaleSetName -VirtualMachineScaleSet $vmssConfig

Error :

New-AzVmss : Parameter 'osDisk.name' is not allowed.
ErrorCode: InvalidParameter
ErrorMessage: Parameter 'osDisk.name' is not allowed.
ErrorTarget: osDisk.name
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : e97450a3-ed89-46f8-84fa-6779a002a3e9
At line:1 char:1
+ New-AzVmss -ResourceGroupName $resourceGroup -VMScaleSetName $scaleSe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzVmss], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Automation.NewAzureRmVmss
Parmar
  • 1
  • 2
  • Please remove your [exact same question](https://stackoverflow.com/questions/69391739/i-want-to-specify-os-disk-name-while-creating-azure-vmss-using-powershell) you posted 5 days ago. Also, show us the **complete** error message, not just part of it. Seems a duplicate of [this question](https://stackoverflow.com/questions/45903498/getting-error-changing-property-osdisk-name-is-not-allowed-with-azure-power) – Theo Oct 04 '21 at 08:22
  • @Theo Thanks for your update, I've deleted my old question. – Parmar Oct 05 '21 at 10:30
  • @Theo the link provided by your is for VM and I've asked for VMSS. – Parmar Oct 05 '21 at 10:31
  • @Theo Detailed error updated, Please check – Parmar Oct 06 '21 at 09:35
  • Hello @Mr.Parmar, as per the error and the command you are using it seems you are using a gallery image to create a new VMSS and its bydefault we cannot set osdisk name while deploying from image .. – Ansuman Bal Oct 06 '21 at 09:42

0 Answers0