-
Notifications
You must be signed in to change notification settings - Fork 254
Add Azure Table list back #743
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
Draft
alzimmermsft
wants to merge
13
commits into
microsoft:main
Choose a base branch
from
alzimmermsft:AddTablesBack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
841b54a
Add Azure Table list back
alzimmermsft 763c128
Run description evaluation
alzimmermsft 51141a0
Merge in main
alzimmermsft ada4342
Cleanup test-reousrces-post.ps1
alzimmermsft a7537de
Additional changes
alzimmermsft cf8aa18
Fix linting
alzimmermsft 8be661d
PR feedback
alzimmermsft f335b63
Support both Storage and Cosmos DB table listing
alzimmermsft eb14e02
Fix linting and tests
alzimmermsft db5428f
Fix CODEOWNERS
alzimmermsft 1575a8a
Description feedback
alzimmermsft 9bdef27
One more small cleanup
alzimmermsft c92f83f
Merge in main
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
3,194 changes: 1,669 additions & 1,525 deletions
3,194
eng/tools/ToolDescriptionEvaluator/results.md
Large diffs are not rendered by default.
Oops, something went wrong.
2,284 changes: 1,209 additions & 1,075 deletions
2,284
eng/tools/ToolDescriptionEvaluator/tools.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.5.2.0 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Mcp.Tools.Table", "src\Azure.Mcp.Tools.Table.csproj", "{B7A97E82-2E1D-BE3A-2A7C-A90F3165AACD}" | ||
| EndProject | ||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Mcp.Tools.Table.LiveTests", "tests\Azure.Mcp.Tools.Table.LiveTests\Azure.Mcp.Tools.Table.LiveTests.csproj", "{83DD8707-A48C-1D6B-0D9F-63BD93180599}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Mcp.Tools.Table.UnitTests", "tests\Azure.Mcp.Tools.Table.UnitTests\Azure.Mcp.Tools.Table.UnitTests.csproj", "{C0756D40-AADD-FDA6-49C2-973096FF795D}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {B7A97E82-2E1D-BE3A-2A7C-A90F3165AACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {B7A97E82-2E1D-BE3A-2A7C-A90F3165AACD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {B7A97E82-2E1D-BE3A-2A7C-A90F3165AACD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {B7A97E82-2E1D-BE3A-2A7C-A90F3165AACD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {83DD8707-A48C-1D6B-0D9F-63BD93180599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {83DD8707-A48C-1D6B-0D9F-63BD93180599}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {83DD8707-A48C-1D6B-0D9F-63BD93180599}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {83DD8707-A48C-1D6B-0D9F-63BD93180599}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {C0756D40-AADD-FDA6-49C2-973096FF795D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {C0756D40-AADD-FDA6-49C2-973096FF795D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {C0756D40-AADD-FDA6-49C2-973096FF795D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {C0756D40-AADD-FDA6-49C2-973096FF795D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(NestedProjects) = preSolution | ||
| {83DD8707-A48C-1D6B-0D9F-63BD93180599} = {0AB3BF05-4346-4AA6-1389-037BE0695223} | ||
| {C0756D40-AADD-FDA6-49C2-973096FF795D} = {0AB3BF05-4346-4AA6-1389-037BE0695223} | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {3BE8B60B-F7A1-4780-A64D-170B629FEF04} | ||
| EndGlobalSection | ||
| EndGlobal |
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,7 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| [assembly: InternalsVisibleTo("Azure.Mcp.Tools.Tables.UnitTests")] | ||
| [assembly: InternalsVisibleTo("Azure.Mcp.Tools.Tables.LiveTests")] |
20 changes: 20 additions & 0 deletions
20
tools/Azure.Mcp.Tools.Tables/src/Azure.Mcp.Tools.Tables.csproj
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,20 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <IsAotCompatible>true</IsAotCompatible> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <EmbeddedResource Include="**\Resources\*.txt" /> | ||
| <EmbeddedResource Include="**\Resources\*.json" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\..\core\Azure.Mcp.Core\src\Azure.Mcp.Core.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup /> | ||
| <ItemGroup> | ||
| <PackageReference Include="Azure.Data.Tables" /> | ||
| <PackageReference Include="Azure.ResourceManager" /> | ||
| <PackageReference Include="Microsoft.Extensions.DependencyInjection" /> | ||
| <PackageReference Include="ModelContextProtocol" /> | ||
| <PackageReference Include="System.CommandLine" /> | ||
| </ItemGroup> | ||
| </Project> |
42 changes: 42 additions & 0 deletions
42
tools/Azure.Mcp.Tools.Tables/src/Commands/BaseTablesCommand.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,42 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Azure.Mcp.Core.Commands; | ||
| using Azure.Mcp.Core.Commands.Subscription; | ||
| using Azure.Mcp.Core.Extensions; | ||
| using Azure.Mcp.Tools.Tables.Options; | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Commands; | ||
|
|
||
| public abstract class BaseTablesCommand<[DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] T> : SubscriptionCommand<T> | ||
| where T : BaseTablesOptions, new() | ||
| { | ||
| protected override void RegisterOptions(Command command) | ||
| { | ||
| base.RegisterOptions(command); | ||
| command.Options.Add(TablesOptionDefinitions.Account); | ||
| command.Options.Add(TablesOptionDefinitions.CosmosDbAccount); | ||
| command.Validators.Add(commandResult => | ||
| { | ||
| var storageAccount = commandResult.GetValueOrDefault<string>(TablesOptionDefinitions.Account.Name); | ||
| var cosmosDbAccount = commandResult.GetValueOrDefault<string>(TablesOptionDefinitions.CosmosDbAccount.Name); | ||
| if (string.IsNullOrWhiteSpace(storageAccount) && string.IsNullOrWhiteSpace(cosmosDbAccount)) | ||
| { | ||
| commandResult.AddError($"One of --{TablesOptionDefinitions.StorageAccountName} or --{TablesOptionDefinitions.CosmosDbAccountName} must be provided."); | ||
| } | ||
| else if (!string.IsNullOrWhiteSpace(storageAccount) && !string.IsNullOrWhiteSpace(cosmosDbAccount)) | ||
| { | ||
| commandResult.AddError($"Only one of --{TablesOptionDefinitions.StorageAccountName} or --{TablesOptionDefinitions.CosmosDbAccountName} can be provided."); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected override T BindOptions(ParseResult parseResult) | ||
| { | ||
| var options = base.BindOptions(parseResult); | ||
| options.StorageAccount = parseResult.GetValueOrDefault<string>(TablesOptionDefinitions.Account.Name); | ||
| options.CosmosDbAccount = parseResult.GetValueOrDefault<string>(TablesOptionDefinitions.CosmosDbAccount.Name); | ||
| return options; | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
tools/Azure.Mcp.Tools.Tables/src/Commands/TablesJsonContext.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,12 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Commands; | ||
|
|
||
| [JsonSerializable(typeof(TablesListCommand.TablesListCommandResult))] | ||
| [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault)] | ||
| internal sealed partial class TablesJsonContext : JsonSerializerContext | ||
| { | ||
| } |
65 changes: 65 additions & 0 deletions
65
tools/Azure.Mcp.Tools.Tables/src/Commands/TablesListCommand.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,65 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Azure.Mcp.Core.Commands; | ||
| using Azure.Mcp.Tools.Tables.Options; | ||
| using Azure.Mcp.Tools.Tables.Services; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Commands; | ||
|
|
||
| public sealed class TablesListCommand(ILogger<TablesListCommand> logger) : BaseTablesCommand<TablesListOptions>() | ||
| { | ||
| private const string CommandTitle = "List Azure Table storage tables"; | ||
alzimmermsft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private readonly ILogger<TablesListCommand> _logger = logger; | ||
|
|
||
| public override string Name => "list"; | ||
|
|
||
| public override string Description => "List all tables in a Storage or Cosmos DB account."; | ||
|
|
||
| public override string Title => CommandTitle; | ||
|
|
||
| public override ToolMetadata Metadata => new() | ||
| { | ||
| Destructive = false, | ||
| Idempotent = true, | ||
| OpenWorld = false, | ||
| ReadOnly = true, | ||
| LocalRequired = false, | ||
| Secret = false | ||
| }; | ||
|
|
||
| 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 account = options.StorageAccount ?? options.CosmosDbAccount; | ||
| var tablesService = context.GetService<ITablesService>(); | ||
| var tables = await tablesService.ListTables( | ||
| account!, | ||
| !string.IsNullOrWhiteSpace(options.CosmosDbAccount), | ||
| options.Subscription!, | ||
| options.Tenant, | ||
| options.RetryPolicy); | ||
|
|
||
| context.Response.Results = ResponseResult.Create(new(tables ?? []), TablesJsonContext.Default.TablesListCommandResult); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| _logger.LogError(ex, "Error listing tables. StorageAccount: {StorageAccount}, CosmosDbAccount: {CosmosDbAccount}.", | ||
| options.StorageAccount, options.CosmosDbAccount); | ||
| HandleException(context, ex); | ||
| } | ||
|
|
||
| return context.Response; | ||
| } | ||
|
|
||
| internal record TablesListCommandResult(List<string> Tables); | ||
| } | ||
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,5 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| global using System.CommandLine; | ||
| global using Azure.Mcp.Core.Models.Command; |
12 changes: 12 additions & 0 deletions
12
tools/Azure.Mcp.Tools.Tables/src/Options/BaseTablesOptions.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,12 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Azure.Mcp.Core.Options; | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Options; | ||
|
|
||
| public class BaseTablesOptions : SubscriptionOptions | ||
| { | ||
| public string? StorageAccount { get; set; } | ||
| public string? CosmosDbAccount { get; set; } | ||
| } |
6 changes: 6 additions & 0 deletions
6
tools/Azure.Mcp.Tools.Tables/src/Options/TablesListOptions.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,6 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Options; | ||
|
|
||
| public class TablesListOptions : BaseTablesOptions; |
20 changes: 20 additions & 0 deletions
20
tools/Azure.Mcp.Tools.Tables/src/Options/TablesOptionDefinitions.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,20 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Options; | ||
|
|
||
| public static class TablesOptionDefinitions | ||
| { | ||
| public const string StorageAccountName = "storage-account"; | ||
| public const string CosmosDbAccountName = "cosmosdb-account"; | ||
|
|
||
| public static readonly Option<string> Account = new($"--{StorageAccountName}") | ||
| { | ||
| Description = "The name of the Azure Storage account (e.g., 'mystorageaccount').", | ||
| }; | ||
|
|
||
| public static readonly Option<string> CosmosDbAccount = new($"--{CosmosDbAccountName}") | ||
| { | ||
| Description = "The name of the Cosmos DB account (e.g., 'mycosmosdbaccount').", | ||
| }; | ||
| } |
16 changes: 16 additions & 0 deletions
16
tools/Azure.Mcp.Tools.Tables/src/Services/ITablesService.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,16 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Azure.Mcp.Core.Options; | ||
|
|
||
| namespace Azure.Mcp.Tools.Tables.Services; | ||
|
|
||
| public interface ITablesService | ||
| { | ||
| Task<List<string>> ListTables( | ||
| string account, | ||
| bool isCosmosDb, | ||
| string subscription, | ||
| string? tenant = null, | ||
| RetryPolicyOptions? retryPolicy = null); | ||
| } |
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.