Learn R Programming

AzureRMR (version 1.0.0)

az_subscription: Azure subscription class

Description

Class representing an Azure subscription.

Usage

az_subscription

Arguments

Format

An R6 object of class az_subscription.

Methods

  • new(token, id, ...): Initialize a subscription object.

  • list_resource_groups(): Return a list of resource group objects for this subscription.

  • get_resource_group(name): Return an object representing an existing resource group.

  • create_resource_group(name, location): Create a new resource group in the specified region/location, and return an object representing it.

  • delete_resource_group(name, confirm=TRUE): Delete a resource group, after asking for confirmation.

  • resource_group_exists(name): Check if a resource group exists.

  • list_resources(): List all resources deployed under this subscription.

  • list_locations(): List locations available.

  • get_provider_api_version(provider, type): Get the current API version for the given resource provider and type. If no resource type is supplied, returns a vector of API versions, one for each resource type for the given provider. If neither provider nor type is supplied, returns the API versions for all resources and providers.

Details

Generally, the easiest way to create a subscription object is via the get_subscription or list_subscriptions methods of the az_rm class. To create a subscription object in isolation, call the new() method and supply an Oauth 2.0 token of class AzureToken, along with the ID of the subscription.

See Also

Azure Resource Manager overview

Examples

Run this code
# NOT RUN {
# recommended way to retrieve a subscription object
sub <- az_rm$
    new(tenant="myaadtenant.onmicrosoft.com", app="app_id", password="password")$
    get_subscription("subscription_id")

# retrieve list of resource group objects under this subscription
sub$list_resource_groups()

# get a resource group
sub$get_resource_group("rgname")

# check if a resource group exists, and if not, create it
rg_exists <- sub$resource_group_exists("rgname")
if(!rg_exists)
    sub$create_resource_group("rgname", location="australiaeast")

# delete a resource group
sub$delete_resource_group("rgname")

# get provider API versions for some resource types
sub$get_provider_api_version("Microsoft.Compute", "virtualMachines")
sub$get_provider_api_version("Microsoft.Storage", "storageAccounts")

# }

Run the code above in your browser using DataLab