I have an Virtual Disk (vhd) in an Azure blobstore and wan't to create a new Virtual Machine within Azure. To get this done i created an powershell script with contains the following:
#Global Parameters $ResourceGroup = Get-AzureRmResourceGroup | where {$_. ResourceGroupName -eq "VirtualMachines"} $VMName = "vmDenodoDatabases" $Location = "westeurope" $netWork = Get-AzureRmVirtualNetwork | where {$_. Name -eq "rg-network"} Write-Host $ResourceGroup.ResourceGroupName #VM Parameter $vmSize = "Standard_A2" $BlobLocation = "https://storagedatavault.blob.core.windows.net/vms/Denodo%20Training%20QuickStart%20Virtual%20Machine-disk001.vhd?st=2019-08-24T17%3A12%3A00Z&se=2019-08-25T17%3A12%3A13Z&sp=racwdl&sv=2018-03-28&sr=c&sig=Ke1EC%2FEk%2FwUnnvhNE0grAz7YrXfoObwxzFy%2FBl7Ucdw%3D" #Network Parameter $SubnetName = "default" $InterfaceName = "DenodoDBNic1" # Create Network Security Group, Subnet and Virtual Network $NSG = Get-AzureRmNetworkSecurityGroup $Subnet = Get-AzureRmVirtualNetwork | where {$_.ResourceGroupName -eq "rg-Netwerk"} | Get-AzureRmVirtualNetworkSubnetConfig # Create the Interface #$pip = New-AzureRmPublicIpAddress -Name "$VMName-IP" -ResourceGroupName $ResourceGroup.ResourceGroupName -Location $Location -AllocationMethod Dynamic Write-Host $Subnet.Id #$Interface = New-AzureRMNetworkInterface -Name $InterfaceName -ResourceGroupName $ResourceGroup.ResourceGroupName -Location $Location -SubnetId $Subnet.Id -PublicIpAddressId $pip.Id # VM Details Write-Host "VM Config 1" $VirtualMachine = New-AzureRMVMConfig -VMName $VMName -VMSize $VMSize # -AvailabilitySetID $AvailabilitySet.Id Write-Host "VM Config 2" $VirtualMachine = Add-AzureRMVMNetworkInterface -VM $VirtualMachine -Id $Interface.Id Write-Host "VM Config 3" $VirtualMachine = Set-AzureRMVMOSDisk -VM $VirtualMachine -Name $VMName -VhdUri $BlobLocation -CreateOption Attach -Linux # Create the VM in Azure Write-Host "Create VM" New-AzureRMVM -ResourceGroupName $ResourceGroup.ResourceGroupName -Location $Location -VM $VirtualMachine
Everything goes fine except the last part in the execution it returns the following output:
New-AzureRMVM : Shared Access Signature (SAS) URI is not allowed for property 'osDisk.vhd.uri' with API version 2018-06-01 and higher. ErrorCode: InvalidParameter ErrorMessage: Shared Access Signature (SAS) URI is not allowed for property 'osDisk.vhd.uri' with API version 2018-06-01 and higher. ErrorTarget: osDisk.vhd.uri StatusCode: 400 ReasonPhrase: Bad Request OperationID : e71a5aa2-cd0e-4282-9cba-1594e3d2bc6e At C:\Users\Admin\Documents\PowerShell\CreateAzureVMFromBlob.ps1:37 char:1+ New-AzureRMVM -ResourceGroupName $ResourceGroup.ResourceGroupName -Lo ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
Can you please help me!!
Manny thanks
Erik