How to automate packet capture ( Network Watcher)?

Gnanasekar M Dasarathan 1 Reputation point
2021-10-22T07:34:19.23+00:00

hi All,

I followed the document https://learn.microsoft.com/en-us/azure/network-watcher/network-watcher-alert-triggered-packet-capture

When I would like to 'Add PowerShell to the function' in that document, I'm getting below error

  1. I've replaced the relevant fields in the Powershell code and clicked 'Test/Run' and throws me below error 2021-10-22T07:28:59.636 [Error] Executed 'Functions.AlertPacketCapturePowershell' (Failed, Id=9ef9f06e-9f04-4175-8889-d7da57322bfc, Duration=2ms)Result: FailureException: No parameter defined in the script or function for the input binding 'Request'.Stack: at Microsoft.Azure.Functions.PowerShellWorker.AzFunctionInfo..ctor(RpcFunctionMetadata metadata) in /home/vsts/work/1/s/src/FunctionInfo.cs:line 131at Microsoft.Azure.Functions.PowerShellWorker.FunctionLoader.LoadFunction(FunctionLoadRequest request) in /home/vsts/work/1/s/src/FunctionLoader.cs:line 52at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessFunctionLoadRequest(StreamingMessage request) in /home/vsts/work/1/s/src/RequestProcessor.cs:line 222

I googled and observed few are suggested to decrease the run -time version to V1 from V3. I did it so [ not sure it's the right approach] and still getting below error

2021-10-22T07:37:44.761 [Error] Import-Module : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.at <ScriptBlock>, /AlertPacketCapturePowershell/azuremodules/Az.Accounts/Az.Accounts.psm1: line 117 at run.ps1: line 4+ Import-Module+ _____________+ CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
2021-10-22T07:37:46.386 [Error] Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.at run.ps1: line 31+ Connect-AzAccount+ _________________+ CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException+ FullyQualifiedErrorId : CommandNotFoundException
2021-10-22T07:37:46.417 [Error] Exception while executing function: Functions.AlertPacketCapturePowershell. Microsoft.Azure.WebJobs.Script: PowerShell script error. Microsoft.Azure.PowerShell.Authentication: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
2021-10-22T07:37:46.433 [Error] Function completed (Failure, Id=1881dcb2-012d-44ae-897c-31e68a606d8b, Duration=2459ms)
Any help is appreciated. Thanks in advance

Thanks,
Gnanasekar

Azure Network Watcher
Azure Network Watcher
An Azure service that is used to monitor, diagnose, and gain insights into network performance and health.
157 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 21,101 Reputation points MVP
    2021-10-22T13:00:36.96+00:00

    Hi,
    I would suggest to open GitHub issue for that specific document and report that the example is no longer working.

    0 comments No comments