Skip to content

[App Config] az appconfig kv import: Support importing key-values from AKS ConfigMap#31861

Merged
yanzhudd merged 14 commits intoAzure:devfrom
RichardChen820:appconfig/import/configmap
Aug 25, 2025
Merged

[App Config] az appconfig kv import: Support importing key-values from AKS ConfigMap#31861
yanzhudd merged 14 commits intoAzure:devfrom
RichardChen820:appconfig/import/configmap

Conversation

@RichardChen820
Copy link
Copy Markdown
Member

@RichardChen820 RichardChen820 commented Jul 23, 2025

Related command
az appconfig kv import --source aks

Description
Support importing key-values from AKS ConfigMap to provide a better user experience for migrating to use AppConfiguration as centralized configuration management in AKS.

Testing Guide

  • Import from AKS by name
az appconfig kv import --source aks --aks-cluster <cluster-name> --configmap-name myconfigmap
  • Import key values from a configmap in a specific namespace from AKS by ARM ID and
az appconfig kv import --source aks --aks-cluster <cluster-resource-id> --configmap-name myconfigmap --configmap-namespace mynamespace
  • Import key values from a file-style configmap in a specific namespace with flattening.
az appconfig kv import --source aks --aks-cluster <clustername> --configmap-name myconfigmap --configmap-namespace mynamespace --format json --separator __

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 July 23, 2025 07:25
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jul 23, 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

Hi @RichardChen820,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

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

azure-client-tools-bot-prd bot commented Jul 23, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️appconfig
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd appconfig kv import cmd appconfig kv import added parameter aks_cluster
⚠️ 1006 - ParaAdd appconfig kv import cmd appconfig kv import added parameter configmap_name
⚠️ 1006 - ParaAdd appconfig kv import cmd appconfig kv import added parameter configmap_namespace
⚠️ 1010 - ParaPropUpdate appconfig kv import cmd appconfig kv import update parameter source: updated property choices from ['appconfig', 'appservice', 'file'] to ['aks', 'appconfig', 'appservice', 'file']

@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>

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 23, 2025

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

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 importing key-values from Azure Kubernetes Service (AKS) ConfigMaps to Azure App Configuration, providing a migration path for users wanting to centralize configuration management using App Configuration in AKS environments.

Key changes:

  • New import source 'aks' that retrieves ConfigMap data via AKS RunCommand API
  • Support for structured data formats (JSON, YAML, properties) with configurable flattening
  • Comprehensive parameter validation and error handling for AKS-specific arguments

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
keyvalue.py Adds AKS-specific parameters and integration with new ConfigMap reader function
_params.py Defines CLI parameters for AKS cluster, ConfigMap name, and namespace arguments
_validators.py Implements validation logic for AKS cluster identifiers and required parameters
_kv_import_helpers.py Core implementation for reading ConfigMap data via AKS RunCommand and data processing
_diff_utils.py Extends serializer support to include AKS as a valid source mode
_constants.py Adds AKS to the comparison fields mapping for import operations
test_appconfig_kv_import_export_commands.py Integration tests covering ConfigMap import scenarios and error handling
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_kv_import_export_commands.py:223

  • Commented out try statement should be removed as it serves no purpose and creates confusion about the intended error handling structure.
            'label': 'KeyValuesWithFeatures',

c.argument('appservice_account', validator=validate_appservice_name_or_id, help='ARM ID for AppService OR the name of the AppService, assuming it is in the same subscription and resource group as the App Configuration store. Required for AppService arguments')

with self.argument_context('appconfig kv import', arg_group='AKS') as c:
c.argument('aks_cluster', validator=validate_aks_cluster_name_or_id, help='ARM ID for AKS OR the name of the AKS, assuming it is in the same subscription and resource group as the App Configuration store. Required for AKS arguments'),
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

The help message should start with an active voice verb instead of a noun. Consider changing 'ARM ID for AKS...' to 'Specify ARM ID for AKS...' or 'Provide ARM ID for AKS...'

Copilot uses AI. Check for mistakes.

