Understanding Core Elements of ARM Templates

Now that we know the basic outline and structure of an ARM template, and we also know how to declare and use variables and parameters, it's time to move to other important aspects of ARM templates. In this chapter, we will look into some of the most important concepts related to ARM templates. ARM templates provide a foundation for the way environments and resources are provisioned on Azure, while the resources object is the place where all resources are declared, defined, and configured. In this chapter, we will look at the resources object, along with the outputs object, which is the way to return or generate outputs from ARM templates. Outputs play a significant role in providing feedback to the ARM template deployed regarding the state of execution, and other runtime values that can be of importance for testing and usage in other dependent ARM templates.

As we discuss resource and output JSON objects, you will discover that additional capabilities are needed to configure the objects using runtime values and objects. Without the ability to compute, configure, or generate runtime values based on a given context, it is difficult to write generic, modular, reusable, and maintainable templates. Azure ARM templates provide expressions that write constructs to be evaluated at runtime while deploying the template to generate values. These expressions can use Azure ARM templates' numerous functions to ease the task of determining and generating appropriate values.

In this chapter, we will use many functions and write numerous expressions to explain their usage. Specifically, we will cover the following topics:

  • ARM template expressions
  • ARM template functions
  • The resources object
  • A complete template
  • Nesting resources
  • Understanding dependsOn
  • Using references
  • Understanding resourceId
  • Using linked templates
  • Using nested templates