Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class FeatureFlag:
The list of variants defined for this feature.
:ivar dict {string, object} telemetry:
The declaration of options used to configure telemetry for this feature.
:ivar dict tags:
Tags associated with the feature flag.
"""

def __init__(
Expand All @@ -151,6 +153,7 @@ def __init__(
allocation=None,
variants=None,
telemetry=None,
tags=None
):
self.name = name
self.key = key
Expand All @@ -165,6 +168,7 @@ def __init__(
self.variants = variants
self.telemetry = telemetry
self.display_name = display_name
self.tags = tags

def __repr__(self):
featureflag = {
Expand All @@ -180,7 +184,8 @@ def __repr__(self):
"Allocation": custom_serialize_allocation(self.allocation),
"Variants": custom_serialize_variants(self.variants),
"Telemetry": custom_serialize_telemetry(self.telemetry),
"Display Name": self.display_name
"Display Name": self.display_name,
"Tags": self.tags
}

return json.dumps(featureflag, indent=2, ensure_ascii=False)
Expand Down Expand Up @@ -803,7 +808,8 @@ def map_keyvalue_to_featureflag(keyvalue, show_all_details=True, hide_enabled=Tr
last_modified=keyvalue.last_modified,
allocation=feature_flag_value.allocation,
variants=feature_flag_value.variants,
telemetry=feature_flag_value.telemetry
telemetry=feature_flag_value.telemetry,
tags=keyvalue.tags
)

# By Default, we will try to show conditions unless the user has
Expand Down
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appconfig/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@
- name: Set a feature flag with name "Beta" and custom key ".appconfig.featureflag/MyApp1:Beta".
text:
az appconfig feature set -n MyAppConfiguration --feature Beta --key .appconfig.featureflag/MyApp1:Beta
- name: Set a feature flag with name "Beta" and custom key ".appconfig.featureflag/MyApp1:Beta" with tags "tag1=value1" and "tag2=value2".
Comment thread
ChristineWanjau marked this conversation as resolved.
text:
az appconfig feature set -n MyAppConfiguration --feature Beta --key .appconfig.featureflag/MyApp1:Beta --tags tag1=value1 tag2=value2
"""

helps['appconfig feature delete'] = """
Expand All @@ -455,6 +458,9 @@
- name: Delete a feature whose name is "Beta" but key is ".appconfig.featureflag/MyApp1:Beta".
text:
az appconfig feature delete -n MyAppConfiguration --key .appconfig.featureflag/MyApp1:Beta --yes
- name: Delete a feature whose name is "Beta" but key is ".appconfig.featureflag/MyApp1:Beta" with tags "tag1=value1" and "tag2=value2".
Comment thread
ChristineWanjau marked this conversation as resolved.
text:
az appconfig feature delete -n MyAppConfiguration --key .appconfig.featureflag/MyApp1:Beta --tags tag1=value1 tag2=value2 --yes
"""

helps['appconfig feature show'] = """
Expand Down Expand Up @@ -500,6 +506,12 @@
- name: List all features starting with "MyApp1".
text:
az appconfig feature list -n MyAppConfiguration --key .appconfig.featureflag/MyApp1*
- name: List all feature flags with specific tags.
text:
az appconfig feature list -n MyAppConfiguration --tags tag1=value1 tag2=value2
- name: List all feature flags with tag name "tag1" with empty value.
text:
az appconfig feature list -n MyAppConfiguration --tags tag1=
"""

