Learn R Programming

AzureRMR (version 2.1.0)

az_rm: Azure Resource Manager

Description

Base class for interacting with Azure Resource Manager.

Usage

az_rm

Arguments

Format

An R6 object of class az_rm.

Methods

  • new(tenant, app, ...): Initialize a new ARM connection with the given credentials. See 'Authentication` for more details.

  • list_subscriptions(): Returns a list of objects, one for each subscription associated with this app ID.

  • get_subscription(id): Returns an object representing a subscription.

  • get_subscription_by_name(name): Returns the subscription with the given name (as opposed to a GUID).

Authentication

The recommended way to authenticate with ARM is via the get_azure_login function, which creates a new instance of this class.

To authenticate with the az_rm class directly, provide the following arguments to the new method:

  • tenant: Your tenant ID. This can be a name ("myaadtenant"), a fully qualified domain name ("myaadtenant.onmicrosoft.com" or "mycompanyname.com"), or a GUID.

  • app: The client/app ID to use to authenticate with Azure Active Directory. The default is to login interactively using the Azure CLI cross-platform app, but it's recommended to supply your own app credentials if possible.

  • password: if auth_type == "client_credentials", the app secret; if auth_type == "resource_owner", your account password.

  • username: if auth_type == "resource_owner", your username.

  • auth_type: The OAuth authentication method to use, one of "client_credentials", "authorization_code", "device_code" or "resource_owner". See get_azure_token for how the default method is chosen, along with some caveats.

  • host: your ARM host. Defaults to https://management.azure.com/. Change this if you are using a government or private cloud.

  • aad_host: Azure Active Directory host for authentication. Defaults to https://login.microsoftonline.com/. Change this if you are using a government or private cloud.

  • config_file: Optionally, a JSON file containing any of the arguments listed above. Arguments supplied in this file take priority over those supplied on the command line. You can also use the output from the Azure CLI az ad sp create-for-rbac command.

  • token: Optionally, an OAuth 2.0 token, of class AzureToken. This allows you to reuse the authentication details for an existing session. If supplied, all other arguments will be ignored.

See Also

create_azure_login, get_azure_login

Azure Resource Manager overview, REST API reference

Examples

Run this code
# NOT RUN {
# start a new Resource Manager session
az <- az_rm$new(tenant="myaadtenant.onmicrosoft.com", app="app_id", password="password")

# authenticate with credentials in a file
az <- az_rm$new(config_file="creds.json")

# authenticate with device code
az <- az_rm$new(tenant="myaadtenant.onmicrosoft.com", app="app_id", auth_type="device_code")

# retrieve a list of subscription objects
az$list_subscriptions()

# a specific subscription
az$get_subscription("subscription_id")

# }

Run the code above in your browser using DataLab