Create an Azure VM with an unmanaged disk -


i'm trying create azure vm unmanaged disk via powershell since managed disks aren't supported in azure government yet.

none of documentation find powershell vm creation references managed or unmanaged disks , default seems managed disks. vm creation fails following error:

new-azurermvm : managed disks not supported in region.

errorcode: badrequest

here's script i'm using:

$location = "usgovtexas"  new-azurermresourcegroup -name myresourcegroup -location $location  # create subnet configuration $subnetconfig = new-azurermvirtualnetworksubnetconfig -name mysubnet -addressprefix 192.168.1.0/24  # create virtual network $vnet = new-azurermvirtualnetwork -resourcegroupname myresourcegroup -location $location `     -name myvnet -addressprefix 192.168.0.0/16 -subnet $subnetconfig  # create public ip address , specify dns name $pip = new-azurermpublicipaddress -resourcegroupname myresourcegroup -location $location `     -allocationmethod static -idletimeoutinminutes 4 -name "mypublicdns$(get-random)"  # create inbound network security group rule port 3389 $nsgrulerdp = new-azurermnetworksecurityruleconfig -name mynetworksecuritygrouprulerdp  -protocol tcp `     -direction inbound -priority 1000 -sourceaddressprefix * -sourceportrange * -destinationaddressprefix * `     -destinationportrange 3389 -access allow  # create inbound network security group rule port 80 $nsgruleweb = new-azurermnetworksecurityruleconfig -name mynetworksecuritygrouprulewww  -protocol tcp `     -direction inbound -priority 1001 -sourceaddressprefix * -sourceportrange * -destinationaddressprefix * `     -destinationportrange 80 -access allow  # create network security group $nsg = new-azurermnetworksecuritygroup -resourcegroupname myresourcegroup -location $location `     -name mynetworksecuritygroup -securityrules $nsgrulerdp,$nsgruleweb  # create virtual network card , associate public ip address , nsg $nic = new-azurermnetworkinterface -name mynic -resourcegroupname myresourcegroup -location $location `     -subnetid $vnet.subnets[0].id -publicipaddressid $pip.id -networksecuritygroupid $nsg.id  # define credential object $cred = get-credential  # create 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 virtual machine new-azurermvm -resourcegroupname myresourcegroup -location $location -vm $vmconfig 

we can use script create azure windows vm unmanaged disk:

$location = "usgovtexas" $rgname = "myresourcegroup" new-azurermresourcegroup -name myresourcegroup -location $location  # create subnet configuration $subnetconfig = new-azurermvirtualnetworksubnetconfig -name mysubnet -addressprefix 192.168.1.0/24  # create virtual network $vnet = new-azurermvirtualnetwork -resourcegroupname myresourcegroup -location $location `     -name myvnet -addressprefix 192.168.0.0/16 -subnet $subnetconfig  # create public ip address , specify dns name $pip = new-azurermpublicipaddress -resourcegroupname myresourcegroup -location $location `     -allocationmethod static -idletimeoutinminutes 4 -name "mypublicdns$(get-random)"  # create inbound network security group rule port 3389 $nsgrulerdp = new-azurermnetworksecurityruleconfig -name mynetworksecuritygrouprulerdp  -protocol tcp `     -direction inbound -priority 1000 -sourceaddressprefix * -sourceportrange * -destinationaddressprefix * `     -destinationportrange 3389 -access allow  # create inbound network security group rule port 80 $nsgruleweb = new-azurermnetworksecurityruleconfig -name mynetworksecuritygrouprulewww  -protocol tcp `     -direction inbound -priority 1001 -sourceaddressprefix * -sourceportrange * -destinationaddressprefix * `     -destinationportrange 80 -access allow  # create network security group $nsg = new-azurermnetworksecuritygroup -resourcegroupname myresourcegroup -location $location `     -name mynetworksecuritygroup -securityrules $nsgrulerdp,$nsgruleweb  # create virtual network card , associate public ip address , nsg $nic = new-azurermnetworkinterface -name mynic -resourcegroupname myresourcegroup -location $location `     -subnetid $vnet.subnets[0].id -publicipaddressid $pip.id -networksecuritygroupid $nsg.id  # define credential object $cred = get-credential  #vm config $vmsize = "standard_ds2" $vmname="myvm"  $vm = new-azurermvmconfig -vmname $vmname -vmsize $vmsize $pubname = ”microsoftwindowsserver” $offername = ”windowsserver” $skuname = ”2016-datacenter” $vm = set-azurermvmoperatingsystem -vm $vm -windows -computername $vmname -credential $cred $vm = set-azurermvmsourceimage -vm $vm -publishername $pubname -offer $offername -skus $skuname -version "latest"  $vm = add-azurermvmnetworkinterface -vm $vm -id $nic.id   # create new storage account new-azurermstorageaccount -resourcegroupname "myresourcegroup" -accountname "mystorageaccount" -location $location -skuname "standard_lrs"  # disk setup $diskname = ”jason-disk” $storageaccount = "jasontest321" $sta = get-azurermstorageaccount -resourcegroupname $rgname -name $storageaccount $osdiskuri = $sta.primaryendpoints.blob.tostring() + "vhds/" + $diskname? + ".vhd" $vm = set-azurermvmosdisk -vm $vm -name $diskname -vhduri $osdiskuri -createoption fromimage   # create virtual machine new-azurermvm -resourcegroupname myresourcegroup -location $location -vm $vm 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -