Skip to content

Use valid Application Insights resource names#

Operational Excellence · Application Insights · Rule · 2021_06 · Awareness

Azure Resource Manager (ARM) has requirements for Application Insights resource names.

Description#

When naming Azure resources, resource names must meet service requirements. The requirements for Application Insights resource names are:

  • Between 1 and 255 characters long.
  • Letters, numbers, hyphens, periods, underscores, and parenthesis.
  • Must not end in a period.
  • Resource names must be unique within a resource group.

Recommendation#

Consider using names that meet Application Insights resource naming requirements. Additionally consider naming resources with a standard naming convention.

Examples#

Configure with Bicep#

To deploy resources that pass this rule:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.

For example:

Azure Bicep snippet
@minLength(1)
@maxLength(255)
@description('The name of the resource.')
param name string

@description('The location resources will be deployed.')
param location string = resourceGroup().location

resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
  name: name
  location: location
  kind: 'web'
  properties: {
    Application_Type: 'web'
    Flow_Type: 'Redfield'
    Request_Source: 'IbizaAIExtension'
    WorkspaceResourceId: workspaceId
    DisableLocalAuth: true
  }
}

Configure with Azure Verified Modules

A pre-validated module supported by Microsoft is available from the Azure Bicep public registry. To reference the module, please use the following syntax:

br/public:avm/res/insights/component:<version>

To use the latest version:

br/public:avm/res/insights/component:0.6.0

Configure with Azure template#

To deploy resources that pass this rule:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.

For example:

Azure Template snippet
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "metadata": {
        "description": "The name of the resource."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location resources will be deployed."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Insights/components",
      "apiVersion": "2020-02-02",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "kind": "web",
      "properties": {
        "Application_Type": "web",
        "Flow_Type": "Redfield",
        "Request_Source": "IbizaAIExtension",
        "WorkspaceResourceId": "[parameters('workspaceId')]",
        "DisableLocalAuth": true
      }
    }
  ]
}

Notes#

This rule does not check if Application Insights resource names are unique.

Comments