vm_config: VM configuration functions

Description Usage Arguments Details Value See Also Examples

View source: R/vm_config.R

Description

VM configuration functions

Usage

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
centos_7.5(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

centos_7.6(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

centos_8.1(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

debian_8_backports(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

debian_9_backports(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

debian_10_backports(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

debian_10_backports_gen2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

ubuntu_dsvm(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh,
  nsg_rule_allow_jupyter, nsg_rule_allow_rstudio)), ...)

ubuntu_dsvm_gen2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh,
  nsg_rule_allow_jupyter, nsg_rule_allow_rstudio)), ...)

windows_dsvm(keylogin = FALSE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_rdp)), ...)

rhel_7.6(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

rhel_8(keylogin = TRUE, managed_identity = TRUE, datadisks = numeric(0),
  nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

rhel_8.1(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

rhel_8.1_gen2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

rhel_8.2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

rhel_8.2_gen2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

ubuntu_16.04(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

ubuntu_18.04(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

ubuntu_20.04(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

ubuntu_20.04_gen2(keylogin = TRUE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_ssh)), ...)

windows_2016(keylogin = FALSE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_rdp)), ...)

windows_2019(keylogin = FALSE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_rdp)), ...)

windows_2019_gen2(keylogin = FALSE, managed_identity = TRUE,
  datadisks = numeric(0), nsg = nsg_config(list(nsg_rule_allow_rdp)), ...)

vm_config(image, keylogin, managed_identity = TRUE,
  os_disk_type = c("Premium_LRS", "StandardSSD_LRS", "Standard_LRS"),
  datadisks = numeric(0), nsg = nsg_config(), ip = ip_config(),
  vnet = vnet_config(), nic = nic_config(), other_resources = list(),
  variables = list(), ...)

Arguments

keylogin

Whether to use an SSH public key to login (TRUE) or a password (FALSE). Note that Windows does not support SSH key logins.

managed_identity

Whether to provide a managed system identity for the VM.

datadisks

The data disks to attach to the VM. Specify this as either a vector of numeric disk sizes in GB, or a list of datadisk_config objects for more control over the specification.

nsg

The network security group for the VM. Can be a call to nsg_config to create a new NSG; an AzureRMR resource object or resource ID to reuse an existing NSG; or NULL to not use an NSG (not recommended).

...

For the specific VM configurations, other customisation arguments to be passed to vm_config. For vm_config, named arguments that will be folded into the VM resource definition in the template. In particular use properties=list(*) to set additional properties for the VM, beyond those set by the various configuration functions.

image

For vm_config, the VM image to deploy. This should be an object of class image_config, created by the function of the same name.

os_disk_type

The type of primary disk for the VM. Can be "Premium_LRS" (the default), "StandardSSD_LRS", or "Standard_LRS". Of these, "Standard_LRS" uses hard disks and the others use SSDs as the underlying hardware. Change this to "StandardSSD_LRS" or "Standard_LRS" if the VM size doesn't support premium storage.

ip

The public IP address for the VM. Can be a call to ip_config to create a new IP address; an AzureRMR resource object or resource ID to reuse an existing address resource; or NULL if the VM should not be accessible from outside its subnet.

vnet

The virtual network for the VM. Can be a call to vnet_config to create a new virtual network, or an AzureRMR resource object or resource ID to reuse an existing virtual network. Note that by default, AzureVM will associate the NSG with the virtual network/subnet, not with the VM's network interface.

nic

The network interface for the VM. Can be a call to nic_config to create a new interface, or an AzureRMR resource object or resource ID to reuse an existing interface.

other_resources

An optional list of other resources to include in the deployment.

variables

An optional named list of variables to add to the template.

Details

These functions are for specifying the details of a new virtual machine deployment: the VM image and related options, along with the Azure resources that the VM may need. These include the datadisks, network security group, public IP address (if the VM is to be accessible from outside its subnet), virtual network, and network interface. vm_config is the base configuration function, and the others call it to create VMs with specific operating systems and other image details.

The VM configurations with gen2 in the name are generation 2 VMs, which feature several technical improvements over the earlier generation 1. Consider using these for greater efficiency, however note that gen2 VMs are only available for select images and do not support all possible VM sizes.

Each resource can be specified in a number of ways:

A VM configuration defines the following template variables by default, depending on its resources. If a particular resource is created, the corresponding *Name, *Id and *Ref variables will be available. If a resource is referred to but not created, the *Name* and *Id variables will be available. Other variables can be defined via the variables argument.

