Skip to content

Use valid NIC names#

Operational Excellence · Network Interface · Rule · 2020_06 · Awareness

Network Interface (NIC) names should meet naming requirements.

Description#

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

  • Between 1 and 80 characters long.
  • Alphanumerics, underscores, periods, and hyphens.
  • Start with alphanumeric.
  • End alphanumeric or underscore.
  • NIC names must be unique within a resource group.

Recommendation#

Consider using names that meet Network Interface naming requirements. Additionally consider naming resources with a standard naming convention.

Examples#

Configure with Azure template#

To deploy network interfaces that pass this rule:

  • Configuring a minLength and maxLength constraint for the resource name parameter.
  • Optionally, you could also use a uniqueString() function to generate a unique name.

For example:

Azure Template snippet
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location resources will be deployed."
      }
    },
    "subnetId": {
      "type": "string",
      "metadata": {
        "description": "A reference to the VNET subnet where the VM will be deployed."
      }
    },
    "nicName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "metadata": {
        "description": "The name of the resource."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2023-05-01",
      "name": "[parameters('nicName')]",
      "location": "[parameters('location')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig-1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "subnet": {
                "id": "[parameters('subnetId')]"
              }
            }
          }
        ]
      }
    }
  ]
}

Configure with Bicep#

To deploy network interfaces that pass this rule:

  • Configuring a minLength and maxLength constraint for the resource name parameter.
  • Optionally, you could also use a uniqueString() function to generate a unique name.

For example:

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

resource nic 'Microsoft.Network/networkInterfaces@2023-05-01' = {
  name: nicName
  location: location
  properties: {
    ipConfigurations: [
      {
        name: 'ipconfig-1'
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          subnet: {
            id: subnetId
          }
        }
      }
    ]
  }
}

Notes#

This rule does not check if Network Interface names are unique.

Comments