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,286 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akshay kumar Mandha 2,265 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


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.