Creating NSG in azure is easy unless you want to create multiple NSG with multiple inbound and outbound security rules. Here is a simple way to create that.
First open Microsoft Excel and create a .CSV file by following this format: Please do not change the format. Then save the file in CSV format.
Once you are raedy with the CSV file run bellow command. Don’t forget to login and select right subscription
#Mentioned the CSV path here $nsgCsv = Import-Csv "C:\Users\BaselineNSG.csv" $nsgName = 'Subhendu-NSG' $resourceGroup = 'TestRG' $RGLocation = (Get-AzureRmResourceGroup -name $resourceGroup).Location ####################################################################### $rulesArray = @() #create rule config foreach ($rule in $nsgCsv) { $nsgRule = New-AzureRmNetworkSecurityRuleConfig ` -Name $rule.Name ` -Description $rule.Description ` -Protocol $rule.Protocol ` -SourcePortRange ($rule.SourcePortRange -split ',') ` -DestinationPortRange ($rule.DestinationPortRange -split ',') ` -SourceAddressPrefix ($rule.SourceAddressPrefix -split ',') ` -DestinationAddressPrefix ($rule.DestinationAddressPrefix -split ',') ` -Access $rule.Access ` -Priority $rule.Priority ` -Direction $rule.Direction $rulesArray += $nsgRule } #create nsg New-AzureRmNetworkSecurityGroup -Name $nsgNames -ResourceGroupName $resourceGroup -Location $RGLocation -SecurityRules $rulesArray
# Mention your VM here $VMName = "SubhenduTestVM" # Mention your Stage Storage here $stagestorageaccountname…
Hope you are doing great . Current Time is very critical for us . I…
Being a part of Microsoft Education I have explored powershell long time back . But…
Sorry !! But Yes . Microsoft is about to release new exam in Azure Segment…
Migration is always a part of our life and part of this fantastic IT world…
I believe you have enjoyed my last script related to VM snapshot creation . Sometime…