Skip to content

[Az.Network] Updated New-AzNetworkWatcherPacketCaptureV2 command and added a new sub command 'New-AzPacketCaptureSettingsConfig' for Network watcher Packet capture include ring buffer change. #27880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

v-sapanchal
Copy link
Contributor

Description

Modified the existing Packet capture command include ring buffer change, in order to that, created a new sub command for capture settings,
Example:
image
image

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/Network/Network/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@v-sapanchal v-sapanchal added this to the Az 14.2.0 (07/01/2025) milestone Jun 2, 2025
@v-sapanchal v-sapanchal marked this pull request as ready for review June 13, 2025 10:47
@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 10:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates the Packet Capture commands by introducing a new subcommand (New-AzPacketCaptureSettingsConfig) to encapsulate capture settings and by modifying New-AzNetworkWatcherPacketCaptureV2 to support ring buffer configurations via new parameters. Key changes include:

  • Adding a new cmdlet to generate capture settings objects.
  • Updating Packet Capture V2 to accept ContinuousCapture, CaptureSettings, and LocalPath parameters.
  • Adjusting help files, tests, and command mappings to incorporate the new functionality.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/StaticAnalysis/Exceptions/Az.Network/SignatureIssues.csv Updated signature exceptions for New-AzNetworkWatcherPacketCaptureV2 to flag naming convention issues.
tools/StaticAnalysis/Exceptions/Az.Network/ExampleIssues.csv Added new example entries for New-AzPacketCaptureSettingsConfig.
src/Network/Network/help/New-AzPacketCaptureSettingsConfig.md New help file documenting the new subcommand.
src/Network/Network/help/New-AzNetworkWatcherPacketCaptureV2.md Updated help file reflecting new parameters and example with ring buffer capture.
src/Network/Network/NetworkWatcher/PacketCapture/NewPacketCaptureSettingsCommand.cs New implementation for creating packet capture settings objects.
src/Network/Network/NetworkWatcher/PacketCapture/NewAzureNetworkWatcherPacketCaptureCommandV2.cs Modified to add support for ContinuousCapture, CaptureSettings, and LocalPath parameters.
src/Network/Network/Models/PSPacketCaptureSettings.cs New model supporting file count, file size, and session time limit settings.
src/Network/Network/ChangeLog.md Updated to mention new commands and parameter additions.
src/Network/Network/Az.Network.psd1 Updated command exports to include the new subcommand.
src/Network/Network.Test/ScenarioTests/NetworkWatcherAPITests.ps1 & cs Added tests validating the new capture settings functionality.
src/Accounts/Accounts/Utilities/CommandMappings.json Included the new command mapping for New-AzPacketCaptureSettingsConfig.
Comments suppressed due to low confidence (2)

tools/StaticAnalysis/Exceptions/Az.Network/SignatureIssues.csv:462

  • The exception message flags the 'CaptureSettings' parameter naming for New-AzNetworkWatcherPacketCaptureV2. Consider revising the parameter name to use a singular noun for consistency, or update the enforced naming convention if appropriate.
+"Az.Network","Microsoft.Azure.Commands.Network.NewAzureNetworkWatcherPacketCaptureCommandV2","New-AzNetworkWatcherPacketCaptureV2","1","8410","Parameter CaptureSettings of cmdlet New-AzNetworkWatcherPacketCaptureV2 does not follow the enforced naming convention of using a singular noun for a parameter name.","Consider using a singular noun for the parameter name."

src/Network/Network/NetworkWatcher/PacketCapture/NewAzureNetworkWatcherPacketCaptureCommandV2.cs:308

  • There is an inconsistency in parameter naming between 'LocalFilePath' and 'LocalPath'. Consolidate these names to a single consistent identifier to avoid confusion and improve clarity in both the cmdlet implementation and its documentation.
packetCaptureProperties.StorageLocation.FilePath = this.LocalFilePath;


[Parameter(
Mandatory = false,
HelpMessage = "Filters for packet capture session.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the description from swagger repo. Also mentions, only required when continous capture field is being set.

FileCount = 10,
FileSizeInBytes = 104857600,
SessionTimeLimitInSeconds = 86400
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to pass these default values ?
What if we don't pass captureSettings as well, this should be set at the server side, right ?

}
else
{
this.CaptureSettings.FileCount = this.CaptureSettings.FileCount ?? 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to set default value here, it should be taken care by server only, lets test this behavior once.
applicable to other fields as well.

this.CaptureSettings.FileSizeInBytes = this.CaptureSettings.FileSizeInBytes ?? 104857600;
this.CaptureSettings.SessionTimeLimitInSeconds = this.CaptureSettings.SessionTimeLimitInSeconds ?? 86400;

if (this.CaptureSettings.FileCount < 1 || this.CaptureSettings.FileCount > 10000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - lets do the validation before assignment,

base.Execute();

// Set default values if null
if (this.FileCount == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets check if we need to set default value here or not ?

[-Scope <PSPacketCaptureMachineScope>] [-TargetType <String>] [-Filter <PSPacketCaptureFilter[]>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-StorageAccountId <String>] [-StoragePath <String>] [-FilePath <String>] [-BytesToCapturePerPacket <Int32>]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FilePath -> LocalFilePath.

```

### SetByName
```
New-AzNetworkWatcherPacketCaptureV2 -NetworkWatcherName <String> -ResourceGroupName <String> -Name <String>
-TargetId <String> [-StorageAccountId <String>] [-StoragePath <String>] [-LocalFilePath <String>]
-TargetId <String> [-StorageAccountId <String>] [-StoragePath <String>] [-FilePath <String>]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LocalFilePath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line number 38 as well

@@ -242,6 +277,36 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -CaptureSettings
Filters for packet capture session.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the description. This is not filter, this is capture settings.
Update -> Capture Settings for packet capture session. Should only be provided when continous capture field is set.

### -LocalFilePath
Local file path.
### -LocalPath
This path is valid if 'ContinuousCapture' is provided and required if no storage ID is provided, otherwise optional. Must include the name of the capture file (*.cap).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can;t both storageId or local path be provided ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants