| AzureCLICredential | R Documentation |
Authenticates using the Azure CLI (az) command-line tool. This credential
requires the Azure CLI to be installed and the user to be logged in via
az login.
The credential uses the az account get-access-token command to retrieve
access tokens. It will use the currently active Azure CLI account and
subscription unless a specific tenant is specified.
azr::Credential -> azr::InteractiveCredential -> AzureCLICredential
.process_timeoutTimeout in seconds for Azure CLI command execution
new()Create a new Azure CLI credential
AzureCLICredential$new( scope = NULL, tenant_id = NULL, process_timeout = NULL, interactive = FALSE, use_bridge = FALSE )
scopeA character string specifying the OAuth2 scope. Defaults to
NULL, which uses the scope set during initialization.
tenant_idA character string specifying the Azure Active Directory
tenant ID. Defaults to NULL, which uses the default tenant from Azure CLI.
process_timeoutA numeric value specifying the timeout in seconds
for the Azure CLI process. Defaults to 10.
interactiveA logical value indicating whether to check if the user is
logged in and perform login if needed. Defaults to FALSE.
use_bridgeA logical value indicating whether to use the device code
bridge webpage during login. If TRUE, launches an intermediate local webpage
that displays the device code and facilitates copy-pasting before redirecting
to the Microsoft device login page. Only used when interactive = TRUE. Defaults to FALSE.
A new AzureCLICredential object
get_token()Get an access token from Azure CLI
AzureCLICredential$get_token(scope = NULL)
scopeA character string specifying the OAuth2 scope. If NULL,
uses the scope specified during initialization.
An httr2::oauth_token() object containing the access token
req_auth()Add authentication to an httr2 request
AzureCLICredential$req_auth(req, scope = NULL)
reqAn httr2::request() object
scopeA character string specifying the OAuth2 scope. If NULL,
uses the scope specified during initialization.
The request object with authentication header added
account_show()Show the currently active Azure CLI account information
AzureCLICredential$account_show(timeout = NULL)
timeoutA numeric value specifying the timeout in seconds for the
Azure CLI command. If NULL, uses the process timeout specified during
initialization.
A list containing the account information from Azure CLI
login()Perform Azure CLI login using device code flow
AzureCLICredential$login()
Invisibly returns the exit status (0 for success, non-zero for failure)
logout()Log out from Azure CLI
AzureCLICredential$logout()
Invisibly returns NULL
clone()The objects of this class are cloneable with this method.
AzureCLICredential$clone(deep = FALSE)
deepWhether to make a deep clone.
# Create credential with default settings
cred <- AzureCLICredential$new()
# Create credential with specific scope and tenant
cred <- AzureCLICredential$new(
scope = "https://management.azure.com/.default",
tenant_id = "your-tenant-id"
)
# To get a token or authenticate a request it is required that
# 'az login' is successfully executed, otherwise it will return an error.
## Not run:
# Get an access token
token <- cred$get_token()
# Use with httr2 request
req <- httr2::request("https://management.azure.com/subscriptions")
resp <- httr2::req_perform(cred$req_auth(req))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.