Skip to content

Conversation

@nikhilpadhye1
Copy link
Contributor


This adds the packet capture operation for azure firewall. Enabling support for start/status/stop packet capture. This feature is looking to be taken to GA in the coming weeks. Used the UI to generate the command as per the rest-api spec and added descriptions and tests to ensure functionality.

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az network azure-firewall packetcaptureoperation

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 14:54
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Oct 7, 2025

⚠️Azure CLI Extensions Breaking Change Test
⚠️azure-firewall
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd network azure-firewall sub group network azure-firewall added

@azure-client-tools-bot-prd
Copy link

Hi @nikhilpadhye1,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 7, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

Copy link
Contributor

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

Adds Azure Firewall packet capture command supporting start, status, and stop operations, along with associated test coverage and a raised minimum CLI core version.

  • Introduces new command: network azure-firewall packet-capture-operation
  • Adds end-to-end scenario test for packet capture
  • Updates extension minimum CLI core version to 2.75.0

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
azext_firewall/tests/latest/test_azure_firewall_scenario.py Adds scenario test for packet capture (start/status/stop) workflow.
azext_firewall/azext_metadata.json Raises required az cli core version.
aaz/latest/network/azure_firewall/_packet_capture_operation.py Implements the new packet capture operation command.
aaz/latest/network/azure_firewall/init.py Exposes new command module.
aaz/latest/network/azure_firewall/__cmd_group.py Command group definition (no functional logic change).

self.cmd('storage account create -g {rg} -n {storageaccountname} --sku Standard_LRS --https-only true --kind StorageV2 --access-tier Hot')
self.cmd('storage container create -n {containername} --account-name {storageaccountname} --public-access off')
storage_account = self.cmd('az storage account show -g {rg} -n {storageaccountname}').get_output_in_json()
sas_response = self.cmd('az storage container generate-sas --account-name {storageaccountname} --name {containername} --permissions acdlrw --expiry {expirystring}').get_output_in_json()
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

generate-sas returns a SAS token string (TSV/plain) rather than JSON; using get_output_in_json() will fail to parse. Use .output (optionally with -o tsv) and avoid JSON parsing, e.g. self.cmd('... -o tsv').output.strip().

Suggested change
sas_response = self.cmd('az storage container generate-sas --account-name {storageaccountname} --name {containername} --permissions acdlrw --expiry {expirystring}').get_output_in_json()
sas_response = self.cmd('az storage container generate-sas --account-name {storageaccountname} --name {containername} --permissions acdlrw --expiry {expirystring}').output.strip()

Copilot uses AI. Check for mistakes.
'rg' : resource_group,
'sub_id': "020a3f33-bdd2-4ddc-9275-6041363e2876",
'location': "centralus",
'storageaccountname': f"azfwcontainerpcaptestcli",
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Storage account names must be globally unique; this hard-coded value increases risk of collisions/flaky tests in parallel runs. Recommend generate a randomized name (e.g. self.create_random_name('fwpcap', 20).lower()) and ensure it meets naming constraints.

Suggested change
'storageaccountname': f"azfwcontainerpcaptestcli",
'storageaccountname': self.create_random_name('fwpcap', 20).lower(),

Copilot uses AI. Check for mistakes.
"public_ip_name": self.create_random_name("public-ip-", 16),
"m_public_ip_name": self.create_random_name("mpublic-ip-", 16),
'rg' : resource_group,
'sub_id': "020a3f33-bdd2-4ddc-9275-6041363e2876",
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Hard-coded subscription ID is not used elsewhere in this test function and can cause confusion; remove it or reference the dynamic test subscription if needed (e.g. self.get_subscription_id()).

Suggested change
'sub_id': "020a3f33-bdd2-4ddc-9275-6041363e2876",

Copilot uses AI. Check for mistakes.
_aaz_info = {
"version": "2024-10-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/azurefirewalls/{}/packetcaptureoperation", "2024-10-01"],
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Resource path casing in _aaz_info differs from the actual request URL (resourcegroups vs resourceGroups, microsoft.network vs Microsoft.Network, azurefirewalls vs azureFirewalls, packetcaptureoperation vs packetCaptureOperation). This inconsistency can break tooling relying on _aaz_info for resource ID normalization; align casing with the canonical path used in the request (line 206).

Suggested change
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/azurefirewalls/{}/packetcaptureoperation", "2024-10-01"],
["mgmt-plane", "/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/azureFirewalls/{}/packetCaptureOperation", "2024-10-01"],

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should i make this change?

_args_schema.sas_url = AAZStrArg(
options=["--sas-url"],
arg_group="Parameters",
help="Upload capture location",
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Help text for --sas-url is vague; clarify it (e.g. 'SAS URL of the destination blob container where the packet capture file will be uploaded').

Suggested change
help="Upload capture location",
help="SAS URL of the destination blob container where the packet capture file will be uploaded.",

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Hi @nikhilpadhye1

⚠️ Release Requirements

Module: azure-firewall

  • ⚠️ Please update VERSION to be 1.6.0 in src/azure-firewall/setup.py

Notes

@github-actions github-actions bot added the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Oct 8, 2025
@necusjz necusjz added skip-cal-version and removed release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. labels Oct 8, 2025
@necusjz
Copy link
Member

necusjz commented Oct 8, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants