Here are examples of how to create Azure NSGs using different methods:
Using the Azure Portal:
- Go to the Azure Portal and sign in to your account.
- In the left-hand menu, click on “Resource groups”.
- Select the resource group in which you want to create the NSG.
- Click on “Add”.
- Search for “Network security group” and select it.
- Fill in the required information, such as the name and region of the NSG.
- 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:
- Open the Azure Cloud Shell by clicking on the “Cloud Shell” icon in the Azure Portal toolbar.
- Choose the Bash shell environment.
- 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.