Skip to content

[App Config] az appconfig kv set/import: Add support for JSON comments#32130

Merged
zhoxing-ms merged 17 commits intoAzure:devfrom
albertofori:albertofori/strip_comments
Sep 29, 2025
Merged

[App Config] az appconfig kv set/import: Add support for JSON comments#32130
zhoxing-ms merged 17 commits intoAzure:devfrom
albertofori:albertofori/strip_comments

Conversation

@albertofori
Copy link
Copy Markdown
Contributor

@albertofori albertofori commented Sep 17, 2025

Related command

appconfig kv set
appconfig kv import

Description

Adds support for stripping comments when writing a kv which is of json content type and might have comments. This is also done for import from a json file.

Testing Guide

History Notes

{App Config} az appconfig kv set/import: Add support for JSON comments


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

Copilot AI review requested due to automatic review settings September 17, 2025 02:23
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Sep 17, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

azure-client-tools-bot-prd bot commented Sep 17, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Sep 17, 2025

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

@github-actions
Copy link
Copy Markdown

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>

Copy link
Copy Markdown
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

This PR adds support for stripping JSON comments when setting or importing key-value pairs with JSON content type in Azure App Configuration. The enhancement allows JSON with both single-line (//) and multi-line (/* */) comments to be processed by automatically stripping the comments before validation and storage.

  • Implements a strip_json_comments utility function to remove comments from JSON strings
  • Modifies the key-value set operation to strip comments when JSON validation fails initially
  • Updates the import functionality to handle JSON files containing comments

Reviewed Changes

Copilot reviewed 7 out of 32 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test_appconfig_json_content_type.py Adds unit tests for JSON comment stripping functionality
test_azconfig_user_token_audience.yaml Updates test recording with new timestamps and configuration
json_with_comments_stripped.json Test fixture containing clean JSON without comments
json_with_comments.json Test fixture containing JSON with both single-line and multi-line comments
keyvalue.py Adds __normalize_json_input function to handle JSON comment stripping during kv set operations
_utils.py Implements the core strip_json_comments function with comment removal logic
_kv_import_helpers.py Updates JSON file parsing to support comments during import operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
@albertofori albertofori requested a review from Copilot September 17, 2025 23:17
Copy link
Copy Markdown
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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated

return index

def __find_next_double_quote_index(json_string, start_index):
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

These helper functions lack docstrings explaining their parameters, return values, and potential exceptions. Add comprehensive docstrings for better code documentation.

Copilot uses AI. Check for mistakes.
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
@albertofori albertofori requested a review from Copilot September 19, 2025 19:11
Copy link
Copy Markdown
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

Copilot reviewed 7 out of 32 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_kv_import_helpers.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/appconfig/_utils.py Outdated
@ChristineWanjau
Copy link
Copy Markdown
Contributor

Just curious, in portal we don't allow comments for key-vault reference, AI config and Feature flags do we do the same for CLI?

@albertofori
Copy link
Copy Markdown
Contributor Author

Just curious, in portal we don't allow comments for key-vault reference, AI config and Feature flags do we do the same for CLI?

Good call out. This has been updated to exclude KeyVault refs, feature flags and AI Config as is in portal. Kindly let me know if I am missing any other content type.

Thanks!

Comment thread src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py Outdated
@albertofori
Copy link
Copy Markdown
Contributor Author

albertofori commented Sep 25, 2025

@zhoxing-ms , @yanzhudd , Could you please take a look at this PR and help merge it. We would want this to go with the current release window

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd changed the title {AppConfig} az appconfig kv set/import: Add support for JSON comments {App Config} az appconfig kv set/import: Add support for JSON comments Sep 29, 2025
@yanzhudd
Copy link
Copy Markdown
Contributor

License check: @microsoft-github-policy-service rerun

@albertofori
Copy link
Copy Markdown
Contributor Author

albertofori commented Sep 29, 2025

Hi @yanzhudd ,

Please I just pushed the change to add the license text at the beginning of the new file. Thanks!

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@zhoxing-ms zhoxing-ms changed the title {App Config} az appconfig kv set/import: Add support for JSON comments [App Config] az appconfig kv set/import: Add support for JSON comments Sep 29, 2025
@zhoxing-ms zhoxing-ms merged commit 94bf940 into Azure:dev Sep 29, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants