summary import { PacketCapture , NetworkManagementClient } from "@msinternal/network-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createPacketCapture ( ) { const subscriptionId = "subid" ; const resourceGroupName = "rg1" ; const networkWatcherName = "nw1" ; const packetCaptureName = "pc1" ; const parameters = { bytesToCapturePerPacket : 10000 , filters : [ { localIPAddress : "10.0.0.4" , localPort : "80" , protocol : "TCP" } ] , storageLocation : { filePath : "D:capturepc1.cap" , storageId : "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Storage/storageAccounts/pcstore" , storagePath : "https://mytestaccountname.blob.core.windows.net/capture/pc1.cap" } , target : "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1" , timeLimitInSeconds : 100 , totalBytesPerSession : 100000 } ; const credential = new DefaultAzureCredential ( ) ; const client = new NetworkManagementClient ( credential , subscriptionId ) ; const result = await client . packetCaptures . beginCreateAndWait ( resourceGroupName , networkWatcherName , packetCaptureName , parameters ) ; console . log ( result ) ; } createPacketCapture ( ) . catch ( console . error ) ;