summary import { VirtualNetworkGateway , NetworkManagementClient } from "@msinternal/network-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function updateVirtualNetworkGateway ( ) { const subscriptionId = "subid" ; const resourceGroupName = "rg1" ; const virtualNetworkGatewayName = "vpngw" ; const parameters = { active : false , bgpSettings : { asn : 65515 , bgpPeeringAddress : "10.0.1.30" , peerWeight : 0 } , customRoutes : { addressPrefixes : [ "101.168.0.6/32" ] } , disableIPSecReplayProtection : false , enableBgp : false , enableBgpRouteTranslationForNat : false , enableDnsForwarding : true , gatewayType : "Vpn" , ipConfigurations : [ { name : "gwipconfig1" , privateIPAllocationMethod : "Dynamic" , publicIPAddress : { id : "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip" } , subnet : { id : "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet" } } ] , location : "centralus" , natRules : [ { name : "natRule1" , typePropertiesType : "Static" , externalMappings : [ { addressSpace : "50.0.0.0/24" } ] , id : "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule1" , internalMappings : [ { addressSpace : "10.10.0.0/24" } ] , ipConfigurationId : "" , mode : "EgressSnat" } , { name : "natRule2" , typePropertiesType : "Static" , externalMappings : [ { addressSpace : "30.0.0.0/24" } ] , id : "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule2" , internalMappings : [ { addressSpace : "20.10.0.0/24" } ] , ipConfigurationId : "" , mode : "IngressSnat" } ] , sku : { name : "VpnGw1" , tier : "VpnGw1" } , vpnClientConfiguration : { radiusServers : [ { radiusServerAddress : "10.2.0.0" , radiusServerScore : 20 , radiusServerSecret : "radiusServerSecret" } ] , vpnClientProtocols : [ "OpenVPN" ] , vpnClientRevokedCertificates : [ ] , vpnClientRootCertificates : [ ] } , vpnType : "RouteBased" } ; const credential = new DefaultAzureCredential ( ) ; const client = new NetworkManagementClient ( credential , subscriptionId ) ; const result = await client . virtualNetworkGateways . beginCreateOrUpdateAndWait ( resourceGroupName , virtualNetworkGatewayName , parameters ) ; console . log ( result ) ; } updateVirtualNetworkGateway ( ) . catch ( console . error ) ;