Configure Azure Connection Monitors

The azure-native:network:ConnectionMonitor resource, part of the Pulumi Azure Native provider, defines a Connection Monitor that continuously tests network connectivity between endpoints and measures latency, packet loss, and reachability. This guide focuses on three capabilities: VM-to-external endpoint monitoring, multi-source multi-destination test groups, and Arc-enabled network segment monitoring.

Connection monitors require a Network Watcher resource in the target region and reference existing VMs, Log Analytics workspaces, or Arc-enabled infrastructure. The examples are intentionally small. Combine them with your own monitoring infrastructure and alerting pipelines.

Monitor connectivity between VM and external endpoint

Network teams verify that VMs can reach external services by continuously testing connectivity and measuring latency.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const connectionMonitor = new azure_native.network.ConnectionMonitor("connectionMonitor", {
    connectionMonitorName: "cm1",
    endpoints: [
        {
            name: "source",
            resourceId: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1",
        },
        {
            address: "bing.com",
            name: "destination",
        },
    ],
    location: "eastus",
    networkWatcherName: "nw1",
    resourceGroupName: "rg1",
    testConfigurations: [{
        name: "tcp",
        protocol: azure_native.network.ConnectionMonitorTestConfigurationProtocol.Tcp,
        tcpConfiguration: {
            port: 80,
        },
        testFrequencySec: 60,
    }],
    testGroups: [{
        destinations: ["destination"],
        name: "tg",
        sources: ["source"],
        testConfigurations: ["tcp"],
    }],
});
import pulumi
import pulumi_azure_native as azure_native

connection_monitor = azure_native.network.ConnectionMonitor("connectionMonitor",
    connection_monitor_name="cm1",
    endpoints=[
        {
            "name": "source",
            "resource_id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1",
        },
        {
            "address": "bing.com",
            "name": "destination",
        },
    ],
    location="eastus",
    network_watcher_name="nw1",
    resource_group_name="rg1",
    test_configurations=[{
        "name": "tcp",
        "protocol": azure_native.network.ConnectionMonitorTestConfigurationProtocol.TCP,
        "tcp_configuration": {
            "port": 80,
        },
        "test_frequency_sec": 60,
    }],
    test_groups=[{
        "destinations": ["destination"],
        "name": "tg",
        "sources": ["source"],
        "test_configurations": ["tcp"],
    }])
package main

