How to create Azure NSGs with the Azure Portal, Powershell, azurecli, Cloudshell.

Here are examples of how to create Azure NSGs using different methods:

Using the Azure Portal:

  1. Go to the Azure Portal and sign in to your account.
  2. In the left-hand menu, click on “Resource groups”.
  3. Select the resource group in which you want to create the NSG.
  4. Click on “Add”.
  5. Search for “Network security group” and select it.
  6. Fill in the required information, such as the name and region of the NSG.
  7. Click on “Create” to create the NSG.

Using PowerShell:

To create an NSG using PowerShell, you can use the New-AzNetworkSecurityGroup cmdlet. Here’s an example:

powershell
# Connect to your Azure account
Connect-AzAccount

# Create a new NSG
$NSGName = "MyNSG"
$NSGResourceGroupName = "MyResourceGroup"
$NSGLocation = "East US"
New-AzNetworkSecurityGroup -Name $NSGName -ResourceGroupName $NSGResourceGroupName -Location $NSGLocation

Using the Azure CLI:

To create an NSG using the Azure CLI, you can use the az network nsg create command. Here’s an example:

bash
# Log in to your Azure account
az login

# Create a new NSG
NSGName="MyNSG"
NSGResourceGroup="MyResourceGroup"
NSGLocation="eastus"
az network nsg create --name $NSGName --resource-group $NSGResourceGroup --location $NSGLocation

Using Azure Cloud Shell:

Azure Cloud Shell is a browser-based shell environment that provides command-line access to Azure resources. Here’s an example of how to create an NSG using Azure Cloud Shell:

  1. Open the Azure Cloud Shell by clicking on the “Cloud Shell” icon in the Azure Portal toolbar.
  2. Choose the Bash shell environment.
  3. Run the following command to create an NSG:
bash
az network nsg create --name MyNSG --resource-group MyResourceGroup --location eastus

Note: Replace “MyNSG” and “MyResourceGroup” with your desired names.

Author: tonyhughes