helps['appconfig feature lock'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,21 @@ def load_arguments(self, _):
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. Default key is the reserved prefix ".appconfig.featureflag/" + feature name.')
c.argument('requirement_type', arg_type=get_enum_type([FeatureFlagConstants.REQUIREMENT_TYPE_ALL, FeatureFlagConstants.REQUIREMENT_TYPE_ANY]),
help='Requirement type determines if filters should use "Any" or "All" logic when evaluating the state of a feature.')
c.argument('tags', arg_type=tags_type)

with self.argument_context('appconfig feature delete') as c:
c.argument('feature', help='Name of the feature to be deleted. If the feature flag key is different from the default key, provide the `--key` argument instead. Support star sign as filters, for instance * means all features and abc* means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
c.argument('label', help="If no label specified, delete the feature flag with null label by default. Support star sign as filters, for instance * means all labels and abc* means labels with abc as prefix.")
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. If both key and feature arguments are provided, only key will be used. Support star sign as filters, for instance ".appconfig.featureflag/*" means all features and ".appconfig.featureflag/abc*" means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
c.argument('tags', arg_type=tags_arg_type, help="If no tags are specified, delete all feature flags with any tags. Support space-separated tags: key[=value] [key[=value] ...].")

with self.argument_context('appconfig feature list') as c:
c.argument('feature', help='Name of the feature to be listed. If the feature flag key is different from the default key, provide the `--key` argument instead. Support star sign as filters, for instance * means all features and abc* means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
c.argument('label', help="If no label specified, list all labels. Support star sign as filters, for instance * means all labels and abc* means labels with abc as prefix. Use '\\0' for null label.")
c.argument('fields', arg_type=feature_fields_arg_type)
c.argument('all_', help="List all feature flags.")
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. If both key and feature arguments are provided, only key will be used. Support star sign as filters, for instance ".appconfig.featureflag/*" means all features and ".appconfig.featureflag/abc*" means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
c.argument('tags', arg_type=tags_arg_type, help="If no tags are specified, list all feature flags with any tags. Support space-separated tags: key[=value] [key[=value] ...].")

with self.argument_context('appconfig feature lock') as c:
c.argument('feature', help='Name of the feature to be locked. If the feature flag key is different from the default key, provide the `--key` argument instead.')
Expand Down
19 changes: 12 additions & 7 deletions src/azure-cli/azure/cli/command_modules/appconfig/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def set_feature(cmd,
yes=False,
connection_string=None,
auth_mode="key",
endpoint=None):
endpoint=None,
tags=None):
if key is None and feature is None:
raise CLIErrors.RequiredArgumentMissingError("Please provide either `--key` or `--feature` value.")

Expand All @@ -67,7 +68,6 @@ def set_feature(cmd,
raise exception

# when creating a new Feature flag, these defaults will be used
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

Consider initializing tags to an empty dictionary (e.g. 'tags = {}') if not provided, to ensure that FeatureFlag objects consistently represent tags as a dictionary instead of null.

Copilot uses AI. Check for mistakes.
tags = {}
default_conditions = {FeatureFlagConstants.CLIENT_FILTERS: []}

if requirement_type:
Expand Down Expand Up @@ -145,6 +145,7 @@ def set_feature(cmd,

# Convert KeyValue object to required FeatureFlag format for
# display

feature_flag = map_keyvalue_to_featureflag(set_kv, show_all_details=True)
entry = json.dumps(feature_flag, default=lambda o: o.__dict__, indent=2, sort_keys=True, ensure_ascii=False)

Expand Down Expand Up @@ -185,7 +186,8 @@ def delete_feature(cmd,
yes=False,
connection_string=None,
auth_mode="key",
endpoint=None):
endpoint=None,
tags=None):
if key is None and feature is None:
raise CLIErrors.RequiredArgumentMissingError("Please provide either `--key` or `--feature` value.")
if key and feature:
Expand All @@ -204,9 +206,10 @@ def delete_feature(cmd,
retrieved_keyvalues = __list_all_keyvalues(azconfig_client,
key_filter=key_filter,
label=SearchFilterOptions.EMPTY_LABEL if label is None else label,
correlation_request_id=correlation_request_id)
correlation_request_id=correlation_request_id,
tags=tags)

confirmation_message = "Found '{}' feature flags matching the specified feature and label. Are you sure you want to delete these feature flags?".format(len(retrieved_keyvalues))
confirmation_message = "Found '{}' feature flags matching the specified feature, label, and tags. Are you sure you want to delete these feature flags?".format(len(retrieved_keyvalues))
user_confirmation(confirmation_message, yes)

deleted_kvs = []
Expand Down Expand Up @@ -304,7 +307,8 @@ def list_feature(cmd,
top=None,
all_=False,
auth_mode="key",
endpoint=None):
endpoint=None,
tags=None):
return __list_features(
cmd=cmd,
feature=feature,
Expand All @@ -316,7 +320,8 @@ def list_feature(cmd,
top=top,
all_=all_,
auth_mode=auth_mode,
endpoint=endpoint
endpoint=endpoint,
tags=tags
)


Expand Down
Loading
Loading