with self.argument_context('appconfig kv import', arg_group='AKS') as c:
c.argument('aks_cluster', validator=validate_aks_cluster_name_or_id, help='ARM ID for AKS OR the name of the AKS, assuming it is in the same subscription and resource group as the App Configuration store. Required for AKS arguments'),
c.argument('configmap_name', help='Name of the ConfigMap. Required for AKS arguments.')
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

The help message should start with an active voice verb instead of a noun. Consider changing 'Name of the ConfigMap...' to 'Specify name of the ConfigMap...' or 'Provide name of the ConfigMap...'

Copilot uses AI. Check for mistakes.
with self.argument_context('appconfig kv import', arg_group='AKS') as c:
c.argument('aks_cluster', validator=validate_aks_cluster_name_or_id, help='ARM ID for AKS OR the name of the AKS, assuming it is in the same subscription and resource group as the App Configuration store. Required for AKS arguments'),
c.argument('configmap_name', help='Name of the ConfigMap. Required for AKS arguments.')
c.argument('configmap_namespace', help='Namespace of the ConfigMap. default to "default" namespace if not specified.')
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

The help message should start with an active voice verb instead of a noun. Consider changing 'Namespace of the ConfigMap...' to 'Specify namespace of the ConfigMap...' or 'Provide namespace of the ConfigMap...'

Copilot uses AI. Check for mistakes.
Comment on lines +872 to +880
key_values = []
for k, v in flattened_data.items():
if validate_import_key(key=k):
key_values.append(KeyValue(key=k, value=v))
return key_values
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

This line resets the key_values list after accumulating values from previous iterations, causing data loss. This should either append to the existing list or be moved outside the loop.

Suggested change
key_values = []
for k, v in flattened_data.items():
if validate_import_key(key=k):
key_values.append(KeyValue(key=k, value=v))
return key_values
for k, v in flattened_data.items():
if validate_import_key(key=k):
key_values.append(KeyValue(key=k, value=v))

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

Choose a reason for hiding this comment

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

I agree with this comment . Moreover, should the return key_values line be unindented?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree, updated.

@RichardChen820 RichardChen820 force-pushed the appconfig/import/configmap branch from f2dc08d to a88288e Compare July 25, 2025 06:46
@RichardChen820 RichardChen820 force-pushed the appconfig/import/configmap branch from d06d232 to 692c843 Compare July 25, 2025 07:29
@yanzhudd yanzhudd changed the title [App Configuration] Add importing key-values from AKS ConfigMap [App Config] az appconfig kv import: Support importing key-values from AKS ConfigMap Aug 11, 2025
@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Copy Markdown
Contributor

please fix the CI issues.

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 31861 in repo Azure/azure-cli

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Aug 11, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@RichardChen820
Copy link
Copy Markdown
Member Author

@yonzhan What's the difference between the instances? https://dev.azure.com/azclitools/public/_build/results?buildId=265753&view=results

@RichardChen820
Copy link
Copy Markdown
Member Author

RichardChen820 commented Aug 14, 2025

@yanzhudd @yonzhan could you please re-run the ADO pipeline to check if the failure has been fixed?

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Aug 14, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@RichardChen820
Copy link
Copy Markdown
Member Author

@yanzhudd The test was supposed to be fixed, could you please do a favor to try it again?

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Aug 18, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@RichardChen820
Copy link
Copy Markdown
Member Author

@yonzhan @yanzhudd Sorry for not so familiar with the vcr test. Just fixed the error, could you please trigger it again? Hope it's the last try.

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Aug 18, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@RichardChen820
Copy link
Copy Markdown
Member Author

@yonzhan @yanzhudd I mark the test to run live only, it will not fail

@RichardChen820
Copy link
Copy Markdown
Member Author

@yonzhan @yanzhudd Could you please help trigger the ADO CI again?

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Aug 25, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@RichardChen820
Copy link
Copy Markdown
Member Author

@yonzhan @yanzhudd It passes, please review this PR

@yanzhudd yanzhudd merged commit be770fe into Azure:dev Aug 25, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS az aks/acs/openshift App Configuration Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants