Expand description
Configures Network Packet Capturing against a Virtual Machine using a Network Watcher.
§Example Usage
ⓘ
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let example = resource_group::create(
"example",
ResourceGroupArgs::builder()
.location("West Europe")
.name("example-resources")
.build_struct(),
);
let exampleAccount = account::create(
"exampleAccount",
AccountArgs::builder()
.account_replication_type("LRS")
.account_tier("Standard")
.location("${example.location}")
.name("examplesa")
.resource_group_name("${example.name}")
.build_struct(),
);
let exampleExtension = extension::create(
"exampleExtension",
ExtensionArgs::builder()
.auto_upgrade_minor_version(true)
.name("network-watcher")
.publisher("Microsoft.Azure.NetworkWatcher")
.type_("NetworkWatcherAgentLinux")
.type_handler_version("1.4")
.virtual_machine_id("${exampleVirtualMachine.id}")
.build_struct(),
);
let exampleNetworkInterface = network_interface::create(
"exampleNetworkInterface",
NetworkInterfaceArgs::builder()
.ip_configurations(
vec![
NetworkInterfaceIpConfiguration::builder().name("testconfiguration1")
.privateIpAddressAllocation("Dynamic")
.subnetId("${exampleSubnet.id}").build_struct(),
],
)
.location("${example.location}")
.name("example-nic")
.resource_group_name("${example.name}")
.build_struct(),
);
let exampleNetworkWatcher = network_watcher::create(
"exampleNetworkWatcher",
NetworkWatcherArgs::builder()
.location("${example.location}")
.name("example-nw")
.resource_group_name("${example.name}")
.build_struct(),
);
let examplePacketCapture = packet_capture::create(
"examplePacketCapture",
PacketCaptureArgs::builder()
.name("example-pc")
.network_watcher_id("${exampleNetworkWatcher.id}")
.storage_location(
PacketCaptureStorageLocation::builder()
.storageAccountId("${exampleAccount.id}")
.build_struct(),
)
.virtual_machine_id("${exampleVirtualMachine.id}")
.build_struct(),
);
let exampleSubnet = subnet::create(
"exampleSubnet",
SubnetArgs::builder()
.address_prefixes(vec!["10.0.2.0/24",])
.name("internal")
.resource_group_name("${example.name}")
.virtual_network_name("${exampleVirtualNetwork.name}")
.build_struct(),
);
let exampleVirtualMachine = virtual_machine::create(
"exampleVirtualMachine",
VirtualMachineArgs::builder()
.location("${example.location}")
.name("example-vm")
.network_interface_ids(vec!["${exampleNetworkInterface.id}",])
.os_profile(
VirtualMachineOsProfile::builder()
.adminPassword("Password1234!")
.adminUsername("testadmin")
.computerName("pctest-vm")
.build_struct(),
)
.os_profile_linux_config(
VirtualMachineOsProfileLinuxConfig::builder()
.disablePasswordAuthentication(false)
.build_struct(),
)
.resource_group_name("${example.name}")
.storage_image_reference(
VirtualMachineStorageImageReference::builder()
.offer("0001-com-ubuntu-server-jammy")
.publisher("Canonical")
.sku("22_04-lts")
.version("latest")
.build_struct(),
)
.storage_os_disk(
VirtualMachineStorageOsDisk::builder()
.caching("ReadWrite")
.createOption("FromImage")
.managedDiskType("Standard_LRS")
.name("osdisk")
.build_struct(),
)
.vm_size("Standard_F2")
.build_struct(),
);
let exampleVirtualNetwork = virtual_network::create(
"exampleVirtualNetwork",
VirtualNetworkArgs::builder()
.address_spaces(vec!["10.0.0.0/16",])
.location("${example.location}")
.name("example-network")
.resource_group_name("${example.name}")
.build_struct(),
);
}
NOTE: This Resource requires that the Network Watcher Virtual Machine Extension is installed on the Virtual Machine before capturing can be enabled which can be installed via the
azure.compute.Extension
resource.
§Import
Virtual Machine Packet Captures can be imported using the resource id
, e.g.
$ pulumi import azure:compute/packetCapture:PacketCapture capture1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkWatchers/watcher1/packetCaptures/capture1
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments