Azure: Error Deploying VM from Generalised Image (Image Undeployable) - powershell

I've been trying to use Powershell (following MS docs) to deploy a new VM from a generalised image but I keep getting this error.
New-AzureRmVM : Long running operation failed with status 'Failed'.
ErrorCode: OSProvisioningClientError
ErrorMessage: OS provisioning for VM 'MyVM' failed. Error details: This installation of Windows is undeployable. Make sure the image has been properly prepared (generalized).
Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
StartTime: 22/03/2017 10:06:24
EndTime: 22/03/2017 10:10:37
OperationID: 549f97d1-ca39-4bc5-bd6c-65e37a8d398f
Status: Failed
At C:\Visual Studio Projects\Deployment\VmSetup.ps1:97 char:1
+ New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
Trouble is that I did run a sysprep and generalised the image.
Code : OSState/generalized
Level : Info
DisplayStatus : VM generalized
Message :
Time :
I'm also unable to start the VM again because it's told me it's generalised.
Failed to start virtual machine 'OtherVM'. Error: Operation 'start' is not allowed on VM 'OtherVM' since the VM is generalized.
Image saving script:
#Script to save image
$vmName = "OtherVM"
$rgName = "MyResourceGroup"
#Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Set-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Status
$vm.Statuses
#Save VM Image
Save-AzureRmVMImage -ResourceGroupName $rgName -Name $vmName `
-DestinationContainerName "generalisedimages" -VHDNamePrefix "gen" `
#-Path "C:\VMTemplate\VmTemplate.json"
Write-Output "Imaged saved."
And the deploy script.
#
# VmDeploy.ps1
#
#Sign into Azure account
#Login-AzureRmAccount
# Name of the virtual machine. This example sets the VM name as "myVM".
$vmName = "MyVM"
#Set resource group and subnet name
$rgName = "MyResourceGroup"
$subnetName = "default"
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
#Set location and vNet name
$location = "UK South"
$vnetName = "{0}-vnet" -f $rgName
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet
#Create public IP
$ipName = "{0}-ip" -f $vmName
$pip = New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $location -AllocationMethod Dynamic
#Create NIC
$nicName = "{0}-nic" -f $vmName
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id
#Create network security group and allow RDP
$nsgName = "{0}-nsg" -f $vmName
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name Rdp -Description "Allow RDP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 110 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 3389
$httpRule = New-AzureRmNetworkSecurityRuleConfig -Name Http -Description "Allow HTTP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 120 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 80
$httpsRule = New-AzureRmNetworkSecurityRuleConfig -Name Https -Description "Allow HTTPS" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 130 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 443
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgName -Location $location -Name $nsgName -SecurityRules $rdpRule, $httpRule, $httpsRule
#Get completed virtual network
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
#Uri of VM image
$imageURI = "https://*******.blob.core.windows.net/system/Microsoft.Compute/Images/generalisedimages/genosDisk.86g419f6-0de6-4331-hi54-32hse8de6bd4.vhd"
# Enter a new user name and password to use as the local administrator account
# for remotely accessing the VM.
$cred = Get-Credential
# Name of the storage account where the VHD is located. This example sets the
# storage account name as "myStorageAccount"
$storageRgName = $rgName
$storageAccName = "mystorage"
# Size of the virtual machine. This example creates "Standard_D2_v2" sized VM.
# See the VM sizes documentation for more information:
# https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/
$vmSize = "Standard_A1"
# Computer name for the VM. This examples sets the computer name as "myComputer".
$computerName = "New VM"
# Name of the disk that holds the OS. This example sets the
# OS disk name as "myOsDisk"
$osDiskName = "OsDisk"
# Assign a SKU name. This example sets the SKU name as "Standard_LRS"
# Valid values for -SkuName are: Standard_LRS - locally redundant storage, Standard_ZRS - zone redundant
# storage, Standard_GRS - geo redundant storage, Standard_RAGRS - read access geo redundant storage,
# Premium_LRS - premium locally redundant storage.
$skuName = "Standard_LRS"
# Get the storage account where the uploaded image is stored
$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $storageRgName -AccountName $storageAccName
Write-Output $storageAcc
# Set the VM name and size
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
#Set the Windows operating system configuration and add the NIC
$vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName `
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
# Create the OS disk URI
$osDiskUri = '{0}vhds/{1}-{2}.vhd' `
-f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
Write-Output "OS Disk URI:" $osDiskUri
# Configure the OS disk to be created from the existing VHD image (-CreateOption fromImage).
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption fromImage -SourceImageUri $imageURI -Windows
Write-Output $vm
# Create the new VM
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
$vmList = Get-AzureRmVM -ResourceGroupName $rgName
$vmList.Name