import (
	network "github.com/pulumi/pulumi-azure-native-sdk/network/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := network.NewConnectionMonitor(ctx, "connectionMonitor", &network.ConnectionMonitorArgs{
			ConnectionMonitorName: pulumi.String("cm1"),
			Endpoints: network.ConnectionMonitorEndpointArray{
				&network.ConnectionMonitorEndpointArgs{
					Name:       pulumi.String("source"),
					ResourceId: pulumi.String("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1"),
				},
				&network.ConnectionMonitorEndpointArgs{
					Address: pulumi.String("bing.com"),
					Name:    pulumi.String("destination"),
				},
			},
			Location:           pulumi.String("eastus"),
			NetworkWatcherName: pulumi.String("nw1"),
			ResourceGroupName:  pulumi.String("rg1"),
			TestConfigurations: network.ConnectionMonitorTestConfigurationArray{
				&network.ConnectionMonitorTestConfigurationArgs{
					Name:     pulumi.String("tcp"),
					Protocol: pulumi.String(network.ConnectionMonitorTestConfigurationProtocolTcp),
					TcpConfiguration: &network.ConnectionMonitorTcpConfigurationArgs{
						Port: pulumi.Int(80),
					},
					TestFrequencySec: pulumi.Int(60),
				},
			},
			TestGroups: network.ConnectionMonitorTestGroupArray{
				&network.ConnectionMonitorTestGroupArgs{
					Destinations: pulumi.StringArray{
						pulumi.String("destination"),
					},
					Name: pulumi.String("tg"),
					Sources: pulumi.StringArray{
						pulumi.String("source"),
					},
					TestConfigurations: pulumi.StringArray{
						pulumi.String("tcp"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var connectionMonitor = new AzureNative.Network.ConnectionMonitor("connectionMonitor", new()
    {
        ConnectionMonitorName = "cm1",
        Endpoints = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Name = "source",
                ResourceId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1",
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Address = "bing.com",
                Name = "destination",
            },
        },
        Location = "eastus",
        NetworkWatcherName = "nw1",
        ResourceGroupName = "rg1",
        TestConfigurations = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestConfigurationArgs
            {
                Name = "tcp",
                Protocol = AzureNative.Network.ConnectionMonitorTestConfigurationProtocol.Tcp,
                TcpConfiguration = new AzureNative.Network.Inputs.ConnectionMonitorTcpConfigurationArgs
                {
                    Port = 80,
                },
                TestFrequencySec = 60,
            },
        },
        TestGroups = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestGroupArgs
            {
                Destinations = new[]
                {
                    "destination",
                },
                Name = "tg",
                Sources = new[]
                {
                    "source",
                },
                TestConfigurations = new[]
                {
                    "tcp",
                },
            },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.ConnectionMonitor;
import com.pulumi.azurenative.network.ConnectionMonitorArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTcpConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var connectionMonitor = new ConnectionMonitor("connectionMonitor", ConnectionMonitorArgs.builder()
            .connectionMonitorName("cm1")
            .endpoints(            
                ConnectionMonitorEndpointArgs.builder()
                    .name("source")
                    .resourceId("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .address("bing.com")
                    .name("destination")
                    .build())
            .location("eastus")
            .networkWatcherName("nw1")
            .resourceGroupName("rg1")
            .testConfigurations(ConnectionMonitorTestConfigurationArgs.builder()
                .name("tcp")
                .protocol("Tcp")
                .tcpConfiguration(ConnectionMonitorTcpConfigurationArgs.builder()
                    .port(80)
                    .build())
                .testFrequencySec(60)
                .build())
            .testGroups(ConnectionMonitorTestGroupArgs.builder()
                .destinations("destination")
                .name("tg")
                .sources("source")
                .testConfigurations("tcp")
                .build())
            .build());

    }
}
resources:
  connectionMonitor:
    type: azure-native:network:ConnectionMonitor
    properties:
      connectionMonitorName: cm1
      endpoints:
        - name: source
          resourceId: /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1
        - address: bing.com
          name: destination
      location: eastus
      networkWatcherName: nw1
      resourceGroupName: rg1
      testConfigurations:
        - name: tcp
          protocol: Tcp
          tcpConfiguration:
            port: 80
          testFrequencySec: 60
      testGroups:
        - destinations:
            - destination
          name: tg
          sources:
            - source
          testConfigurations:
            - tcp

The endpoints array defines source and destination. Sources reference Azure VMs by resource ID; destinations can be external addresses like “bing.com”. The testConfigurations array specifies protocol (TCP, HTTP, or ICMP), port, and test frequency in seconds. The testGroups array links sources to destinations using the test configuration, creating the actual connectivity tests that run continuously.

Monitor multiple endpoints with workspace integration

Production monitoring tests connectivity from multiple sources to multiple destinations, with results flowing to Log Analytics.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const connectionMonitor = new azure_native.network.ConnectionMonitor("connectionMonitor", {
    connectionMonitorName: "cm1",
    endpoints: [
        {
            name: "vm1",
            resourceId: "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1",
        },
        {
            filter: {
                items: [{
                    address: "npmuser",
                    type: azure_native.network.ConnectionMonitorEndpointFilterItemType.AgentAddress,
                }],
                type: azure_native.network.ConnectionMonitorEndpointFilterType.Include,
            },
            name: "CanaryWorkspaceVamshi",
            resourceId: "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace",
        },
        {
            address: "bing.com",
            name: "bing",
        },
        {
            address: "google.com",
            name: "google",
        },
    ],
    networkWatcherName: "nw1",
    outputs: [],
    resourceGroupName: "rg1",
    testConfigurations: [{
        name: "testConfig1",
        protocol: azure_native.network.ConnectionMonitorTestConfigurationProtocol.Tcp,
        tcpConfiguration: {
            disableTraceRoute: false,
            port: 80,
        },
        testFrequencySec: 60,
    }],
    testGroups: [{
        destinations: [
            "bing",
            "google",
        ],
        disable: false,
        name: "test1",
        sources: [
            "vm1",
            "CanaryWorkspaceVamshi",
        ],
        testConfigurations: ["testConfig1"],
    }],
});
import pulumi
import pulumi_azure_native as azure_native

connection_monitor = azure_native.network.ConnectionMonitor("connectionMonitor",
    connection_monitor_name="cm1",
    endpoints=[
        {
            "name": "vm1",
            "resource_id": "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1",
        },
        {
            "filter": {
                "items": [{
                    "address": "npmuser",
                    "type": azure_native.network.ConnectionMonitorEndpointFilterItemType.AGENT_ADDRESS,
                }],
                "type": azure_native.network.ConnectionMonitorEndpointFilterType.INCLUDE,
            },
            "name": "CanaryWorkspaceVamshi",
            "resource_id": "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace",
        },
        {
            "address": "bing.com",
            "name": "bing",
        },
        {
            "address": "google.com",
            "name": "google",
        },
    ],
    network_watcher_name="nw1",
    outputs=[],
    resource_group_name="rg1",
    test_configurations=[{
        "name": "testConfig1",
        "protocol": azure_native.network.ConnectionMonitorTestConfigurationProtocol.TCP,
        "tcp_configuration": {
            "disable_trace_route": False,
            "port": 80,
        },
        "test_frequency_sec": 60,
    }],
    test_groups=[{
        "destinations": [
            "bing",
            "google",
        ],
        "disable": False,
        "name": "test1",
        "sources": [
            "vm1",
            "CanaryWorkspaceVamshi",
        ],
        "test_configurations": ["testConfig1"],
    }])
package main

import (
	network "github.com/pulumi/pulumi-azure-native-sdk/network/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := network.NewConnectionMonitor(ctx, "connectionMonitor", &network.ConnectionMonitorArgs{
			ConnectionMonitorName: pulumi.String("cm1"),
			Endpoints: network.ConnectionMonitorEndpointArray{
				&network.ConnectionMonitorEndpointArgs{
					Name:       pulumi.String("vm1"),
					ResourceId: pulumi.String("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1"),
				},
				&network.ConnectionMonitorEndpointArgs{
					Filter: &network.ConnectionMonitorEndpointFilterArgs{
						Items: network.ConnectionMonitorEndpointFilterItemArray{
							&network.ConnectionMonitorEndpointFilterItemArgs{
								Address: pulumi.String("npmuser"),
								Type:    pulumi.String(network.ConnectionMonitorEndpointFilterItemTypeAgentAddress),
							},
						},
						Type: pulumi.String(network.ConnectionMonitorEndpointFilterTypeInclude),
					},
					Name:       pulumi.String("CanaryWorkspaceVamshi"),
					ResourceId: pulumi.String("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace"),
				},
				&network.ConnectionMonitorEndpointArgs{
					Address: pulumi.String("bing.com"),
					Name:    pulumi.String("bing"),
				},
				&network.ConnectionMonitorEndpointArgs{
					Address: pulumi.String("google.com"),
					Name:    pulumi.String("google"),
				},
			},
			NetworkWatcherName: pulumi.String("nw1"),
			Outputs:            network.ConnectionMonitorOutputTypeArray{},
			ResourceGroupName:  pulumi.String("rg1"),
			TestConfigurations: network.ConnectionMonitorTestConfigurationArray{
				&network.ConnectionMonitorTestConfigurationArgs{
					Name:     pulumi.String("testConfig1"),
					Protocol: pulumi.String(network.ConnectionMonitorTestConfigurationProtocolTcp),
					TcpConfiguration: &network.ConnectionMonitorTcpConfigurationArgs{
						DisableTraceRoute: pulumi.Bool(false),
						Port:              pulumi.Int(80),
					},
					TestFrequencySec: pulumi.Int(60),
				},
			},
			TestGroups: network.ConnectionMonitorTestGroupArray{
				&network.ConnectionMonitorTestGroupArgs{
					Destinations: pulumi.StringArray{
						pulumi.String("bing"),
						pulumi.String("google"),
					},
					Disable: pulumi.Bool(false),
					Name:    pulumi.String("test1"),
					Sources: pulumi.StringArray{
						pulumi.String("vm1"),
						pulumi.String("CanaryWorkspaceVamshi"),
					},
					TestConfigurations: pulumi.StringArray{
						pulumi.String("testConfig1"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var connectionMonitor = new AzureNative.Network.ConnectionMonitor("connectionMonitor", new()
    {
        ConnectionMonitorName = "cm1",
        Endpoints = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Name = "vm1",
                ResourceId = "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1",
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Filter = new AzureNative.Network.Inputs.ConnectionMonitorEndpointFilterArgs
                {
                    Items = new[]
                    {
                        new AzureNative.Network.Inputs.ConnectionMonitorEndpointFilterItemArgs
                        {
                            Address = "npmuser",
                            Type = AzureNative.Network.ConnectionMonitorEndpointFilterItemType.AgentAddress,
                        },
                    },
                    Type = AzureNative.Network.ConnectionMonitorEndpointFilterType.Include,
                },
                Name = "CanaryWorkspaceVamshi",
                ResourceId = "/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace",
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Address = "bing.com",
                Name = "bing",
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Address = "google.com",
                Name = "google",
            },
        },
        NetworkWatcherName = "nw1",
        Outputs = new[] {},
        ResourceGroupName = "rg1",
        TestConfigurations = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestConfigurationArgs
            {
                Name = "testConfig1",
                Protocol = AzureNative.Network.ConnectionMonitorTestConfigurationProtocol.Tcp,
                TcpConfiguration = new AzureNative.Network.Inputs.ConnectionMonitorTcpConfigurationArgs
                {
                    DisableTraceRoute = false,
                    Port = 80,
                },
                TestFrequencySec = 60,
            },
        },
        TestGroups = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestGroupArgs
            {
                Destinations = new[]
                {
                    "bing",
                    "google",
                },
                Disable = false,
                Name = "test1",
                Sources = new[]
                {
                    "vm1",
                    "CanaryWorkspaceVamshi",
                },
                TestConfigurations = new[]
                {
                    "testConfig1",
                },
            },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.ConnectionMonitor;
import com.pulumi.azurenative.network.ConnectionMonitorArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointFilterArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTcpConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var connectionMonitor = new ConnectionMonitor("connectionMonitor", ConnectionMonitorArgs.builder()
            .connectionMonitorName("cm1")
            .endpoints(            
                ConnectionMonitorEndpointArgs.builder()
                    .name("vm1")
                    .resourceId("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .filter(ConnectionMonitorEndpointFilterArgs.builder()
                        .items(ConnectionMonitorEndpointFilterItemArgs.builder()
                            .address("npmuser")
                            .type("AgentAddress")
                            .build())
                        .type("Include")
                        .build())
                    .name("CanaryWorkspaceVamshi")
                    .resourceId("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .address("bing.com")
                    .name("bing")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .address("google.com")
                    .name("google")
                    .build())
            .networkWatcherName("nw1")
            .outputs()
            .resourceGroupName("rg1")
            .testConfigurations(ConnectionMonitorTestConfigurationArgs.builder()
                .name("testConfig1")
                .protocol("Tcp")
                .tcpConfiguration(ConnectionMonitorTcpConfigurationArgs.builder()
                    .disableTraceRoute(false)
                    .port(80)
                    .build())
                .testFrequencySec(60)
                .build())
            .testGroups(ConnectionMonitorTestGroupArgs.builder()
                .destinations(                
                    "bing",
                    "google")
                .disable(false)
                .name("test1")
                .sources(                
                    "vm1",
                    "CanaryWorkspaceVamshi")
                .testConfigurations("testConfig1")
                .build())
            .build());

    }
}
resources:
  connectionMonitor:
    type: azure-native:network:ConnectionMonitor
    properties:
      connectionMonitorName: cm1
      endpoints:
        - name: vm1
          resourceId: /subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1
        - filter:
            items:
              - address: npmuser
                type: AgentAddress
            type: Include
          name: CanaryWorkspaceVamshi
          resourceId: /subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace
        - address: bing.com
          name: bing
        - address: google.com
          name: google
      networkWatcherName: nw1
      outputs: []
      resourceGroupName: rg1
      testConfigurations:
        - name: testConfig1
          protocol: Tcp
          tcpConfiguration:
            disableTraceRoute: false
            port: 80
          testFrequencySec: 60
      testGroups:
        - destinations:
            - bing
            - google
          disable: false
          name: test1
          sources:
            - vm1
            - CanaryWorkspaceVamshi
          testConfigurations:
            - testConfig1

This configuration defines four endpoints: a VM source, a Log Analytics workspace source with agent filtering, and two external destinations. The filter property on the workspace endpoint selects specific agents by address. The testGroups array references multiple sources and destinations by name, creating a matrix of connectivity tests. All sources test all destinations using the shared test configuration.

Monitor Arc-enabled network segments

Hybrid environments with Azure Arc monitor connectivity from on-premises or multi-cloud networks by defining network scopes.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const connectionMonitor = new azure_native.network.ConnectionMonitor("connectionMonitor", {
    connectionMonitorName: "cm1",
    endpoints: [
        {
            name: "vm1",
            resourceId: "/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM",
            type: azure_native.network.EndpointType.AzureVM,
        },
        {
            address: "bing.com",
            name: "bing",
            type: azure_native.network.EndpointType.ExternalAddress,
        },
        {
            address: "google.com",
            name: "google",
            type: azure_native.network.EndpointType.ExternalAddress,
        },
        {
            locationDetails: {
                region: "eastus",
            },
            name: "ArcBasedNetwork",
            scope: {
                include: [{
                    address: "172.21.128.0/20",
                }],
            },
            subscriptionId: "9cece3e3-0f7d-47ca-af0e-9772773f90b7",
            type: azure_native.network.EndpointType.AzureArcNetwork,
        },
    ],
    networkWatcherName: "nw1",
    outputs: [],
    resourceGroupName: "rg1",
    testConfigurations: [{
        name: "testConfig1",
        protocol: azure_native.network.ConnectionMonitorTestConfigurationProtocol.Tcp,
        tcpConfiguration: {
            disableTraceRoute: false,
            port: 80,
        },
        testFrequencySec: 60,
    }],
    testGroups: [{
        destinations: [
            "bing",
            "google",
        ],
        disable: false,
        name: "test1",
        sources: [
            "vm1",
            "ArcBasedNetwork",
        ],
        testConfigurations: ["testConfig1"],
    }],
});
import pulumi
import pulumi_azure_native as azure_native

connection_monitor = azure_native.network.ConnectionMonitor("connectionMonitor",
    connection_monitor_name="cm1",
    endpoints=[
        {
            "name": "vm1",
            "resource_id": "/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM",
            "type": azure_native.network.EndpointType.AZURE_VM,
        },
        {
            "address": "bing.com",
            "name": "bing",
            "type": azure_native.network.EndpointType.EXTERNAL_ADDRESS,
        },
        {
            "address": "google.com",
            "name": "google",
            "type": azure_native.network.EndpointType.EXTERNAL_ADDRESS,
        },
        {
            "location_details": {
                "region": "eastus",
            },
            "name": "ArcBasedNetwork",
            "scope": {
                "include": [{
                    "address": "172.21.128.0/20",
                }],
            },
            "subscription_id": "9cece3e3-0f7d-47ca-af0e-9772773f90b7",
            "type": azure_native.network.EndpointType.AZURE_ARC_NETWORK,
        },
    ],
    network_watcher_name="nw1",
    outputs=[],
    resource_group_name="rg1",
    test_configurations=[{
        "name": "testConfig1",
        "protocol": azure_native.network.ConnectionMonitorTestConfigurationProtocol.TCP,
        "tcp_configuration": {
            "disable_trace_route": False,
            "port": 80,
        },
        "test_frequency_sec": 60,
    }],
    test_groups=[{
        "destinations": [
            "bing",
            "google",
        ],
        "disable": False,
        "name": "test1",
        "sources": [
            "vm1",
            "ArcBasedNetwork",
        ],
        "test_configurations": ["testConfig1"],
    }])
package main

import (
	network "github.com/pulumi/pulumi-azure-native-sdk/network/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := network.NewConnectionMonitor(ctx, "connectionMonitor", &network.ConnectionMonitorArgs{
			ConnectionMonitorName: pulumi.String("cm1"),
			Endpoints: network.ConnectionMonitorEndpointArray{
				&network.ConnectionMonitorEndpointArgs{
					Name:       pulumi.String("vm1"),
					ResourceId: pulumi.String("/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM"),
					Type:       pulumi.String(network.EndpointTypeAzureVM),
				},
				&network.ConnectionMonitorEndpointArgs{
					Address: pulumi.String("bing.com"),
					Name:    pulumi.String("bing"),
					Type:    pulumi.String(network.EndpointTypeExternalAddress),
				},
				&network.ConnectionMonitorEndpointArgs{
					Address: pulumi.String("google.com"),
					Name:    pulumi.String("google"),
					Type:    pulumi.String(network.EndpointTypeExternalAddress),
				},
				&network.ConnectionMonitorEndpointArgs{
					LocationDetails: &network.ConnectionMonitorEndpointLocationDetailsArgs{
						Region: pulumi.String("eastus"),
					},
					Name: pulumi.String("ArcBasedNetwork"),
					Scope: &network.ConnectionMonitorEndpointScopeArgs{
						Include: network.ConnectionMonitorEndpointScopeItemArray{
							&network.ConnectionMonitorEndpointScopeItemArgs{
								Address: pulumi.String("172.21.128.0/20"),
							},
						},
					},
					SubscriptionId: pulumi.String("9cece3e3-0f7d-47ca-af0e-9772773f90b7"),
					Type:           pulumi.String(network.EndpointTypeAzureArcNetwork),
				},
			},
			NetworkWatcherName: pulumi.String("nw1"),
			Outputs:            network.ConnectionMonitorOutputTypeArray{},
			ResourceGroupName:  pulumi.String("rg1"),
			TestConfigurations: network.ConnectionMonitorTestConfigurationArray{
				&network.ConnectionMonitorTestConfigurationArgs{
					Name:     pulumi.String("testConfig1"),
					Protocol: pulumi.String(network.ConnectionMonitorTestConfigurationProtocolTcp),
					TcpConfiguration: &network.ConnectionMonitorTcpConfigurationArgs{
						DisableTraceRoute: pulumi.Bool(false),
						Port:              pulumi.Int(80),
					},
					TestFrequencySec: pulumi.Int(60),
				},
			},
			TestGroups: network.ConnectionMonitorTestGroupArray{
				&network.ConnectionMonitorTestGroupArgs{
					Destinations: pulumi.StringArray{
						pulumi.String("bing"),
						pulumi.String("google"),
					},
					Disable: pulumi.Bool(false),
					Name:    pulumi.String("test1"),
					Sources: pulumi.StringArray{
						pulumi.String("vm1"),
						pulumi.String("ArcBasedNetwork"),
					},
					TestConfigurations: pulumi.StringArray{
						pulumi.String("testConfig1"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var connectionMonitor = new AzureNative.Network.ConnectionMonitor("connectionMonitor", new()
    {
        ConnectionMonitorName = "cm1",
        Endpoints = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Name = "vm1",
                ResourceId = "/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM",
                Type = AzureNative.Network.EndpointType.AzureVM,
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Address = "bing.com",
                Name = "bing",
                Type = AzureNative.Network.EndpointType.ExternalAddress,
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                Address = "google.com",
                Name = "google",
                Type = AzureNative.Network.EndpointType.ExternalAddress,
            },
            new AzureNative.Network.Inputs.ConnectionMonitorEndpointArgs
            {
                LocationDetails = new AzureNative.Network.Inputs.ConnectionMonitorEndpointLocationDetailsArgs
                {
                    Region = "eastus",
                },
                Name = "ArcBasedNetwork",
                Scope = new AzureNative.Network.Inputs.ConnectionMonitorEndpointScopeArgs
                {
                    Include = new[]
                    {
                        new AzureNative.Network.Inputs.ConnectionMonitorEndpointScopeItemArgs
                        {
                            Address = "172.21.128.0/20",
                        },
                    },
                },
                SubscriptionId = "9cece3e3-0f7d-47ca-af0e-9772773f90b7",
                Type = AzureNative.Network.EndpointType.AzureArcNetwork,
            },
        },
        NetworkWatcherName = "nw1",
        Outputs = new[] {},
        ResourceGroupName = "rg1",
        TestConfigurations = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestConfigurationArgs
            {
                Name = "testConfig1",
                Protocol = AzureNative.Network.ConnectionMonitorTestConfigurationProtocol.Tcp,
                TcpConfiguration = new AzureNative.Network.Inputs.ConnectionMonitorTcpConfigurationArgs
                {
                    DisableTraceRoute = false,
                    Port = 80,
                },
                TestFrequencySec = 60,
            },
        },
        TestGroups = new[]
        {
            new AzureNative.Network.Inputs.ConnectionMonitorTestGroupArgs
            {
                Destinations = new[]
                {
                    "bing",
                    "google",
                },
                Disable = false,
                Name = "test1",
                Sources = new[]
                {
                    "vm1",
                    "ArcBasedNetwork",
                },
                TestConfigurations = new[]
                {
                    "testConfig1",
                },
            },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.ConnectionMonitor;
import com.pulumi.azurenative.network.ConnectionMonitorArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointLocationDetailsArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorEndpointScopeArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTcpConfigurationArgs;
import com.pulumi.azurenative.network.inputs.ConnectionMonitorTestGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var connectionMonitor = new ConnectionMonitor("connectionMonitor", ConnectionMonitorArgs.builder()
            .connectionMonitorName("cm1")
            .endpoints(            
                ConnectionMonitorEndpointArgs.builder()
                    .name("vm1")
                    .resourceId("/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM")
                    .type("AzureVM")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .address("bing.com")
                    .name("bing")
                    .type("ExternalAddress")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .address("google.com")
                    .name("google")
                    .type("ExternalAddress")
                    .build(),
                ConnectionMonitorEndpointArgs.builder()
                    .locationDetails(ConnectionMonitorEndpointLocationDetailsArgs.builder()
                        .region("eastus")
                        .build())
                    .name("ArcBasedNetwork")
                    .scope(ConnectionMonitorEndpointScopeArgs.builder()
                        .include(ConnectionMonitorEndpointScopeItemArgs.builder()
                            .address("172.21.128.0/20")
                            .build())
                        .build())
                    .subscriptionId("9cece3e3-0f7d-47ca-af0e-9772773f90b7")
                    .type("AzureArcNetwork")
                    .build())
            .networkWatcherName("nw1")
            .outputs()
            .resourceGroupName("rg1")
            .testConfigurations(ConnectionMonitorTestConfigurationArgs.builder()
                .name("testConfig1")
                .protocol("Tcp")
                .tcpConfiguration(ConnectionMonitorTcpConfigurationArgs.builder()
                    .disableTraceRoute(false)
                    .port(80)
                    .build())
                .testFrequencySec(60)
                .build())
            .testGroups(ConnectionMonitorTestGroupArgs.builder()
                .destinations(                
                    "bing",
                    "google")
                .disable(false)
                .name("test1")
                .sources(                
                    "vm1",
                    "ArcBasedNetwork")
                .testConfigurations("testConfig1")
                .build())
            .build());

    }
}
resources:
  connectionMonitor:
    type: azure-native:network:ConnectionMonitor
    properties:
      connectionMonitorName: cm1
      endpoints:
        - name: vm1
          resourceId: /subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM
          type: AzureVM
        - address: bing.com
          name: bing
          type: ExternalAddress
        - address: google.com
          name: google
          type: ExternalAddress
        - locationDetails:
            region: eastus
          name: ArcBasedNetwork
          scope:
            include:
              - address: 172.21.128.0/20
          subscriptionId: 9cece3e3-0f7d-47ca-af0e-9772773f90b7
          type: AzureArcNetwork
      networkWatcherName: nw1
      outputs: []
      resourceGroupName: rg1
      testConfigurations:
        - name: testConfig1
          protocol: Tcp
          tcpConfiguration:
            disableTraceRoute: false
            port: 80
          testFrequencySec: 60
      testGroups:
        - destinations:
            - bing
            - google
          disable: false
          name: test1
          sources:
            - vm1
            - ArcBasedNetwork
          testConfigurations:
            - testConfig1

The ArcBasedNetwork endpoint uses type “AzureArcNetwork” and defines a scope with CIDR ranges. The locationDetails property specifies the Azure region for test execution. The subscriptionId property identifies which subscription contains the Arc-enabled infrastructure. This endpoint acts as a source, testing connectivity from the specified network segment to external destinations.

Beyond these examples

These snippets focus on specific Connection Monitor features: endpoint types (VMs, external addresses, workspaces, Arc networks), test configurations and protocols, and test groups linking sources to destinations. They’re intentionally minimal rather than full monitoring solutions.

The examples reference pre-existing infrastructure such as Network Watcher resources in the target region, VMs, Log Analytics workspaces or Arc-enabled infrastructure, and Azure Arc agents for Arc network endpoints. They focus on configuring the monitor rather than provisioning the underlying infrastructure.

To keep things focused, common monitoring patterns are omitted, including:

  • Output destinations (Log Analytics, Event Hub, Storage)
  • HTTP/ICMP protocol configurations
  • Success thresholds and alert conditions
  • Trace route and path analysis options

These omissions are intentional: the goal is to illustrate how each Connection Monitor feature is wired, not provide drop-in monitoring modules. See the Connection Monitor resource reference for all available configuration options.

Let's configure Azure Connection Monitors

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Endpoint Configuration
What types of endpoints can I monitor with Connection Monitor?

You can monitor four types of endpoints:

  1. Azure VMs - Use resourceId pointing to the VM
  2. External addresses - Use address with a hostname or IP
  3. Log Analytics workspaces - Use resourceId with optional agent filtering
  4. Azure Arc networks - Use type: AzureArcNetwork with scope and locationDetails
How do I set up monitoring from a VM to an external website?
Create two endpoints: one with your VM’s resourceId as the source, and another with the website’s address as the destination. Then create a testGroup that references both endpoint names and links them to a testConfiguration specifying the protocol and port.
How do I filter specific agents in a Log Analytics workspace endpoint?
Configure the endpoint’s filter property with items containing the agent address and type: AgentAddress, then set the filter’s type to Include.
How do I monitor Azure Arc-enabled networks?
Create an endpoint with type: AzureArcNetwork, specify the subscriptionId, define the network scope using scope.include with CIDR addresses, and set the locationDetails.region.
Test Configuration & Groups
How do test groups connect sources, destinations, and configurations?
Test groups reference endpoint names in their sources and destinations arrays, and test configuration names in their testConfigurations array. This links which endpoints to test and how to test them.
What's the default test frequency and how do I change it?
The default monitoring interval is 60 seconds, set via monitoringIntervalInSeconds. Individual test configurations can also specify testFrequencySec (shown as 60 in examples).
What protocols can I use for testing?
The examples show TCP protocol with tcpConfiguration specifying port and disableTraceRoute settings. Configure the protocol in testConfigurations.
Resource Management
What properties can't I change after creating a connection monitor?
Three properties are immutable: connectionMonitorName, networkWatcherName, and resourceGroupName.
Does the connection monitor start automatically after creation?
Yes, by default. The autoStart property defaults to true, but you can set it to false to prevent automatic startup.

Using a different cloud?

Explore monitoring guides for other cloud providers: