Статьи

Использование хранилища виртуальных машин Azure

 

Вчера Microsoft Open Technologies анонсировала дополнительный сервис для виртуальных машин Windows Azure — хранилище виртуальных машин . Депо — это управляемый сообществом каталог образов ВМ с открытым исходным кодом. Это позволяет создавать виртуальные машины и совместно использовать их с пользовательскими конфигурациями или установленными стеками программного обеспечения.

Даг Махью также опубликовал статью о том, как начать пользоваться сервисом.

Я провел некоторое время, работая с депо прошлой ночью, и вот что я узнал.

Требования

Вы можете догадаться, что вам понадобится подписка на Windows Azure, но есть еще несколько вещей, которые вам нужно сделать.

  1. Убедитесь, что функция предварительного просмотра виртуальной машины включена для вашей службы. Вы можете сделать это, войдя в свою подписку и перейдя по адресу https://account.windowsazure.com/PreviewFeatures . Оказавшись здесь, зарегистрируйтесь для опции Виртуальные машины и виртуальные сети, если она еще не активна.

  2. Убедитесь, что у вас установлена ​​последняя версия инструментов командной строки Windows Azure, поскольку депо создает сценарий развертывания, в котором используется новый параметр (-o). Вы можете обновить инструменты командной строки, выполнив одно из следующих действий:

    • Используйте команду npm install azure-cli -g для установки последних битов командной строки Azure.

    ИЛИ ЖЕ

  3. You’ll also need to import your account settings if you haven’t already. You can find the steps for this in the How to download and import publish settings section of this article.

Using a community image

If you want to create a new VM using a community image, the process is pretty simple:

  1. Open http://vmdepot.msopentech.com/List/Index in your browser.

  2. Find an image you want from the list. You can either scroll through the list or use the search bar at the top. The following image illustrates using the search field to find a VM that has Riak.

  3. At this point you can either click the Deployment Script link to the far right of the VM entry you want to use or the Deployment Script icon at the top to retrieve a deployment script. You’ll need to agree to the terms of use and select a region, and then you’ll be given a command similar to the following:

    azure vm create DNS_PREFIX -o vmdepot-66-2-2 -l "East US" USER_NAME [PASSWORD] [--ssh] [other_options] 
  4. You will need to replace the fields such as USER_NAME with actual values. Here’s what each should go in each of these fields:

    • DNS_PREFIX should be replaced with whatever you want this machine to be called. I’m going to use myawesomevm.

    • USER_NAME should be replaced with the user name you want to login to the machine as.

    • [PASSWORD] should be the password you want to use for this user (don’t include the [] characters around the password).

    • [—ssh] should be changed to just —ssh if you want to enable SSH (and you probably do, otherwise how are you connecting to the machine?)

    • [other_options] should be replaced with any other options available for the azure vm create command. For example, —vm-size small.

    A final command line should look something like:

azure vm create larryriak -o vmdepot-66-2-2 -l "East US" larry secretpassword --ssh 
  1. Run this command from a command-line. It will copy the disk image from the VM Depot to storage in your subscription, and then provision a VM that uses this disk image.

  2. At this point, the new VM should show up in the Windows Azure portal.

    After the VM status changes to running, you should be able to use SSH to connect to the VM and use it as you normally would.

Publishing a VM

Doug Mahugh’s article provides information on publishing an image to the VM Depot. I didn’t go through the entire process of publishing a VM because I didn’t want to clutter up the VM Depot with «Larry’s great generic Linux VM for testing purposes». The steps seem relatively straight forward though.

Create a custom VM and publish a VHD to the VM Deopot

  1. Create a VM. You can find a walk through of this process in the Create a virtual machine running Linux tutorial.

  2. Once it’s been created, SSH to the VM and install things people might find useful.

  3. Capture an image of the VM to a VHD. You can find these steps in the How to capture an image of a virtual machine running Linux article.

  4. Set the storage container that contains the .VHD to public. You can do this in the Windows Azure Portal by:

    1. Selecting the storage account.

    2. Selecting Containers.

    3. Selecting the container (vhds in this case) and clicking edit container. You’ll get a dialog similar to the following:

    4. Select Public Container for the access level of this container, and then click the checkbox.

Publishing the VHD to the VM Depot

You’ll need to create an account on the VM Depot for this step. It allows you to use a Windows LiveID, Google ID, or Yahoo! ID. To create an account, just click on the Sign In link in the upper right to set this up.

After you’ve created an account and signed in, perform the following steps to share your VM with the community:

  1. Click the Publish icon at the top of the page.

  2. Enter information about the VM image: name, description, what packages are installed, legal terms, etc.

  3. The URL of the VHD to publish is the full URL to the VHD in your public container. You can get this by performing the following steps:

    1. Go to the Windows Azure Portal.

    2. Go to the storage account that contains this VHD.

    3. Select Containers, and then select the container.

    4. A list of the objects in the container, along with the full URL to each item, will be displayed. Just note the URL and use it in the URL of the VHD to publish field in the VM Depot.

  4. Once you’ve specified the VHD path and filled out all the information, agree to the terms and click the publish button.

Final Thoughts

The VM Depot is a great addition to the Windows Azure VM story. Previously you had to select a raw OS image and manually install your software stack on it. With the Depot, you can now pick an image that already has the stack you need, as well as share your custom stack with the community. And since it’s based on the Windows Azure command-line tools, it allows you to create the command-line once in the portal and then use it in your automation scripts, or hand it out to co-workers who need to create their own VMs.

There’s already a lot of VMs in the Depot for both specific OS releases (Debian Wheezy and Mageia) and specific software and software stacks (LAMP, Ruby, JRuby, WordPress, Joomla, Drupal). It will be interesting to see what new VMs show up now that this is open to the community.

Any thoughts on specific OS or software stacks that you’d like to see in the VM Depot?