-
Notifications
You must be signed in to change notification settings - Fork 4k
[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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
There was a problem hiding this 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.")] |
There was a problem hiding this comment.
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 | ||
}; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>] |
There was a problem hiding this comment.
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>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalFilePath
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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 ?
Description
Modified the existing Packet capture command include ring buffer change, in order to that, created a new sub command for capture settings,


Example:
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.md
and reviewed the following information:ChangeLog.md
file(s) appropriatelysrc/Network/Network/ChangeLog.md
.## Upcoming Release
header in the past tense.ChangeLog.md
if no new release is required, such as fixing test case only.