leflic
leflic

Reputation: 59

Get-AzureNetworkSecurityGroup not working

I try too add some Security roules in my Azure NSG via Powershell, but

Get-AzureNetworkSecurityGroup

doesn't seem to work, it alway returns nothing. I can't select a NSG by Name too

Get-AzureNetworkSecurityGroup -Name myname

Although

Find-AzureRmResource -ResourceNameContains nsg

finds my NSGs.

What do I do wrong?

Thanks

Upvotes: 1

Views: 1401

Answers (1)

Kaushal Kumar Panday
Kaushal Kumar Panday

Reputation: 2467

Get-AzureNetworkSecurityGroup is meant for NSG's created using the classic deployment model (Old Portal). This will yeild output only if you have classic NSG's in your subscription.

You have indicated that you get output when you use the Find-AzureRmResource commandlet. Now this is a commandlet for the resources created using the ARM deployment model in Azure. One easy way to identify the Resource Manager commandlets is to look for the letters RM in the commandlet.

Looks like you have NSG's created using Resource Manager, so try the following:

Get-AzureRmNetworkSecurityGroup -Name  nsg1 -ResourceGroupName "KaushalRG"

Looks for network security group "nsg1" in resource group "KaushalRG"

More information on the deployment models in Azure can be found here: Azure Resource Manager vs. classic deployment

Upvotes: 1

Related Questions