0

I'm following the following to use Azure CLI to open ports
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/nsg-quickstart

I.e., the command,

az vm open-port --resource-group myResourceGroup --name myVM --port 80

works fine. However, when I try to open up the next port, 21, I got this:

Security rule open-port-80 conflicts with rule open-port-21. Rules cannot have the same Priority and Direction.

So

  • how do I open a bunch of ports (not just one) to my VM using Azure CLI?
  • how do I add more ports to the already opened set of ports to my VM using Azure CLI?

thx

Run5k
  • 16,463
  • 24
  • 53
  • 67
xpt
  • 9,385
  • 44
  • 120
  • 178

2 Answers2

3

For your issue, you want to open port for your Azure VM. Actually, they're Network Security Group(NSG) rules. You used command:

az vm open-port --resourcr-group myResourceGroup --name myVM --port 80

It used the default priority and it's just one.

So you can use special and complete command to create rules. And the rules like this:

az network nsg rule create --name myRuleName --resource-group myResourveGroup --priority 100 --access Allow --source-address-prefixes '*' --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges 80 --protocol Tcp

For more detail about the command you can read az network nsg rule.

1

This example worked as of Aug 12 2018 to allow tcp/2222 inbound

az network nsg rule create --nsg-name c3nsg --resource-group c3 -n c3nsg-nonstandard-ssh --direction Inbound --priority 101 --access Allow --source-address-prefixes * --source-port-ranges * --destination-address-prefixes * --destination-port-ranges 2222 --protocol tcp