How to remove the plan associated with a VM?

Michael Malinowski 0 Reputation points
2025-01-27T14:41:18.05+00:00

The error I get when trying to attach the disk:

Failed to start virtual machine 'my-vm'. Error: Creating a virtual machine from a non-Marketplace image does not need Plan information. Please remove the Plan information from VM 'my-vms/providers/Microsoft.Compute/virtualMachines/my-vm'>my-vm'.

I cannot delete the vm and I need the certain disk I'm trying to attach.

How do you de-attach the plan? I've tried a few powershell commands and also couldn't find anything on the web portal.

Thank you in advance

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,303 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Akshay kumar Mandha 2,355 Reputation points Microsoft Vendor
    2025-01-27T19:16:16.73+00:00

    Hi Michael Malinowski,
    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here
    Based on your query,
    Could you please try below script to remove plan and attach the certain disk I have tested in my lab it is working as expected Please try and let me know If you have already existing disk, you ignore that disk creation command only you can replace names and run the script in PowerShell

    # Create the Disk Configuration
    $diskConfig = New-AzDiskConfig -SkuName StandardSSD_LRS -Location "EastUS" -CreateOption Empty -DiskSizeGB 128
    # Create the Disk in the 'Akshay' resource group
    $disk = New-AzDisk -ResourceGroupName Akshay -DiskName akshaydisk123 -Disk $diskConfig
    # Get the VM Information
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    # Remove the Plan Information
    $vm.Plan = $null
    # Update the VM
    Update-AzVM -ResourceGroupName Akshay -VM $vm
    # Verify the Changes
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    $vm | Format-List
    # Attach the New Disk to the VM
    # Get the Disk and VM Info
    $disk = Get-AzDisk -ResourceGroupName Akshay -DiskName akshaydisk123
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    # Attach the Disk to the VM
    $vm.StorageProfile.DataDisks.Add([Microsoft.Azure.Management.Compute.Models.DataDisk]@{
        Lun          = 0
        Name         = $disk.Name
        CreateOption = "Attach"
        ManagedDisk  = @{ Id = $disk.Id }
    })
    # Update the VM with the new disk
    Update-AzVM -ResourceGroupName Akshay -VM $vm
    # Verify Disk Attachment
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    $vm.StorageProfile.DataDisks | Format-List
    
    # Get the VM Info 
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    # Identify the disk (assuming Lun = 0)
    $dataDisk = $vm.StorageProfile.DataDisks | Where-Object { $_.Lun -eq 0 }
    # Remove the disk from the VM
    $vm.StorageProfile.DataDisks.Remove($dataDisk)
    # Update the VM  
    Update-AzVM -ResourceGroupName Akshay -VM $vm
    # to verify detachment
    $vm = Get-AzVM -ResourceGroupName Akshay -Name pcsvm
    $vm.StorageProfile.DataDisks | Format-List
    

    And also review the below link it is related same kind of question will be there it might help any one of the inputs
    https://learn.microsoft.com/en-us/answers/questions/359145/how-to-fix-a-generalized-vm-that-requires-plan-inf

    Please let me know if you have any further questions Tag me in a comment, and I will be happy to help. Feel free to ask if you need any additional information. I am always here to assist you as needed.

    If you found this information helpful, please click an accepting the answer and 👍"Upvote" on my post for other community member's reference User's image


  2. Nikhil Duserla 4,115 Reputation points Microsoft Vendor
    2025-01-29T13:00:51.6433333+00:00

    Hi @Michael Malinowski,

    We have noticed that you rated an answer as not helpful. We appreciate your feedback and are committed to improving your experience with the Q&A. I have worked on finding an alternative solution to address your issue. Continuing on, I have a few things to share here.

    Continuing on, I have a few things to share here-

    If you are looking to attach the ALMA8 disk to an existing CentOS7 VM, it is possible. However, you need to remove that a plan is associated with the VM.

    In contrast, non-Marketplace images do not require any plan information. If this information is inadvertently included in your VM configuration, it may result in errors when performing tasks such as attaching disks.

    If the VM was originally created with incorrect settings or captured from an image that included plan details (even after being generalized), Azure will preserve these settings in the VM's metadata. This can lead to issues when attempting to perform actions that don't require plan information.

    If you are looking to changing the OS from CentOS7 to ALMA8 during the initial VM creation process is not possible.

    Microsoft does not support an upgrade of the operating system of a Microsoft Azure virtual machine. Instead, you should create a new Azure virtual machine that is running the supported version of the operating system that is required and then migrate the workload- https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/server-software-support

    I have provided a detailed answer which has clear for which you are looking for. If you wish, you may re-surveying for the engagement you received on the thread. Your feedback is very important to us.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.