Azure naming · Microsoft.Network/networkSecurityGroups

nsg Network security group

Stateful allow/deny rules for subnets and NICs.

Naming constraints

CAF abbreviationnsg
Resource typeMicrosoft.Network/networkSecurityGroups
Length1–80 characters
CaseMixed case
Allowed charactersAlphanumerics, underscores, periods, and hyphens. Start with alphanumeric; end with alphanumeric or underscore.
Uniqueness Resource group
SeparatorHyphen
Watch out: The portal creates <vm>-nsg automatically when you create a VM with a basic NSG.

Source: Microsoft Learn, “Naming rules and restrictions for Azure resources”, checked October 2026. Abbreviation from the Cloud Adoption Framework.

Example & copy-ready

A worked name for workload app, env prod, region weu, instance 001.

Example name
nsg-app-prod-weu-001 Valid
Validation regex for CI checks or pre-commit hooks (.NET and JavaScript)
^(?=.{1,80}$)[A-Za-z0-9](?:[A-Za-z0-9_.-]*[A-Za-z0-9_])?$
Bicep naming expression
var name = take('nsg-${workload}-${env}-${region}-${instance}', 80)
Terraform local
locals {
  name = substr(join("-", compact(["nsg", var.workload, var.env, var.region, var.instance])), 0, 80)
}

Azure Policy can't evaluate regular expressions, so a policy can check the nsg prefix but not the full format. Run the regex in your pipeline, or audit existing names on a schedule.

Uniqueness scope

Unique within the parent resource group. The same name can be reused in a different resource group.

Open in the name generator