summary import { SecurityRule , NetworkManagementClient } from "@msinternal/network-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createSecurityRule ( ) { const subscriptionId = "subid" ; const resourceGroupName = "rg1" ; const networkSecurityGroupName = "testnsg" ; const securityRuleName = "rule1" ; const securityRuleParameters = { access : "Deny" , destinationAddressPrefix : "11.0.0.0/8" , destinationPortRange : "8080" , direction : "Outbound" , priority : 100 , sourceAddressPrefix : "10.0.0.0/8" , sourcePortRange : "*" , protocol : "*" } ; const credential = new DefaultAzureCredential ( ) ; const client = new NetworkManagementClient ( credential , subscriptionId ) ; const result = await client . securityRules . beginCreateOrUpdateAndWait ( resourceGroupName , networkSecurityGroupName , securityRuleName , securityRuleParameters ) ; console . log ( result ) ; } createSecurityRule ( ) . catch ( console . error ) ;