Monday 15 August 2011

powershell - current azure storage doesn't allow create new VM -



powershell - current azure storage doesn't allow create new VM -

i have script, create vitrual machine, , install google chrome via dsc. created current storage account, , executed script. in next time have error. script:

$subscriptionname = "subscription_name" select-azuresubscription -subscriptionname $subscriptionname #replace variable values needed $vmname = "csetest" $storageaccount = 'googlechrome' $storagekey = 'key' $storagecontainer = 'dscarchives' $servicename="chromeinstaller" #get os image reference $arraywindows=( get-azurevmimage | where-object { $_.imagename -like "*windows*server*2012*r2*en.us*" } ) $locationallow=$arraywindows[$arraywindows.count-1].location $locationallow=$locationallow.split(";") $locationallow=$locationallow | where-object { $_ -like "* us*"} $localization=(get-random -inputobject $locationallow) #create vm config lastly windows update $vmconfig = new-azurevmconfig -name $vmname -imagename $arraywindows[$arraywindows.count-1].imagename -instancesize little #create provisioning configuration $vmprovisioningconfig = add-azureprovisioningconfig -vm $vmconfig -windows -adminusername "login" -password "password" $storagecontext = new-azurestoragecontext -storageaccountname $storageaccount -storageaccountkey $storagekey publish-azurevmdscconfiguration -configurationpath .\chromeinstaller.ps1 -containername $storagecontainer -storagecontext $storagecontext -force #set azure vm dsc extension run lcm meta-configuration $vmazureextension = set-azurevmdscextension -vm $vmprovisioningconfig -configurationarchive chromeinstaller.ps1.zip -configurationname openchrome -verbose -storagecontext $storagecontext -containername $storagecontainer -force #create vm new-azurevm -servicename $servicename -vms $vmazureextension -location $localization -waitforboot

in lastly line, script throw exception:

new-azurevm : badrequest: location or affinity grouping central of storage business relationship source image a699494373c04fc0bc8f2bb1389d6106__windows-server-2012-r2-201410.01-en.us-127gb.vhd resides not in same location or affinity grouping specified cloud service. source image must reside in storage business relationship has same affinity grouping or location cloud service west us.

so, can see, script generate random location. , can't link on location. so, how can prepare bug?

the source image vhd must exist in same location new virtual machine. utilize azcopy re-create image storage accounts in locations listed in $locationallow.

powershell azure

No comments:

Post a Comment