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 reports on latency, packet loss, and reachability. This guide focuses on three capabilities: endpoint configuration, test configurations and protocols, and endpoint filtering for workspace agents.
Connection monitors belong to a Network Watcher resource and reference VMs, Log Analytics workspaces, or Arc-enabled networks as test sources. The examples are intentionally small. Combine them with your own Network Watcher, monitoring outputs, and alert rules.
Monitor connectivity between a VM and external endpoint
Most connectivity monitoring starts by verifying that VMs can reach external services like public APIs or websites.
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 monitor sends TCP probes from the source VM to the destination endpoint every 60 seconds. The endpoints array defines both source (by resourceId) and destination (by address). The testConfigurations array specifies protocol, port, and test frequency. The testGroups array connects sources to destinations using named test configurations.
Monitor from multiple sources with endpoint filtering
Larger deployments test connectivity from multiple sources, including VMs and Log Analytics workspace agents.
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
Endpoint filters target specific agents within a workspace by address. The filter property with type “Include” and items containing agent addresses selects which workspace agents participate. Test groups can reference multiple sources and destinations, creating a matrix of connectivity tests.
Test connectivity from Azure Arc network ranges
Hybrid environments with Azure Arc can monitor connectivity from on-premises network ranges without deploying agents to every machine.
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
Arc-based endpoints represent entire CIDR blocks rather than individual machines. The type property set to “AzureArcNetwork” enables this mode. The scope property with include items defines which network ranges participate. The locationDetails property specifies the Azure region for test execution.
Beyond these examples
These snippets focus on specific Connection Monitor features: endpoint types, test configurations and protocols, and endpoint filtering and scoping. They’re intentionally minimal rather than full monitoring solutions.
The examples reference pre-existing infrastructure such as Network Watcher resources in the target region, and VMs, Log Analytics workspaces, or Arc-enabled networks. 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 rules
- Notes and metadata tagging
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 FREEFrequently Asked Questions
Configuration & Immutability
connectionMonitorName, networkWatcherName, and resourceGroupName properties are immutable and cannot be changed after creation.autoStart property defaults to true, but you can set it to false if you want to start monitoring manually.monitoringIntervalInSeconds.Endpoints & Sources
You can monitor four endpoint types:
- Azure VMs - Use
resourceIdpointing to the VM - External addresses - Use
addresswith a hostname or IP - Log Analytics workspaces - Use
resourceIdwith optional agent filtering - Azure Arc networks - Use
type: AzureArcNetworkwithscopeandlocationDetails
resourceId as the source, and another with the external address (like bing.com) as the destination. Then link them in a testGroup.filter property with items specifying type: AgentAddress and the agent address to include, plus set type: Include on the filter.type: AzureArcNetwork, specify the subscriptionId, set locationDetails.region, and define the network scope with CIDR addresses to include.Test Configuration
testGroups to link source and destination endpoint names, then specify which testConfigurations to apply. Each test group can have multiple sources, destinations, and test configurations.testConfigurations with protocol: Tcp. Configure the tcpConfiguration with properties like port and disableTraceRoute.