az_template: Azure template class

az_templateR Documentation

Azure template class


Class representing an Azure deployment template.


An R6 object of class az_template.


  • new(token, subscription, resource_group, name, ...): Initialize a new template object. See 'Initialization' for more details.

  • check(): Check the deployment status of the template; throw an error if the template has been deleted.

  • cancel(free_resources=FALSE): Cancel an in-progress deployment. Optionally free any resources that have already been created.

  • delete(confirm=TRUE, free_resources=FALSE): Delete a deployed template, after a confirmation check. Optionally free any resources that were created. If the template was deployed in Complete mode (its resource group is exclusive to its use), the latter process will delete the entire resource group. Otherwise resources are deleted in the order given by the template's output resources list; in this case, some may be left behind if the ordering is incompatible with dependencies.

  • list_resources(): Returns a list of Azure resource objects that were created by the template. This returns top-level resources only, not those that represent functionality provided by another resource.

  • get_tags(): Returns the tags for the deployment template (note: this is not the same as the tags applied to resources that are deployed).


Initializing a new object of this class can either retrieve an existing template, or deploy a new template on the host. Generally, the easiest way to create a template object is via the get_template, deploy_template or list_templates methods of the az_resource_group class, which handle the details automatically.

To initialize an object that refers to an existing deployment, supply the following arguments to new():

  • token: An OAuth 2.0 token, as generated by get_azure_token.

  • subscription: The subscription ID.

  • resource_group: The resource group.

  • name: The deployment name'.

If you also supply the following arguments to new(), a new template will be deployed:

  • template: The template to deploy. This can be provided in a number of ways:

    1. A nested list of R objects, which will be converted to JSON via jsonlite::toJSON

    2. A vector of strings containing unparsed JSON

    3. The name of a template file

    4. A URL from which the host can download the template

  • parameters: The parameters for the template. This can be provided using any of the same methods as the template argument.

  • wait: Optionally, whether to wait until the deployment is complete. Defaults to FALSE, in which case the method will return immediately.

You can use the build_template_definition and build_template_parameters helper functions to construct the inputs for deploying a template. These can take as inputs R lists, JSON text strings, or file connections, and can also be extended by other packages.

See Also

az_resource_group, az_resource, build_template_definition, build_template_parameters Template overview, Template API reference


## Not run: 

# recommended way to deploy a template: via a resource group object

tpl <- resgroup$deploy_template("mydeployment",

# retrieve list of created resource objects

# delete template (will not touch resources)

# delete template and free resources

## End(Not run)

AzureRMR documentation built on Sept. 21, 2023, 9:07 a.m.