Omar Ochoa
Omar Ochoa

Reputation: 11

Trying to create Palo Alto VM with Azure Powershell

I'm currently trying to create a Palo Alto VM-Series firewall with Azure Powershell to later incorporate some changes.

I have the following relevant code

$VM = Set-AzureRmVMSourceImage -VM $vm -PublisherName $pubName -Offer $offerName -Skus $skuName -Version "latest"

$VM = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize 

Set-AzureRmVMPlan -VM $VM -Publisher paloaltonetworks -Product vmseries1 -Name "bundle2" 

# Specify the OS disk name and create the VM
$DiskName='OSDisk-'+$VMName
$SA = Get-AzureRmStorageAccount -Name $SAName -ResourceGroupName $RGName
$OSDiskUri = $SA.PrimaryEndpoints.Blob.ToString() + "vhds/" + $VMName+".vhd"
   $VM = Set-AzureRmVMOSDisk -VM $VM -Name $DiskName -VhdUri $OSDiskUri -CreateOption fromImage
$VM = Add-AzureRmVMNetworkInterface -VM $VM -Id $VNIC01.Id -Primary
New-AzureRmVM -ResourceGroupName $RGName -Location $Region -VM $VM -Verbose

I get the error

New-AzureRmVM : Changing property 'osDisk.createOption' is not allowed.
ErrorCode: PropertyChangeNotAllowed
ErrorMessage: Changing property 'osDisk.createOption' is not allowed.
StatusCode: 409
ReasonPhrase: Conflict
OperationID : 882848ca-7053-4098-9599-d25d58b4b3fe
At C:\Users\IEUser\Desktop\DeployMultipleNicPANWv0.2.ps1:192 char:1
+ New-AzureRmVM -ResourceGroupName $RGName -Location $Region -VM $VM -V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmVM], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

I had previously tried some changes since it tells me the origin vhd was created with Premium Storage and I have a Standard Storage.

Could someone point me to the right direction?

Thanks

Upvotes: 1

Views: 809

Answers (1)

Sa Yang
Sa Yang

Reputation: 9411

According to your code, I found it the scripts contain

“$VM = Set-AzureRmVMOSDisk -VM $VM -Name $DiskName -VhdUri $OSDiskUri -CreateOption fromImage”.

And the error code is 409. This issue may caused by this :VM created from Image cannot have blob based disks. All disks have to be managed disks.

So, you should decide what source do you want to use to create VM. If you just want to use image to create VM, you should not add -VhdUri $OSDiskUri

More about how to use image to create a new VM with Powershell, refer to this document.

Also, you can use templates to create Palo Alto VM easily. More about how to create Palo Alto VM with templates, refer to this link.

----------Update----------

Ensure your image and other requirements had properly been configured ,and then you can use following Powershell scripts to create:

    $VM = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize 

    $VM = Set-AzureRmVMSourceImage -VM $vm -PublisherName $pubName -Offer $offerName -Skus $skuName -Version "latest"

    Set-AzureRmVMPlan -VM $VM -Publisher paloaltonetworks -Product vmseries1 -Name "bundle2" 


    $VM = Set-AzureRmVMOSDisk -VM $VM -CreateOption fromImage -Caching ReadWrite
    $VM = Add-AzureRmVMNetworkInterface -VM $VM -Id $VNIC01.Id -Primary

    New-AzureRmVM -ResourceGroupName $RGName -Location $Region -VM $VM -Verbose

NOTE: With managed disk, we cannot change OSdiskname when we use image or vdi to create VM. If you still cannot create it, I suggest you use the templates to create it. Just click deploy on Azure and then supply required information.

Upvotes: 1

Related Questions