Variable name Contents Description
location [resourceGroup().location] Region to deploy resources
vmId [resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))] VM resource ID
vmRef [concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))] VM template reference
nsgName [concat(parameters('vmName'), '-nsg')] Network security group resource name
nsgId [resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))] NSG resource ID
nsgRef [concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))] NSG template reference
ipName [concat(parameters('vmName'), '-ip')] Public IP address resource name
ipId [resourceId('Microsoft.Network/publicIPAddresses', variables('ipName'))] IP resource ID
ipRef [concat('Microsoft.Network/publicIPAddresses/', variables('ipName'))] IP template reference
vnetName [concat(parameters('vmName'), '-vnet')] Virtual network resource name
vnetId [resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))] Vnet resource ID
vnetRef [concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))] Vnet template reference
subnet subnet Subnet name. Only defined if a Vnet was created or supplied as an az_resource object.
subnetId [concat(variables('vnetId'), '/subnets/', variables('subnet'))] Subnet resource ID. Only defined if a Vnet was created or supplied as an az_resource object.
nicName [concat(parameters('vmName'), '-nic')] Network interface resource name
nicId [resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))] NIC resource ID
nicRef [concat('Microsoft.Network/networkInterfaces/', variables('nicName'))] NIC template reference

Thus, for example, if you are creating a VM named "myvm" along with all its associated resources, the NSG is named "myvm-nsg", the public IP address is "myvm-ip", the virtual network is "myvm-vnet", and the network interface is "myvm-nic".

Value

An object of S3 class vm_config, that can be used by the create_vm method.

See Also

image_config, user_config, datadisk_config for options relating to the VM resource itself

nsg_config, ip_config, vnet_config, nic_config for other resource configs

build_template for template builder methods

vmss_config for configuring a virtual machine scaleset

create_vm

Examples

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# basic Linux (Ubuntu) and Windows configs
ubuntu_18.04()
windows_2019()

# Windows DSVM with 500GB data disk, no public IP address
windows_dsvm(datadisks=500, ip=NULL)

# RHEL VM exposing ports 80 (HTTP) and 443 (HTTPS)
rhel_8(nsg=nsg_config(nsg_rule_allow_http, nsg_rule_allow_https))

# exposing no ports externally, spot (low) priority
rhel_8(nsg=nsg_config(list()), properties=list(priority="spot"))

# deploying an extra resource: storage account
ubuntu_18.04(
    variables=list(storName="[concat(parameters('vmName'), 'stor')]"),
    other_resources=list(
        list(
            type="Microsoft.Storage/storageAccounts",
            name="[variables('storName')]",
            apiVersion="2018-07-01",
            location="[variables('location')]",
            properties=list(supportsHttpsTrafficOnly=TRUE),
            sku=list(name="Standard_LRS"),
            kind="Storage"
        )
    )
)

## custom VM configuration: Windows 10 Pro 1903 with data disks
## this assumes you have a valid Win10 desktop license
user <- user_config("myname", password="Use-strong-passwords!")
image <- image_config(
     publisher="MicrosoftWindowsDesktop",
     offer="Windows-10",
     sku="19h1-pro"
)
datadisks <- list(
    datadisk_config(250, type="Premium_LRS"),
    datadisk_config(1000, type="Standard_LRS")
)
nsg <- nsg_config(
    list(nsg_rule_allow_rdp)
)
vm_config(
    image=image,
    keylogin=FALSE,
    datadisks=datadisks,
    nsg=nsg,
    properties=list(licenseType="Windows_Client")
)


## Not run: 

# reusing existing resources: placing multiple VMs in one vnet/subnet
rg <- AzureRMR::get_azure_login()$
    get_subscription("sub_id")$
    get_resource_group("rgname")

vnet <- rg$get_resource(type="Microsoft.Network/virtualNetworks", name="myvnet")

# by default, the NSG is associated with the subnet, so we don't need a new NSG either
vmconfig1 <- ubuntu_18.04(vnet=vnet, nsg=NULL)
vmconfig2 <- debian_9_backports(vnet=vnet, nsg=NULL)
vmconfig3 <- windows_2019(vnet=vnet, nsg=NULL)


## End(Not run)

AzureVM documentation built on Oct. 23, 2020, 5:20 p.m.