All empty or null properties that are not required should be excluded from the template samples. This includes empty objects {}, arrays [], strings "", and any property that has a null value.

Why is this an issue?

Empty or null elements are usually introduced by mistake. They are useless and prevent readability of the code.

Exceptions

The top-level JSON template properties: parameters, variables, functions, resources and outputs are excluded from this rule. Also required properties are excluded from this rule.

How to fix it in ARM Templates

Empty or null elements should be removed or completed with real code.

Code examples

Noncompliant code example

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2023-01-01",
      "sku": "Standard_GRS",
      "name": null,
      "kind": "",
      "tags": {},
      "dependsOn": []
    }
  ]
}

Compliant solution

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2023-01-01",
      "sku": "Standard_GRS",
      "name": "myStorage",
      "kind": "BlobStorage"
    }
  ]
}

How to fix it in Bicep

Empty or null elements should be removed or completed with real code.

Code examples

Noncompliant code example

resource exampleStorage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: null     // Noncompliant
  kind: ''       // Noncompliant
  sku: 'Standard_GRS'
  tags: {}       // Noncompliant
  dependsOn: []  // Noncompliant
}

Compliant solution

resource exampleStorage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: 'myStorage'   // Compliant
  kind: 'BlobStorage' // Compliant
  sku: 'Standard_GRS'
}

Resources

External coding guidelines