AzureVM update: flexible and powerful deployment and management of VMs in Azure

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

by Hong Ooi, senior data scientist, Microsoft Azure

I'm happy to announce version 2.0 of AzureVM, a package for deploying and managing virtual machines in Azure. This is a complete rewrite of the package, with the objective of making it a truly generic and flexible tool for working with VMs and VM scale sets (clusters).

AzureVM 1.0 was a rather limited package in many respects: it came with only a small selection of DSVM templates, and didn't give you many options for changing them. While you could deploy any arbitrary template, this functionality was actually provided by the underlying AzureRMR package, rather than something that AzureVM added.

Here are the main changes in AzureVM 2.0:

  • Separate out deployment of VMs and VM clusters; the latter are implemented as scalesets, rather than simplistic arrays of individual VMs. The methods to work with scalesets are named get_vm_scaleset, create_vm_scaleset and delete_vm_scaleset; get/create/delete_vm_cluster are now defunct.
  • New UI for VM/scaleset creation, with many more ways to fine-tune the deployment options, including specifying the base VM image; networking details like security rules, load balancers and autoscaling; datadisks to attach; use of low-priority VMs for scalesets; etc.
  • Several predefined configurations supplied to allow quick deployment of commonly used images (Ubuntu, Windows Server, RHEL, Debian, Centos, DSVM).
  • Allow referring to existing resources in a deployment (eg placing VMs into an existing vnet), by supplying AzureRMR::az_resource objects as arguments.
  • Clear distinction between a VM deployment template and a resource. get_vm and get_vm_scaleset will always attempt to retrieve the template; to get the resource, use get_vm_resource and get_vm_scaleset_resource.
  • New VM resource methods: get_public_ip_address, get_private_ip_address.
  • New cluster/scaleset resource methods: get_public_ip_address (technically the address for the load balancer, if present), get_vm_public_ip_addresses, get_vm_private_ip_addresses, list_instances, get_instance.
  • Use a pool of background processes to talk to scalesets in parallel when carrying out instance operations. The pool size can be controlled with the global options azure_vm_minpoolsize and azure_vm_maxpoolsize.

See the README and/or the vignette for more information.

Here are some example deployments. A basic Ubuntu VM:


sub <- AzureRMR::get_azure_login()$

# default is an Ubuntu 18.04 VM, size Standard_DS3_v2, login via SSH key
# call sub$list_vm_sizes() to get the sizes available in your region
sub$create_vm(“myubuntuvm”, user_config(“myname”, “~/.ssh/”),

A more complex deployment (Windows 10 Pro):

## this assumes you have a valid Win10 desktop license
user <- user_config(“myname”, password=“Use-strong-passwords!”)
image <- image_config(
datadisks <- list(
    datadisk_config(250, type=“Premium_LRS”),
    datadisk_config(1000, type=“Standard_LRS”)
nsg <- nsg_config(
sub$create_vm(“mywin10vm”, user,

Creating a scaleset:

sub$create_vm_scaleset(“myubuntuss”, user_config(“myname”, “~/.ssh/”), instances=5,


Sharing a subnet between a VM and a scaleset:

# first, create the resgroup
rg <- sub$create_resource_group(“rgname”, “australiaeast”)

# create the master
rg$create_vm(“mastervm”, user_config(“myname”, “~/.ssh/”))

# get the vnet resource
vnet <- rg$get_resource(type=“Microsoft.Network/virtualNetworks”, name=“mastervm-vnet”)

# create the scaleset
# since the NSG is associated with the vnet, we don't need to create a new NSG either
rg$create_vm_scaleset(“slavess”, user_config(“myname”, “~/.ssh/”),
                      instances=5, vnet=vnet, nsg=NULL)

AzureVM 2.0 is available on CRAN now. If you have any questions, or if you run into problems, please feel free to email me or file an issue at the Github repo.

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)