Interface to 'Azure Resource Manager'

A lightweight but powerful R interface to the 'Azure Resource Manager' REST API. The package exposes classes and methods for 'OAuth' authentication and working with subscriptions and resource groups. It also provides functionality for creating and deleting 'Azure' resources and deploying templates. While 'AzureRMR' can be used to manage any 'Azure' service, it can also be extended by other packages to provide extra functionality for specific services.


AzureRMR is a package for interacting with Azure Resource Manager: authenticate, list subscriptions, manage resource groups, deploy and delete templates and resources. It calls the Resource Manager REST API directly, so you don't need to have PowerShell or Python installed.

You can install the development version from GitHub, via devtools::install_github("cloudyr/AzureRMR").

Before you begin

To use AzureRMR, you must create and register a service principal with Azure Active Directory. This is a one-time task, and the easiest method is to use the Azure cloud shell.

  • In the Azure Portal (https://portal.azure.com/), click on the Cloud Shell icon:

  • If you haven't used the shell before, there will be a dialog box to choose whether to use bash or PowerShell. Choose bash.
  • In the shell, type az ad sp create-for-rbac --name {app-name} --subscription "{your-subscription-name}" --years {N}, substituting the desired name of your service principal (try to make it memorable to you, and unlikely to clash with other names), your subscription name, and the number of years you want the password to be valid.
  • Wait until the app creation is complete. You should see a screen like this.

  • Record your tenant ID, app ID, and password.

If you want to allow access at something other than subscription level, you can use the --scopes argument in place of --subscription. For example, to restrict AzureRMR to only the "AnalyticsRG" resource group: az ad sp create-for-rbac --scopes /subscriptions/{your-subscription-ID}/resourceGroups/AnalyticsRG.

Sample workflow

library(AzureRMR)
 
az <- az_rm$new(tenant="{tenant_id}", app="{app_id}", password="{password}")
 
# get a subscription and resource group
sub <- az$get_subscription("{subscription_id}")
rg <- sub$get_resource_group("rgname")
 
# get a resource (storage account)
stor <- rg$get_resource(type="Microsoft.Storage/storageAccounts", name="mystorage")
 
# method chaining works too
stor <- az$
    get_subscription("{subscription_id}")$
    get_resource_group("rgname")$
    get_resource(type="Microsoft.Storage/storageAccounts", name="mystorage")
 
 
# create a new resource group and resource
rg2 <- sub$create_resource_group("newrgname", location="westus")
 
stor2 <- rg2$create_resource(type="Microsoft.Storage/storageAccounts", name="mystorage2",
    kind="Storage", sku=list(name="Standard_LRS"))
 
# delete them
stor2$delete(confirm=FALSE)
rg2$delete(confirm=FALSE)

Extending

AzureRMR is meant to be a generic mechanism for working with Resource Manager. You can extend it to provide support for service-specific features; examples of packages that do this include AzureVM for virtual machines, and AzureStor for storage accounts. For more information, see the "Extending AzureRMR" vignette.


cloudyr project logo

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("AzureRMR")

1.0.0 by Hong Ooi, 3 months ago


https://github.com/cloudyr/AzureRMR


Report a bug at https://github.com/cloudyr/AzureRMR/issues


Browse source code at https://github.com/cran/AzureRMR


Authors: Hong Ooi [aut, cre] , Microsoft [cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports utils, httr, jsonlite, R6

Suggests knitr, testthat


Imported by AzureContainers, AzureStor, AzureVM, SAR.


See at CRAN