summary import { ConnectionMonitor , NetworkManagementClient } from "@msinternal/network-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createConnectionMonitorV2 ( ) { const subscriptionId = "subid" ; const resourceGroupName = "rg1" ; const networkWatcherName = "nw1" ; const connectionMonitorName = "cm1" ; const parameters = { endpoints : [ { name : "vm1" , resourceId : "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1" } , { name : "CanaryWorkspaceVamshi" , filter : { type : "Include" , items : [ { type : "AgentAddress" , address : "npmuser" } ] } , resourceId : "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace" } , { name : "bing" , address : "bing.com" } , { name : "google" , address : "google.com" } ] , outputs : [ ] , testConfigurations : [ { name : "testConfig1" , tcpConfiguration : { disableTraceRoute : false , port : 80 } , testFrequencySec : 60 , protocol : "Tcp" } ] , testGroups : [ { name : "test1" , destinations : [ "bing" , "google" ] , disable : false , sources : [ "vm1" , "CanaryWorkspaceVamshi" ] , testConfigurations : [ "testConfig1" ] } ] } ; const credential = new DefaultAzureCredential ( ) ; const client = new NetworkManagementClient ( credential , subscriptionId ) ; const result = await client . connectionMonitors . beginCreateOrUpdateAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , parameters ) ; console . log ( result ) ; } createConnectionMonitorV2 ( ) . catch ( console . error ) ;