Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Conversation

@jongio
Copy link
Member

@jongio jongio commented Jun 9, 2025

Adding first Azure SQL command that will be useful for developers wanting to improve their SQL implementation.

User Scenario: "help me optimize my azure sql db"

This tool will return optimization recommendations from sql advisor.

@joshfree joshfree moved this from Untriaged to In Progress in Azure MCP Server (OLD) Jun 10, 2025
@joshfree joshfree added this to the 2025-06 milestone Jun 10, 2025
@xiangyan99
Copy link
Member

Please also update docs/azmcp-commands.md.

Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Looks good overall - just a few low priority comments. Main comment is around whether or not we need to re-expose types for the command results vs leveraging existing objects from the SDKs. Are we trimming down the amount of data or other reasons?

Copy link
Member

@anuchandy anuchandy left a comment

Choose a reason for hiding this comment

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

LGTM, ty!

{
DatabaseNotFoundException => "Database not found. Verify the database exists and you have access.",
_ => base.GetErrorMessage(ex)
}; internal record DbAdviseCommandResult(SqlAnalysisResult Analysis) : IDbAdviseCommandResult
Copy link
Member

Choose a reason for hiding this comment

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

nit; should this record definition be in a new line?

var patterns = new[]
{
@"ON\s+\[?([^\]\s\[]+)\]?\.\[?([^\]\s\[]+)\]?", // ON [schema].[table] or ON schema.table
@"ON\s+\[?([^\]\s\[]+)\]?(?!\s*\.)", // ON [table] (without schema)
Copy link
Member

Choose a reason for hiding this comment

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

In Java, we try to compile the regex upfront so it can help with perf.

Reading the doc, .NET seems to have similar concept https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators#compiled-regular-expressions, so we could avoid runtime regx compilation (and is AOT friendly).

    // / ON [schema].[table] or ON schema.table
    [GeneratedRegex(@"ON\s+\[?([^\]\s\[]+)\]?\.\[?([^\]\s\[]+)\]?",  RegexOptions.IgnoreCase)]
    private static partial Regex NameFromTableSchemaRegex();
    
   // // ON [table] (without schema)
    [GeneratedRegex(@"ON\s+\[?([^\]\s\[]+)\]?(?!\s*\.)",  RegexOptions.IgnoreCase)]
    private static partial Regex NameFromTableOnlyRegex();
var match = NameFromTableSchemaRegex().Match(sql);
// rest is the same code.

@jongio
Copy link
Member Author

jongio commented Jun 13, 2025

We are waiting for a db to be available that has auto tuning recommendations so we can test this. It takes 7 days for a db to show auto-tuning recommendations, so we'll verify it next week.

jongio added 6 commits June 16, 2025 09:48
…ex recommendations

- Introduced new SQL command groups for managing Azure SQL resources.
- Added commands for listing SQL servers and databases.
- Implemented index recommendation functionality with appropriate options.
- Created base command classes for SQL operations to streamline command creation.
- Enhanced error handling for SQL operations with custom exceptions.
- Updated documentation to reflect new command structure and usage.
- Added unit tests for SQL index recommendation command to ensure functionality.
… handling in SqlService; add unit tests for SQL service functionality
jongio and others added 23 commits June 16, 2025 09:48
…g SQL servers and databases; add SqlAuthorizationException for error handling
…Command and BaseServerCommand; update index recommendation logic and options handling
…ance index recommendation command with tenant support
…structure and additional metadata; update related commands and tests
- Removed the SqlIndexRecommendCommand and its associated tests.
- Introduced DbAdviseCommand to provide SQL database advisor recommendations.
- Updated CommandFactory to register new Db commands and removed obsolete index commands.
- Created BaseDbCommand for shared functionality among database commands.
- Implemented DbListCommand for listing SQL databases.
- Added ServerListCommand for listing SQL servers.
- Updated SqlService to support advisor type filtering in GetIndexRecommendationsAsync.
- Refactored SQL option definitions to include advisor type options.
- Created new tests for DbAdviseCommand to ensure correct functionality and error handling.
- Removed outdated SqlIndexRecommendCommandTests.
…and tests with improved analysis result handling
…ndation handling; replace index analysis with general recommendations
…emove deprecated SqlIndexRecommendation model and update related tests
…AdviseCommand, DatabaseAdviseOptions, SqlService, ISqlService, and DbAdviseCommandTests
Copy link
Member Author

@jongio jongio left a comment

Choose a reason for hiding this comment

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

I'm still working on getting an env that has db recommendations so I can test this.

@joshfree joshfree modified the milestones: 2025-06, 2025-08 Jul 29, 2025
@jongio
Copy link
Member Author

jongio commented Aug 7, 2025

This is outdated. Will discuss options with SQL team.

@jongio jongio closed this Aug 7, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Azure MCP Server (OLD) Aug 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants