Network security groups - az network nsg

Manage Azure Network Security Groups.

Commands

az network nsg create Create a network security group.
az network nsg delete Deletes the specified network security group.
az network nsg list Lists information about network security groups.
az network nsg rule Manage NSG rules.
az network nsg rule create Create an NSG rule.
az network nsg rule delete Delete an NSG rule.
az network nsg rule list List all rules in an NSG.
az network nsg rule show Show details of an NSG rule.
az network nsg rule update Update an NSG rule.
az network nsg show Retrieves information about the specified network security group.
az network nsg update

az network nsg create

Create a network security group.

az network nsg create --name
--resource-group
[--location]
[--tags]

Examples

Create an NSG with some tags.

az network nsg create -g MyResourceGroup -n MyNsg --tags super_secure no_80 no_22

Required Parameters

--name -n

Name of the network security group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

Optional Parameters

--location -l

Location. You can configure the default location using az configure --defaults location=.

--tags

Space separated tags in 'key[=value]' format. Use "" to clear existing tags.

az network nsg delete

Deletes the specified network security group.

az network nsg delete --name
--resource-group

Required Parameters

--name -n

Name of the network security group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az network nsg list

Lists information about network security groups.

az network nsg list [--resource-group]

Examples

List all NSGs for a specific region (for example, West US).

az network nsg list --query "[?location=='westus']"

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az network nsg show

Retrieves information about the specified network security group.

az network nsg show --name
--resource-group
[--expand]

Examples

Get basic information about an NSG.

az network nsg show -g MyResourceGroup -n MyNsg

Get basic information about all default NSG rules with "Allow" access.

az network nsg show -g MyResourceGroup -n MyNsg --query "defaultSecurityRules[?access=='Allow']"

Required Parameters

--name -n

Name of the network security group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

Optional Parameters

--expand

Expands referenced resources.

az network nsg update

az network nsg update --name
--resource-group
[--add]
[--remove]
[--set]

Required Parameters

--name -n

Name of the network security group.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.