powershellazure-powershellazure-dsvm

Error creating plan while provisioning Ubuntu DSVM using PowerShell


I'm trying to create an Ubuntu DSVM using PowerShell. I've determined that the Ubuntu DSVM image is released by publisher microsoft-ads, under offer linux-data-science-vm-ubuntu and SKU linuxdsvmubuntu. I gather that when specifying my VM config in PowerShell, I need to use Set-AzureRmVMPlan and Set-AzureRmVMSourceImage, and have tried the following:

$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_D4s_v3
$vmConfig = Set-AzureRmVMPlan -VM $vmConfig -Name "linuxdsvmubuntu" -Product "linux-data-science-vm-ubuntu" -Publisher "microsoft-ads"
$vmConfig = Set-AzureRmVMOperatingSystem -VM $vmConfig -Linux -ComputerName $vmName -Credential $cred
$vmConfig = Set-AzureRmVMSourceImage -VM $vmConfig -PublisherName "microsoft-ads" -Offer "linux-data-science-vm-ubuntu" -Skus "linuxdsvmubuntu" -Version latest
$vmConfig = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vmConfig

Unfortunately, I get an error message from the New-AzureRmVM command:

New-AzureRmVM : This resource was created without a plan. A new plan cannot be associated with an update.
ErrorCode: CannotSetPlanOnUpdate
ErrorMessage: This resource was created without a plan. A new plan cannot be associated with an update.
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 648c62cd-4029-408e-8b6c-2ae4310001f6
At line:1 char:1
+ New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vmC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmVM], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

It seems that I might not be using Set-AzureRmVMPlan correctly. Is it clear to anyone what I'm doing wrong?


Solution

  • I discovered that the problem was not with this command itself, but apparently with a failed deployment from an earlier version of the command.

    The first time I tried to use Set-AzureRmVMSourceImage, I was not aware that I needed to use Set-AzureRmVMPlan as well. This resulted in a failed deployment, which I assumed meant that the deployed VM would be deleted from my resource group (or never be added to my resource group in the first place).

    What actually happened is that the failed deployment left a VM with status "Failed" in my resource group. When I later ran the commands shown above, the New-AzureRmVM command was treated as an update step instead of a brand new VM creation. That's why the error message indicates that, "This resource was created without a plan."

    Deleting everything and starting over resulted in success with the commands above.