Description Format Details Fields Methods Instance operations See Also Examples
Class representing a virtual machine scaleset deployment template. This class keeps track of all resources that are created as part of deploying a scaleset, and exposes methods for managing them.
An R6 object of class az_vmss_template
, inheriting from AzureRMR::az_template
.
A virtual machine scaleset in Azure is actually a collection of resources, including any and all of the following.
Network security group (Azure resource type Microsoft.Network/networkSecurityGroups
)
Virtual network (Azure resource type Microsoft.Network/virtualNetworks
)
Load balancer (Azure resource type Microsoft.Network/loadBalancers
)
Public IP address (Azure resource type Microsoft.Network/publicIPAddresses
)
Autoscaler (Azure resource type Microsoft.Insights/autoscaleSettings
)
The scaleset itself (Azure resource type Microsoft.Compute/virtualMachineScaleSets
)
By wrapping the deployment template used to create these resources, the az_vmss_template
class allows managing them all as a single entity.
The following fields are exposed, in addition to those provided by the AzureRMR::az_template class.
dns_name
: The DNS name for the scaleset (technically, the name for its load balancer). Will be NULL if the scaleset is not publicly visible, or doesn't have a load balancer attached.
identity
: The managed identity details for the scaleset. Will be NULL if the scaleset doesn't have an identity assigned.
The following methods are available, in addition to those provided by the AzureRMR::az_template class.
sync_vmss_status
: Check the status of the scaleset.
list_instances()
: Return a list of az_vm_resource objects, one for each VM instance in the scaleset. Note that if the scaleset has an autoscaler attached, the number of instances will vary depending on the load.
get_instance(id)
: Return a specific VM instance in the scaleset.
start(id=NULL, wait=FALSE)
: Start the scaleset. In this and the other methods listed here, id
can be an optional character vector of instance IDs; if supplied, only carry out the operation for those instances.
restart(id=NULL, wait=FALSE)
: Restart the scaleset.
stop(deallocate=TRUE, id=NULL, wait=FALSE)
: Stop the scaleset.
get_public_ip_address()
: Get the public IP address of the scaleset (technically, of the load balancer). If the scaleset doesn't have a load balancer attached, returns NA.
get_vm_public_ip_addresses(id=NULL, nic=1, config=1)
: Get the public IP addresses for the instances in the scaleset. Returns NA for the instances that are stopped or not publicly accessible.
get_vm_private_ip_addresses(id=NULL, nic=1, config=1)
: Get the private IP addresses for the instances in the scaleset.
get_public_ip_resource()
: Get the Azure resource for the load balancer's public IP address.
get_vnet(nic=1, config=1)
: Get the scaleset's virtual network resource.
get_nsg(nic=1, config=1)
: Get the scaleset's network security group resource.
get_load_balancer()
: Get the scaleset's load balancer resource.
get_autoscaler()
: Get the scaleset's autoscaler resource.
run_deployed_command(command, parameters=NULL, script=NULL, id=NULL)
: Run a PowerShell command on the instances in the scaleset.
run_script(script, parameters=NULL, id=NULL)
: Run a script on the VM. For a Linux VM, this will be a shell script; for a Windows VM, a PowerShell script. Pass the script as a character vector.
reimage(id=NULL, datadisks=FALSE)
: Reimage the instances in the scaleset. If datadisks
is TRUE, reimage any attached data disks as well.
redeploy(id=NULL)
: Redeploy the instances in the scaleset.
mapped_vm_operation(..., id=NULL)
: Carry out an arbitrary operation on the instances in the scaleset. See the do_operation
method of the AzureRMR::az_resource class for more details.
add_extension(publisher, type, version, settings=list(), protected_settings=list(), key_vault_settings=list())
: Add an extension to the scaleset.
do_vmss_operation(...)
Carry out an arbitrary operation on the scaleset resource (as opposed to the instances in the scaleset).
Many of these methods are actually provided by the az_vmss_resource class, and propagated to the template as active bindings.
AzureVM has the ability to parallelise scaleset instance operations using a background process pool provided by AzureRMR. This can lead to significant speedups when working with scalesets with high instance counts. The pool is created automatically the first time that it is required, and remains persistent for the session. You can control the size of the process pool with the azure_vm_minpoolsize
and azure_vm_maxpoolsize
options, which have default values 2 and 10 respectively.
The id
argument lets you specify a subset of instances on which to carry out an operation. This can be a character vector of instance IDs; a list of instance objects such as returned by list_instances
; or a single instance object. The default (NULL) is to carry out the operation on all instances.
AzureRMR::az_template, create_vm_scaleset, get_vm_scaleset, delete_vm_scaleset, AzureRMR::init_pool
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
sub <- AzureRMR::get_azure_login()$
get_subscription("subscription_id")
vmss <- sub$get_vm_scaleset("myscaleset")
vmss$identity
vmss$get_public_ip_address() # NA if the scaleset doesn't have a load balancer
vmss$start()
vmss$get_vm_private_ip_addresses()
vmss$get_vm_public_ip_addresses() # NA if scaleset nodes are not publicly visible
instances <- vmss$list_instances()
first <- instances[1]
vmss$run_script("echo hello world! > /tmp/hello.txt", id=first)
vmss$stop(id=first)
vmss$reimage(id=first)
vmss$sync_vmss_status()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.