Courseiva

Fixing an Undeclared Resource Reference in an ARM Template

Exhibit

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Web/sites/config",
      "apiVersion": "2021-02-01",
      "name": "[concat(parameters('siteName'), '/appsettings')]",
      "properties": {
        "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', parameters('insightsName')), '2020-02-02').InstrumentationKey]"
      }
    }
  ]
}

Refer to the exhibit. You are creating an ARM template to deploy an App Service and its Application Insights configuration. The template fails to deploy with error: 'The resource 'Microsoft.Insights/components/...' is not defined in the template.' What is the most likely cause?

Quick Answer

This error means the ARM template references an Application Insights resource — through reference() or a dependsOn — that was never actually declared inside the template's resources array. ARM requires every resource you reference to be explicitly defined in that same deployment; if it's missing, the deployment engine can't resolve it and fails validation before anything gets provisioned.

⚠ Common exam trap

Candidates often confuse a missing resource definition with a syntax error in the `reference()` function or an API version issue, but the error message explicitly says 'not defined', which points directly to the resource not being declared in the template's `resources` section.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The Application Insights component is not defined as a resource in the template.

The error 'The resource 'Microsoft.Insights/components/...' is not defined in the template' indicates that the ARM template references an Application Insights component (e.g., via the `reference()` function or a `dependsOn` property) that is not declared as a resource within the template's `resources` array. In ARM templates, every resource you reference must be explicitly defined; otherwise, the deployment engine cannot resolve it, causing this validation error.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The reference function cannot be used in a properties object.

    Why it's wrong here

    The reference function is valid inside a properties object; the error indicates the Application Insights resource is absent from the template's resources array, so reference cannot resolve it. It is tempting because reference does have placement restrictions, but the message names an undefined resource, not a function misuse.

  • ✗

    The reference function syntax is incorrect.

    Why it's wrong here

    Incorrect reference syntax produces a different validation error about the function itself, not a message stating the resource is not defined in the template. It is tempting because reference errors are common in ARM templates, yet the actual cause is the missing Microsoft.Insights/components resource declaration.

  • ✓

    The Application Insights component is not defined as a resource in the template.

    Why this is correct

    The deployment fails because ARM cannot resolve a reference to a resource absent from the template. Application Insights requires an explicit `Microsoft.Insights/components` resource declaration; without it, the App Service's instrumentation settings reference a non-existent resource, satisfying the stem's "not defined in the template" constraint.

  • ✗

    The apiVersion for the config resource is outdated.

    Why it's wrong here

    The error names a missing resource declaration, not a version problem: the Application Insights component resource itself is absent, so no apiVersion value can resolve it. Bumping apiVersion is tempting because schema-version mismatches do cause deployment failures, and it would be the fix when a resource exists but its apiVersion is deprecated.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

Go deeper

Related to this question

About these practice questions

One of 696 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

3 more ways this is tested on AZ-400

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Refer to the exhibit. A release pipeline deploys this ARM template. The deployment fails with error: 'The template parameters 'adminPassword' is not a valid input.' What is the most likely cause?

hard
  • A.The VM size is not available in the specified location.
  • ✓ B.The parameter 'adminPassword' is not defined in the parameters section of the template.
  • C.The resource group location is invalid.
  • D.The parameter 'adminPassword' is misspelled in the template.

Why B: The error 'The template parameters 'adminPassword' is not a valid input' occurs when the ARM template does not declare a parameter named 'adminPassword' in its parameters section. Even if the parameter is referenced elsewhere, it must be explicitly defined in the parameters block to be accepted. Therefore, the most likely cause is that the parameter is missing from the template's parameters definition.

Variation 2. The exhibit shows a parameters file for an ARM template deployment. During a release pipeline, the deployment fails with the error 'The provided value for the template parameter 'sku' is not valid'. The ARM template defines the 'sku' parameter as an allowed value set of ['F1', 'D1', 'B1', 'S1']. What could be the issue?

hard
  • ✓ A.The parameter file contains an extra space or hidden character in the 'sku' value.
  • B.The parameter file is missing the '$schema' property.
  • C.The 'sku' parameter is defined in the 'variables' section instead of 'parameters'.
  • D.The ARM template expects a different API version for the resource.

Why A: ARM parameter files are JSON, and the allowed-values check is a strict string comparison against the template's allowed set. A trailing space, non-breaking space, or hidden Unicode character in the 'sku' value (for example 'F1 ' instead of 'F1') causes the value to fail the allowed-values validation even though it looks correct in the editor. This is the classic cause of 'The provided value for the template parameter is not valid' when the value visually matches the allowed list.

Variation 3. Your build pipeline uses a YAML template to define steps. You want to pass a parameter to the template to conditionally run a task. What syntax should you use in the template?

medium
  • ✓ A.parameters:
  • B.arguments:
  • C.inputs:
  • D.variables:

Why A: The 'parameters' key in a YAML template is used to define parameters that can be passed to the template, allowing conditional execution based on the parameter value. Option B is incorrect: 'arguments' is not a standard YAML key for passing parameters to templates; it is used for specifying script arguments. Option C is incorrect: 'inputs' is used for task inputs within a step, not for template parameters. Option D is incorrect: 'variables' are used to define pipeline variables, not for passing parameters to templates.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.