-
Notifications
You must be signed in to change notification settings - Fork 467
Merge AppConfig key-value list and show into get #505
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
Merged
alzimmermsft
merged 13 commits into
microsoft:main
from
alzimmermsft:MergeAppConfigShowAndList
Oct 1, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5c47dce
Merge AppConfig key-value list and show into get
alzimmermsft cbaf519
Fix tests
alzimmermsft 24502af
Merge in main
alzimmermsft 9fa5596
Merge branch 'main' into MergeAppConfigShowAndList
alzimmermsft 37532f6
Few small fixes
alzimmermsft 48f5ac5
Fix validation
alzimmermsft d3c1119
Merge in main
alzimmermsft c34079c
Merge branch 'main' into MergeAppConfigShowAndList
alzimmermsft a470210
Merge in main
alzimmermsft 9362d0f
Merge branch 'main' into MergeAppConfigShowAndList
alzimmermsft 451ea56
Use new extension to retrieve value
alzimmermsft d0ece3d
Merge branch 'main' into MergeAppConfigShowAndList
alzimmermsft f439f7d
Merge branch 'main' into MergeAppConfigShowAndList
alzimmermsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
tools/Azure.Mcp.Tools.AppConfig/src/Commands/KeyValue/KeyValueGetCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Azure.Mcp.Core.Commands; | ||
| using Azure.Mcp.Core.Extensions; | ||
| using Azure.Mcp.Core.Models.Option; | ||
| using Azure.Mcp.Tools.AppConfig.Models; | ||
| using Azure.Mcp.Tools.AppConfig.Options; | ||
| using Azure.Mcp.Tools.AppConfig.Options.KeyValue; | ||
| using Azure.Mcp.Tools.AppConfig.Services; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Azure.Mcp.Tools.AppConfig.Commands.KeyValue; | ||
|
|
||
| public sealed class KeyValueGetCommand(ILogger<KeyValueGetCommand> logger) : BaseAppConfigCommand<KeyValueGetOptions>() | ||
| { | ||
| private const string CommandTitle = "Gets App Configuration Key-Value Settings"; | ||
| private readonly ILogger<KeyValueGetCommand> _logger = logger; | ||
|
|
||
| public override string Name => "get"; | ||
|
|
||
| public override string Description => | ||
| """ | ||
| Gets key-values in an App Configuration store. This command can either retrieve a specific key-value by its key | ||
| and optional label, or list key-values if no key is provided. Listing key-values can optionally be filtered by a | ||
| key filter and label filter. Each key-value includes its key, value, label, content type, ETag, last modified time, | ||
| and lock status. | ||
| """; | ||
|
|
||
| public override string Title => CommandTitle; | ||
|
|
||
| public override ToolMetadata Metadata => new() | ||
| { | ||
| Destructive = false, | ||
| Idempotent = true, | ||
| OpenWorld = false, | ||
| ReadOnly = true, | ||
| LocalRequired = false, | ||
| Secret = false | ||
| }; | ||
|
|
||
| protected override void RegisterOptions(Command command) | ||
| { | ||
| base.RegisterOptions(command); | ||
| command.Options.Add(AppConfigOptionDefinitions.Key.AsOptional()); | ||
| command.Options.Add(AppConfigOptionDefinitions.Label); | ||
| command.Options.Add(AppConfigOptionDefinitions.KeyFilter); | ||
| command.Options.Add(AppConfigOptionDefinitions.LabelFilter); | ||
| command.Validators.Add(result => | ||
| { | ||
| var key = result.GetValueOrDefault<string>(AppConfigOptionDefinitions.Key.Name); | ||
| var keyFilter = result.GetValueOrDefault(AppConfigOptionDefinitions.KeyFilter); | ||
| if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(keyFilter)) | ||
| { | ||
| result.AddError("Cannot specify both --key and --key-filter options together. Use only one to get a specific key-value or to filter the list of key-values."); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected override KeyValueGetOptions BindOptions(ParseResult parseResult) | ||
| { | ||
| var options = base.BindOptions(parseResult); | ||
| options.Key = parseResult.GetValueOrDefault<string>(AppConfigOptionDefinitions.Key.Name); | ||
| options.Label = parseResult.GetValueOrDefault<string>(AppConfigOptionDefinitions.Label.Name); | ||
| options.KeyFilter = parseResult.GetValueOrDefault<string>(AppConfigOptionDefinitions.KeyFilter.Name); | ||
| options.LabelFilter = parseResult.GetValueOrDefault<string>(AppConfigOptionDefinitions.LabelFilter.Name); | ||
| return options; | ||
| } | ||
|
|
||
| public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult) | ||
| { | ||
| if (!Validate(parseResult.CommandResult, context.Response).IsValid) | ||
| { | ||
| return context.Response; | ||
| } | ||
|
|
||
| var options = BindOptions(parseResult); | ||
|
|
||
| try | ||
| { | ||
| var appConfigService = context.GetService<IAppConfigService>(); | ||
| var settings = await appConfigService.GetKeyValues( | ||
| options.Account!, | ||
| options.Subscription!, | ||
| options.Key, | ||
| options.Label, | ||
| options.KeyFilter, | ||
| options.LabelFilter, | ||
| options.Tenant, | ||
| options.RetryPolicy); | ||
|
|
||
| context.Response.Results = ResponseResult.Create(new(settings ?? []), AppConfigJsonContext.Default.KeyValueGetCommandResult); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| _logger.LogError("An exception occurred processing command. Exception: {Exception}", ex); | ||
| HandleException(context, ex); | ||
| } | ||
|
|
||
| return context.Response; | ||
| } | ||
|
|
||
| internal record KeyValueGetCommandResult(List<KeyValueSetting> Settings); | ||
| } | ||
87 changes: 0 additions & 87 deletions
87
tools/Azure.Mcp.Tools.AppConfig/src/Commands/KeyValue/KeyValueListCommand.cs
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
tools/Azure.Mcp.Tools.AppConfig/src/Commands/KeyValue/KeyValueShowCommand.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.