OS provisioning for VM 'MyVM' failed. Error details: This installation
of Windows is undeployable. Make sure the image has been properly
prepared (generalized).
According to the error message, it seems you have not generalized VM correctly.
we should RDP to Azure VM, and run sysprep, in the System Preparation Tool dialog box, select Enter System Out-of-Box Experience (OOBE), and make sure that the Generalize check box is selected. In Shutdown Options, select Shutdown.
More information about Generalize a Windows virtual machine, please refer to this link.
I'm also unable to start the VM again because it's told me it's
generalised
Capture an image of an Azure widnows VM, this process deletes the original virtual machine after it is captured.
Prior to capturing an image of an Azure virtual machine, it is recommended the target virtual machine be backed up

Related

Create Azure VM using PowerShell with Managed Disks using Market Place Image

I have been scratching my head for ages and cannot find any information about this. So can someone please tell me how to create a VM using PowerShell so that the VM has managed disks without using ConvertTo-AzureRmVMManagedDisk and is based on a market place image like Get-AzureRmVMImage -Location $location -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2016-Datacenter" | Sort-Object Version -Descending | Select-Object -Index 0
Thanks.
Do you mean you want to use PowerShell to create an Azure VM with managed OS disk?
If I understand it correctly, we can use the following PowerShell script to create it:
$location = "eastus"
New-AzureRmResourceGroup -Name jasonvm -Location $location
# Create a subnet configuration
$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name mySubnet -AddressPrefix 192.168.1.0/24
# Create a virtual network
$vnet = New-AzureRmVirtualNetwork -ResourceGroupName jasonvm -Location $location `
-Name MYvNET -AddressPrefix 192.168.0.0/16 -Subnet $subnetConfig
# Create a public IP address and specify a DNS name
$pip = New-AzureRmPublicIpAddress -ResourceGroupName jasonvm -Location $location `
-AllocationMethod Static -IdleTimeoutInMinutes 4 -Name "mypublicdns$(Get-Random)"
# Create an inbound network security group rule for port 3389
$nsgRuleRDP = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleRDP -Protocol Tcp `
-Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
-DestinationPortRange 3389 -Access Allow
# Create an inbound network security group rule for port 80
$nsgRuleWeb = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleWWW -Protocol Tcp `
-Direction Inbound -Priority 1001 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
-DestinationPortRange 80 -Access Allow
# Create a network security group
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName jasonvm -Location $location `
-Name myNetworkSecurityGroup -SecurityRules $nsgRuleRDP,$nsgRuleWeb
# Create a virtual network card and associate with public IP address and NSG
$nic = New-AzureRmNetworkInterface -Name myNic -ResourceGroupName jasonvm -Location $location `
-SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id
# Define a credential object
$cred = Get-Credential
# Create a virtual machine configuration
$vmConfig = New-AzureRmVMConfig -VMName myVM -VMSize Standard_DS2_v2 | `
Set-AzureRmVMOperatingSystem -Windows -ComputerName myVM -Credential $cred | `
Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer -Offer WindowsServer `
-Skus 2016-Datacenter -Version latest | Add-AzureRmVMNetworkInterface -Id $nic.Id
# Create the virtual machine
New-AzureRmVM -ResourceGroupName jasonvm -Location $location -VM $vmConfig
Here is the result:

How to assign a network interface to a newly created VM with ARM Powershell?

I'm getting started with ARM in our Azure tenancy...
Firstly, I created a resource group, TEST-RG.
I've created a Network Interface in my resource group using the Portal. Let's call it TEST-NIC in resource group TEST-RG.
I've also created a DS2_V2 VM called TEST-VM, running Windows 2012 R2 and also in TEST-RG.
How do I associate TEST-NIC with TEST-VM? I can't see a way of doing that in the Portal, nor can I see a way in the Portal of creating a VM with no network interface, such that I can add TEST-NIC later.
So, I assume this can only be done in PS, but I'm not at all clear how...
Have I lost the plot? Any guidance would be appreciated.
Thanks
For now, Azure does not support add a NIC to an existing VM.
can I see a way in the Portal of creating a VM with no network
interface, such that I can add TEST-NIC later
We can't create a VM without NIC, but we can use PowerShell to create a new VM with this NIC.
Here is my script to create a new VM with existing NIC.
$ResourceGroupName = "nic"
$Location = "Eastus"
$StorageName = "jasondisk321"
$StorageType = "Standard_LRS"
$VMName = "myvm"
$VMSize = "Standard_DS2_v2"
$OSDiskName = $VMName + "OSDisk"
$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -Type $StorageType -Location $Location
$nic = Get-AzureRmNetworkInterface -Name jasonnic -ResourceGroupName $rgname
$nicId = $nic.Id
$Credential = Get-Credential
$vm = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
$vm = Set-AzureRmVMOperatingSystem -VM $vm -ComputerName $VMName -Windows -Credential $Credential
$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2012-R2-Datacenter" -Version "latest"
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
$OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd"
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $OSDiskName -VhdUri $OSDiskUri -CreateOption FromImage
New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $vm
Firstly, you can't deploy an ARM VM without a NIC.
If you look at this script
It has the lines
$Interface = New-AzureRmNetworkInterface -Name $InterfaceName `
-ResourceGroupName $ResourceGroupName `
-Location $Location `
-SubnetId $VNet.Subnets[0].Id `
-PublicIpAddressId $PIp.Id
Which is later used by
$VirtualMachine = Add-AzureRmVMNetworkInterface `
-VM $VirtualMachine `
-Id $Interface.Id
So if you want to use an existing NIC you just need to pass the $interface.id (from Get-AzureRmVMNetworkInterface)
When you wrap those two around the rest of a VM deployment script you'll build a VM with a NIC

Configure Azure Point-To-Site VPN to Virtual Network created in a ResourceGroup

I am using the new Resource Manager interface to create my Virtual Network. And I can't figure out how to configure a Point-To-Site VPN and get the VPN client thru the Powershell API.
My Script:
$accountName = "a#a.com"
$subscriptionId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
$vnetname = "VNet1"
$rgname = "MyRG"
$sharedKey = -join(97..122|%{[char]$_}|Get-Random -C 20)
Get-AzureAccount -Name $accountName
Set-AzureSubscription -SubscriptionId $subscriptionId
New-AzureResourceGroup -Name "MyRG" -Location "Central US" -Force
$subnet = New-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix '10.192.0.0/24'
New-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname -Location "Central US" -AddressPrefix '10.0.0.0/8' -Subnet $subnet -Force
I go into the new Portal and only have DNS options to create, no ability to create a VPN gateway. I tried scripting it, but couldn't figure out the point to site piece. Any suggestions?
Gateway script:
$gwip = New-AzurePublicIpAddress -Name ($vnetname + "gwip") -ResourceGroupName $rgname -Location $location -AllocationMethod Dynamic
$vnet = Get-AzureVirtualNetwork -Name $vnetname -ResourceGroupName $rgname
$subnet = Get-AzureVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
$gwipconfig = New-AzureVirtualNetworkGatewayIpConfig -Name ($vnetname + "gwipconfig") -SubnetId $subnet.Id -PublicIpAddressId $gwip.Id
$gw = New-AzureVirtualNetworkGateway -Name ($vnetname + "gw1") -ResourceGroupName $rgname -Location "Central US" -IpConfigurations $gwipconfig -GatewayType Vpn -VpnType RouteBased
$localGw = New-AzureLocalNetworkGateway -Name ($vnetname + "gw1-local") -ResourceGroupName $rgname -Location "Central US" -GatewayIpAddress $gwipconfig -AddressPrefix '172.16.0.0/24'
New-AzureVirtualNetworkGatewayConnection -Name ($vnetname + "gw1-conn") -ResourceGroupName $rgname -Location "Central US" -VirtualNetworkGateway1 $gw -LocalNetworkGateway2 $localGw -ConnectionType IPsec -RoutingWeight 10 -SharedKey $sharedKey
This was added 1/19/2016, the Powershell on how to create a Point to Site VPN in a Resource manager Network
https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-howto-point-to-site-rm-ps/
There is a one week old Document in the MS Azure documentation saying that it is not possible (yet) under the Resource Manager model.
This article applies to point-to-site connections for virtual networks
created using the classic deployment model (Service Management). At
this time, point-to-site connections to a virtual network created
using the Azure Resource Manager deployment model are not supported.

Azure InvalidParameter: StorageProfile.dataDisks.lun does not have required value(s) for image in storage profile

I have a script to create VMs on Azure using DS Series storage. I am trying to create a VM using one of the SQL Server optimized images. When I change the Publisher, Offer, and SKU to match the SQL Server image I keep getting an error:
InvalidParameter: StorageProfile.dataDisks.lun does not have required value(s) for image in storage profile
Does anyone know how I should modify the following script so that I can use one of the pre-defined image templates for SQL Server?
Switch-AzureMode AzureResourceManager
Add-AzureAccount
$subscr="subscription"
Select-AzureSubscription -SubscriptionName $subscr
$rgName="test-resource-group"
$locName="East US 2"
New-AzureResourceGroup -Name $rgName -Location $locName
$saName="testpremiumstorage"
$saType="Premium_LRS"
New-AzureStorageAccount -Name $saName -ResourceGroupName $rgName –Type $saType -Location $locName
$frontendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testfrontendSubnet" -AddressPrefix 10.3.3.0/24
$backendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -AddressPrefix 10.3.2.0/24
New-AzurevirtualNetwork -Name "testVNet" -ResourceGroupName $rgName -Location $locName -AddressPrefix 10.3.0.0/16 -Subnet $frontendSubnet,$backendSubnet
$publicIP = New-AzurePublicIpAddress -Name "testPublicIp" -ResourceGroupName $rgName -Location $locName –AllocationMethod Static -DomainNameLabel "test-public-ip"
$frontendIP = New-AzureLoadBalancerFrontendIpConfig -Name "test-LB-Frontend" -PublicIpAddress $publicIP
$beaddresspool= New-AzureLoadBalancerBackendAddressPoolConfig -Name "test-LB-backend"
$inboundNATRule1= New-AzureLoadBalancerInboundNatRuleConfig -Name "RDP1" -FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3441 -BackendPort 3389
$inboundNATRule2= New-AzureLoadBalancerInboundNatRuleConfig -Name "RDP2" -FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3442 -BackendPort 3389
$healthProbe = New-AzureLoadBalancerProbeConfig -Name "HealthProbe" -RequestPath "HealthProbe.aspx" -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2
$lbrule = New-AzureLoadBalancerRuleConfig -Name "HTTP" -FrontendIpConfiguration $frontendIP -BackendAddressPool $beAddressPool -Protocol Tcp -FrontendPort 80 -BackendPort 80
$NRPLB = New-AzureLoadBalancer -ResourceGroupName $rgName -Name "test-LB" -Location $locName -FrontendIpConfiguration $frontendIP -InboundNatRule $inboundNATRule1,$inboundNatRule2 -LoadBalancingRule $lbrule -BackendAddressPool $beAddressPool -Probe $healthProbe
$nicName="test-NIC"
$lbName="test-LB"
$bePoolIndex=0
$vnetName="testVNet"
$subnetIndex=0
$natRuleIndex=0
$vnet=Get-AzurevirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$lb=Get-AzureLoadBalancer -Name $lbName -ResourceGroupName $rgName
$backendSubnet = Get-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -VirtualNetwork $vnet
$nic=New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -Subnet $backendSubnet -LoadBalancerBackendAddressPool $lb.BackendAddressPools[$bePoolIndex] -LoadBalancerInboundNatRule $lb.InboundNatRules[$natRuleIndex]
$vmName="test"
$vmSize="Standard_DS2"
$vm=New-AzureVMConfig -VMName $vmName -VMSize $vmSize
#This is where the error occurs. If it is switched to the commented image everything will work fine but not when
# trying to create the SQL Server based image
#$pubName="MicrosoftWindowsServer"
#$offerName="WindowsServer"
#$skuName="2012-R2-Datacenter"
$pubName="MicrosoftSQLServer"
$offerName="SQL2014SP1-WS2012R2"
$skuName="Enterprise-Optimized-for-OLTP"
$cred=Get-Credential -Message "Type the name and password of the local administrator account."
$vm=Set-AzureVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AzureVMSourceImage -VM $vm -PublisherName $pubName -Offer $offerName -Skus $skuName -Version "latest"
$vm=Add-AzureVMNetworkInterface -VM $vm -Id $nic.Id
$diskName="test-OSDisk"
$storageAcc=Get-AzureStorageAccount -ResourceGroupName $rgName -Name $saName
$osDiskUri=$storageAcc.PrimaryEndpoints.Blob.ToString() + "vhds/" + $diskName + ".vhd"
$vm=Set-AzureVMOSDisk -VM $vm -Name $diskName -VhdUri $osDiskUri -CreateOption fromImage
New-AzureVM -ResourceGroupName $rgName -Location $locName -VM $vm
As noted in the script there is a section where the Publisher, Offer, and SKU are defined. When those are switched to the SQL Server related items the script fails with the error but if they use the basic Windows Server 2012 items the script will run fine. Could the item names be different if using premium storage or is there a different way to create the VM?
Some steps that helped me to solve similar issues:
Check if you indeed have the right name - see #theadriangreen's link link and the listing commands behind az vm image --help
Check if you added plan information to the spin-up
Check if you have accepted the terms with az vm image accept-terms --help

Create Azure VM with Premium Storage and Public Static IP Using Powershell

I am trying to create a DS Series VM in Azure using premium storage and assign it a static public IP. From what I have read you can no longer assign a public static IP to a resource group (it only works with the older service groups). I have created a Powershell script that attempts to create a load balancer and assign a new VM to the load balancer. In theory the load balancer can get assigned the public static IP and traffic would get routed to the VM. The script appears to run and the VM is created but it will not Start. The status of the VM is listed as Failed. Can someone please tell me what I am doing wrong in this script?
Switch-AzureMode AzureResourceManager
Add-AzureAccount
$subscr="mysubscription" Select-AzureSubscription -SubscriptionName $subscr
$rgName="testRG" $locName="West US" New-AzureResourceGroup -Name $rgName -Location $locName
$saName="teststorage" $saType="Premium_LRS" New-AzureStorageAccount
-Name $saName -ResourceGroupName $rgName –Type $saType -Location $locName
$frontendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testfrontendSubnet" -AddressPrefix 10.0.1.0/24 $backendSubnet=New-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -AddressPrefix 10.0.2.0/24 New-AzurevirtualNetwork
-Name "testVNet" -ResourceGroupName $rgName -Location $locName -AddressPrefix 10.0.0.0/16 -Subnet $frontendSubnet,$backendSubnet
$publicIP = New-AzurePublicIpAddress -Name "testPublicIp"
-ResourceGroupName $rgName -Location $locName –AllocationMethod Static -DomainNameLabel "testIP" $frontendIP = New-AzureLoadBalancerFrontendIpConfig -Name "test-LB-Frontend"
-PublicIpAddress $publicIP $beaddresspool= New-AzureLoadBalancerBackendAddressPoolConfig -Name "test-LB-backend" $lbrule = New-AzureLoadBalancerRuleConfig -Name "HTTP"
-FrontendIpConfiguration $frontendIP -BackendAddressPool $beAddressPool -Protocol Tcp -FrontendPort 80 -BackendPort 80 $NRPLB = New-AzureLoadBalancer -ResourceGroupName $rgName -Name "test-LB"
-Location $locName -FrontendIpConfiguration $frontendIP -LoadBalancingRule $lbrule -BackendAddressPool $beAddressPool
$nicName="test-NIC" $lbName="test-LB" $bePoolIndex=0 $vnetName="testVNet" $subnetIndex=0 $natRuleIndex=0 $vnet=Get-AzurevirtualNetwork -Name $vnetName -ResourceGroupName $rgName $lb=Get-AzureLoadBalancer -Name $lbName -ResourceGroupName $rgName
$backendSubnet = Get-AzureVirtualNetworkSubnetConfig -Name "testbackendSubnet" -VirtualNetwork $vnet $nic=New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -Subnet $backendSubnet
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[$bePoolIndex] -LoadBalancerInboundNatRule $lb.InboundNatRules[$natRuleIndex]
# TWO OTHERS I'VE TRIED WITHOUT SUCCESS
# $nic=New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -Subnet $backendSubnet
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[$bePoolIndex]
# $nic=New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -Subnet $vnet.Subnets[$subnetIndex].Id
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[$bePoolIndex]
$vmName="test" $vmSize="Standard_DS2" $vm=New-AzureVMConfig -VMName $vmName -VMSize $vmSize
$pubName="MicrosoftWindowsServer" $offerName="WindowsServer" $skuName="2012-R2-Datacenter" $cred=Get-Credential -Message "Type the name and password of the local administrator account." $vm=Set-AzureVMOperatingSystem -VM $vm -Windows -ComputerName $vmName
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate $vm=Set-AzureVMSourceImage -VM $vm -PublisherName $pubName -Offer $offerName -Skus $skuName -Version "latest" $vm=Add-AzureVMNetworkInterface -VM $vm -Id $nic.Id
$diskName="test-OSDisk" $storageAcc=Get-AzureStorageAccount
-ResourceGroupName $rgName -Name $saName $osDiskUri=$storageAcc.PrimaryEndpoints.Blob.ToString() + "vhds/" + $diskName + ".vhd" $vm=Set-AzureVMOSDisk -VM $vm -Name $diskName
-VhdUri $osDiskUri -CreateOption fromImage New-AzureVM -ResourceGroupName $rgName -Location $locName -VM $vm
You are using the location West US and Azure is having severe capacity issues with DS series VMs using Premium storage in East US 2 and West US since a couple of days.
Sadly this problem have not been mentioned the Azure status page.
Try to use another location that support Premium storage, like West Europe and your VM should create and start normally.