summary import { NetworkSecurityGroup , NetworkManagementClient } from "@msinternal/network-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createNetworkSecurityGroupWithRule ( ) { const subscriptionId = "subid" ; const resourceGroupName = "rg1" ; const networkSecurityGroupName = "testnsg" ; const parameters = { location : "eastus" , securityRules : [ { name : "rule1" , access : "Allow" , destinationAddressPrefix : "*" , destinationPortRange : "80" , direction : "Inbound" , priority : 130 , sourceAddressPrefix : "*" , sourcePortRange : "*" , protocol : "*" } ] } ; const credential = new DefaultAzureCredential ( ) ; const client = new NetworkManagementClient ( credential , subscriptionId ) ; const result = await client . networkSecurityGroups . beginCreateOrUpdateAndWait ( resourceGroupName , networkSecurityGroupName , parameters ) ; console . log ( result ) ; } createNetworkSecurityGroupWithRule ( ) . catch ( console . error ) ;