Skip to content
Open Source Blog

AzureR, a family of packages that provides tools to manage Azure resources from the open source R language, is now available.

If you code in Python, C#, Java or JavaScript, you already have a rich selection of SDKs to choose from to interact with Azure. AzureR extends SDK support to the R language, by providing a selection of lightweight yet powerful packages to fill basic infrastructure needs for Azure users.

Diagram of Azure Services that AzureR supports

The AzureR family includes eight packages that extend the R language with tools to create, manage, and monitor Azure resources and services. The packages depend only on R and other open source components of the R ecosystem (such as the R packages “httr”, “jsonlite” and “R6”); there is no requirement to install the Azure CLI, Python or PowerShell. All of the packages are available on the official R package repository CRAN are openly developed on GitHub within the Azure organization and are mirrored as part of the cloudyr project.

The AzureR packages allow R users to interact with Azure services including:

  • Azure Active Directory: the AzureAuth package provides authentication functionality. Use this package to obtain OAuth 2.0 tokens for any Azure service that uses Azure Active Directory (AAD) for authentication. It supports AAD v1.0 and v2.0; authenticating with certificates; and multiple authentication flows, including authorization code, device code, client credentials, on-behalf-of, and resource owner grant.
  • Azure Resource Manager: the AzureRMR package provides an interface to Azure subscriptions, resource groups, resources and templates. Resources can be created, updated and deleted, templates can be deployed and removed, and role-based permissions assigned.
  • Microsoft Graph: the AzureGraph package provides an interface to data in Microsoft Graph, a comprehensive framework for accessing data in various Microsoft online services including Office 365, Windows and Azure Active Directory. Its main functionality revolves around registered apps and service principals in AAD, with a view to supporting the other packages in the family, but it can also be used to manage other objects in Graph.
  • Azure Key Vault: the AzureKeyVault package provides a Resource Manager and client interface to secrets stored in Azure Key Vault. It supports all the standard operations with objects stored in Key Vault, such as encryption and decryption, certificate signing, and storage account key management.
  • Azure Storage: the AzureStor package provides a Resource Manager and client interface to storage accounts. The client interface supports blob, file and Data Lake Gen2 storage. Features include parallel file transfers, retry on error, and an interface to the AzCopy v10
  • Containers: the AzureContainers package provides a Resource Manager and client interface to Azure Container Instances, Azure Container Registry, and Azure Kubernetes Service. Build a Docker image and push it to ACR, deploy it to ACI, or create a service on AKS. As a bonus, AzureContainers can talk to any Docker registry or Kubernetes cluster, not just those in Azure.
  • Virtual machines: AzureVM is a package for deploying and interacting with virtual machines. It provides a flexible, powerful interface that lets you customize nearly all aspects of the deployment, including reusing existing resources and support for managing clusters of VMs via virtual machine scalesets. A selection of predefined configurations is also provided to allow easy deployment of commonly used Linux and Windows images including the Data Science Virtual Machine which includes R, Python and other data science tools.
  • Azure Data Explorer: the AzureKusto package provides a Resource Manager and client interface to Azure Data Explorer (also known as Kusto), a fast, fully managed data analytics service for real-time analysis on large volumes of data streaming from applications, websites, IoT devices, and more. The package provides interfaces to Kusto via the R “dplyr” and “DBI” packages, as well as the ability to manage clusters and database principals.

Here is an example to illustrate how these packages can be used together. We create a resource group and storage account in AzureRMR, and a registered app in AzureGraph. We then assign the necessary permissions for the app to access the storage account. On the client side, we then use AzureStor and AzureAuth to upload a file to the storage account, authenticating via the app.

library(AzureRMR)
library(AzureGraph)
library(AzureStor)

# set your Azure organization and subscription details here
tenant <- "mytenant"
sub_id <- "12345678-aaaa-bbbb-cccc-0123456789ab"

# create a Graph client
gr <- AzureGraph::create_graph_login(tenant)

# create an app (associated service principal will also 
# be created automatically)
app <- gr$create_app("AzureRapp")

# create a Resource Manager client
az <- AzureRMR::create_azure_login(tenant)

# create the resource group and storage account
rg <- az$
    get_subscription(sub_id)$
    create_resource_group("AzureRsample", location="westus")

# create a storage account -- StorageV2, Standard_LRS
stor <- rg$create_storage_account("azurerstor")

# give blob contributor rights to the app
stor$add_role_assignment(app, "Storage blob data contributor")

## client side:

# authenticate with the app
token <- AzureAuth::get_azure_token(
    resource="https://storage.azure.com",
    tenant=tenant,
    app=app$properties$appId,
    password=app$password
)

# blob endpoint object
stor_client <- storage_endpoint("https://azurerstor.blob.core.windows.net", token=token)

# create a blob container --
# authentication details passed down from endpoint
stor_container <- create_storage_container(stor_client, "mycontainer")

# upload a file
storage_upload(stor_container, "/path/to/mybigfile.txt", "mybigfile.txt")

Together, the AzureR packages provide the capability to efficiently and securely access the Azure services that are most likely to be relevant to R users. R users can install the R packages from the CRAN package repository today, and get started using their existing Azure subscription. New subscribers can also create a free Azure account with access to Azure’s free services and $200 in Azure credits towards everything else.

For more information about AzureR, please visit the AzureR repository in GitHub, where comments and suggestions (and pull requests!) are always welcome.

Questions or feedback? Let us know in the comments below.

 

Join the conversation

Leave a Reply

Your email address will not be published. Required fields are marked *

I understand by submitting this form Microsoft is collecting my name, email and comment as a means to track comments on this website. This information will also be processed by an outside service for Spam protection. For more information, please review our Privacy Policy and Terms of Use.

Loading comments...