Resource functions with Azure Resource Manager templates
By Liam Moat.
3 minutes read.
Azure Resource Manager (ARM) provides a collection of resource functions that can be used to reference your resource’s configuration and state in an ARM deployment template. In this blog post, I have collated some common use cases for these functions and provided some snippets for your reference.
If you think there are some missing add them in the comments below - I will also add more over time!
For quick reference, here’s a list of functions used by the snippets below:
listKeys - returns the values for any resource type that supports the list operation.
reference - returns an object representing a resource’s runtime state.
resourceGroup - returns an object that represents the current resource group.
resourceId - returns the unique identifier of a resource.
subscription - returns details about the subscription for the current deployment.
The reference function gives you access to a resource’s runtime state and implicitly declares that one resource depends on another.
To see the property names and values for a resource type, Microsoft recommends creating a template that returns the object in the outputs section1. I also find it useful to browse existing resources in the Azure Resource Explorer and reference the JSON in the “data” tab. While this isn’t a perfect representation of the return type, in my experience the data shown is often the same as that returned by reference.