knitr::opts_chunk$set(echo = TRUE)

This file will provide a simple walkthrough of some of the functionality of the azrunr package. There will be fields within the code blocks that will require the users information.

Setup


You must have an Azure Account linked to a subscription to utilize this package, see link for more information.

To start, we will log in to Azure using the following code

library(azrunr)

# this will access an existing login or prompt you to create a new one
set_azure_login()

After a successful login, we can begin setting up the required parameters that perform various operations and streamline the process.

Various parameters are required to run processes and launch virtual machines within the package, these include: AZUREUSER - The username for the azure profile used AZURESUB - The Azure subscription ID AZURERG - An Azure resource group name AZURESSHKEY - The users ssh key AZURESTOR - A storage account name, this storage account should be located in the above azure resource group AZURECONTAINER - The name of a container within the storage account STORAGEACCESSKEY - The access key for the above storage account, can be found within the Azure Portal

These parameters can be set in a .Renviron file. They will be loaded as R is launched.

set_azure_options()

# If the .Renviron file is changed at any point, you will want to restart R and rerun the above function.

getOption("azurerg")

Now that our parameters are set, the remainder of the package is opened up for easy use

Launching a vm can be done with the use of a template and parameters.

NOTE: this function is not very flexible and is only guaranteed to work with the provided template and shellscript.

# the following will provision a vm and resources based on the parameters we have already set as well as a few more
# There are templateFile and shellScripts available within the /inst/VM_From_Template folder named azuredeploy.json and isntallrstudio_ubuntu20.sh
vmname = "testvm"
userpassword = "testpassword"

deploy <- vm_from_template(vmname, templateFile="/inst/VM_From_Template/azuredeploy.json",
                           shellScript="/inst/VM_From_Template/installrstudio_ubuntu20.sh",
                           userpassword, cpuSize="CPU-4GB",
                           ubuntuOSVersion="20_04-lts")
# This process may take around 10 minutes to complete.
# This function will print relevant information about the vm once it has been deployed
# Naming convention is unique to the resource group

All of these resources can be easily deleted using the delete_deployment_resources() function. All that is required to delete the resources is the vm name, and the resource group that is already set

vmname = "testvmwill3298-5ueymiwq5c6gi"
delete_deployment_resources(vmname)


billspat/bayesrun documentation built on March 20, 2021, 11:15 p.m.