Skip to content

VirtualMachineService

Daniel Berger edited this page Dec 17, 2015 · 21 revisions

The VirtualMachineService class is likely to be used extensively, and it contains additional methods not inherited from ResourceBaseServiceClass, so we cover it in some detail here.

Getting Started

# Get your VirtualMachineService instance
vms = Azure::Armrest::VirtualMachineService.new(conf)

Common Methods

The VirtualMachineService class supports the common methods available to all ResourceBaseGroupService subclasses.

rg = 'some_resource_group'

vm = vms.get('some_vm', rg)
vms.list(rg).each{ |vm| p vm.name }
vms.list_all.each{ |vm| p vm.name }
vms.delete('some_vm', rg)

Additional Methods

# Returns a list of VirtualMachineSize objects that contain information
# about available VM sizes that can be provisioned.
series = vms.series.first

p series.name
p series.number_of_cores
p series.os_disk_size_in_mb

Instance View vs Model View

Unlike other resource types, there are two possible "views" for a virtual machine - instance view and model view. The difference is in the type of object and information they return. By default, the get method retrieves the model view since it includes information about the model that was submitted to Azure, and is similar to the output used for the create method. The instance view largely returns status information for the VM.

You have the option to pass a 3rd parameter to the get method, or to use an explicit method.

# Examples:

vms.get('some_vm', rg) # => Gets model view
vms.get_model_view('some_vm', rg) # => Same as above

vms.get('some_vm', rg, false) # => Gets instance view
vms.get_instance_view('some_vm', rg) # => Same as above