Create a VM from an unmanaged custom image

Source: Internet
Author: User

Create a VM from an unmanaged custom image

There are many documents on the official website that show you how to create a custom image. I have been using azure for more than two years and many machines are not hosted disks, therefore, to help customers test and use a VM created from an unmanaged custom image, the entire script is simple. You only need to change one parameter. However, this is not directly described in the document, at that time, it took time to test the VM. Therefore, you can directly share the success script with everyone. You only need to modify the imageurl to create a custom unhosted disk VM in batches. The created hosted disk will be shared with you later.

    1. The script is as follows:

$ Rgname = "myresourcegroup"

$ Subnetname = "mysubnet"

$ Singlesubnet = new-azurermvirtualnetworksubnetconfig-name $ subnetname-addressprefix 10.0.0.0/24

$ Location = "China North"

$ Vnetname = "myvnetname"

$ Vnet = new-azurermvirtualnetwork-name $ vnetname-resourcegroupname $ rgname-location $ location'

-Addressprefix 10.0.0.0/16-subnet $ singlesubnet

$ Ipname = "myip"

$ Pip = new-azurermpublicipaddress-name $ ipname-resourcegroupname $ rgname-location $ location'

-Allocationmethod dynamic

$ Nicname = "mynicname"

$ Nic = new-azurermnetworkinterface-name $ nicname-resourcegroupname $ rgname'

-Location $ location-subnetid $ vnet. subnets [0]. ID-publicipaddressid $ Pip. ID

$ Nsgname = "mynsg"

 

$ Rdprule = new-azurermnetworksecurityruleconfig-name myrdprule-description "allow RDP "'

-Access allow-protocol TCP-direction inbound-priority 110'

-Sourceaddressprefix Internet-sourceportrange *'

-Destinationaddressprefix *-destinationportrange 3389

$ NSG = new-azurermnetworksecuritygroup-resourcegroupname $ rgname-location $ location'

-Name $ nsgname-securityrules $ rdprule

$ Vmname = "myvm"

$ Vmconfig = new-azurermvmconfig-vmname $ vmname-vmsize "standard_a2"

$ Vm = add-azurermvmnetworkinterface-VM $ vmconfig-Id $ Nic. ID

$ Osdiskuri ="Https://xxxxxxxxxxxx.vhd", change to your own vhd URL

$ Osdiskname = $ vmname + "osdisk"

$ Vm = set-azurermvmosdisk-VM $ VM-name $ osdiskname-vhduri $ osdiskuri-createoption attach-Linux

 

You can create it through powershell. The last three lines are the focus, especially attach-linux. If it is Windows, it is attach-Windows.

Create a VM from an unmanaged custom image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.