Skip to content

ARM template validation fails when Application Insights deployment is disabled #5216

@brendankowitz

Description

@brendankowitz

Description

Deployment template validation fails with an InvalidTemplate error when the "deploy application insights" parameter is set to false.

Error Message

Deployment template validation failed: 'The template resource 'myresource' at line '375' and column '9' is not valid: The resource identifier is null or empty. Please see https://aka.ms/arm-function-reference for usage details.. Please see https://aka.ms/arm-functions for usage details.'. (Code: InvalidTemplate)

Steps to Reproduce

  1. Configure ARM template deployment with Application Insights parameter
  2. Set the "deploy application insights" parameter to false
  3. Attempt to deploy the template
  4. Validation fails at line 375, column 9

Expected Behavior

The ARM template should validate successfully and deploy without Application Insights when the parameter is set to false. The template should handle conditional deployment properly.

Actual Behavior

Template validation fails because a resource at line 375 has a null or empty resource identifier, likely due to a conditional dependency on Application Insights that isn't properly handled.

Environment

  • Template: ARM deployment template for FHIR server
  • Issue Location: Line 375, column 9 in the template
  • Parameter: "deploy application insights" set to false

Root Cause

The error suggests that when Application Insights deployment is disabled, a resource identifier becomes null or empty. This typically occurs when:

  • A resource has a dependency or reference to Application Insights
  • The conditional logic doesn't properly handle the case when Application Insights is not deployed
  • A resourceId() or similar function returns null/empty when the resource doesn't exist

Suggested Fix

Review line 375 of the ARM template and:

  1. Identify the resource with the null identifier
  2. Add proper conditional logic to handle the case when Application Insights is disabled
  3. Use conditional expressions like if() to provide alternative values or skip dependencies when Application Insights is not deployed
  4. Ensure all references to Application Insights resources are wrapped in appropriate conditionals

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions