R package for interacting with Azure Resource Manager
Перейти к файлу
hong-revo aa32d3e85a fixes for new token class 2019-02-10 01:26:31 +11:00
R fixes for new token class 2019-02-10 01:26:31 +11:00
inst better md location 2018-10-25 01:47:40 +08:00
man auth details now in AzureAuth 2019-02-08 08:52:17 +11:00
tests rm token tests 2019-02-06 22:50:28 +11:00
vignettes revising vignettes, docs 2019-01-30 19:19:46 +11:00
.Rbuildignore update rbuildignore 2018-11-14 09:18:35 -08:00
.gitattributes R files 2018-04-30 21:09:03 +10:00
.gitignore require confirmation before delete 2018-05-08 12:40:22 +10:00
.travis.yml rm failing drat 2018-11-10 14:00:49 +11:00
AzureRMR.Rproj change repo name 2018-05-09 12:54:40 +10:00
AzureRMR.rxproj change repo name 2018-05-09 12:54:40 +10:00
AzureRMR.sln add sln file 2018-05-09 12:55:07 +10:00
CONTRIBUTING.md add citation, contrib docs 2018-10-19 07:23:53 +11:00
DESCRIPTION rewording 2019-02-07 01:48:59 +11:00
LICENSE move license to license.md for cran 2018-11-14 09:07:24 -08:00
LICENSE.md move license to license.md for cran 2018-11-14 09:07:24 -08:00
NAMESPACE rm token printing code 2019-02-07 20:46:29 +11:00
NEWS.md rewording 2019-02-07 01:48:59 +11:00
README.md doc iterating 2019-02-07 02:25:25 +11:00

README.md

AzureRMR

CRAN Downloads Travis Build Status

AzureRMR is a package for interacting with Azure Resource Manager: 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. Azure Active Directory OAuth tokens are obtained using the AzureAuth package.

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

Authentication

Under the hood, AzureRMR uses a similar authentication process to the Azure CLI. The first time you authenticate with a given Azure Active Directory tenant, you call create_azure_login() and supply your credentials. AzureRMR will prompt you for permission to create a special data directory in which to cache the obtained authentication token and Resource Manager login. Once this information is saved on your machine, it can be retrieved in subsequent R sessions with get_azure_login(). Your credentials will be automatically refreshed so you don't have to reauthenticate.

Unless you have a specific reason otherwise, it's recommended that you allow AzureRMR to create this caching directory. Note that many other cloud engineering tools save credentials in this way, including the Azure CLI itself.

By default, AzureRMR will authenticate using the Azure CLI cross-platform app. However, AzureRMR can also use a custom service principal, and in general it's a good idea to create your own service principal to authenticate with (if possible). See the "Introduction to AzureRMR" vignette for more details.

Sample workflow

library(AzureRMR)

# authenticate with Azure AD:
# - on first login to this client, call create_azure_login()
# - on subsequent logins, call get_azure_login()
az <- create_azure_login("myaadtenant")

# 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.

Acknowledgements

AzureRMR is inspired by the package AzureSMR, originally written by Alan Weaver and Andrie de Vries, and would not have been possible without their pioneering work. Thanks, guys!


cloudyr project logo