Skip to content

Conversation

achyuth-ms
Copy link
Member

@achyuth-ms achyuth-ms commented Sep 20, 2025

What does this PR do?

Add azmcp sql db export command and unit tests

[Any additional context, screenshots, or information that helps reviewers]

GitHub issue number?

[Link to the GitHub issue this PR addresses]

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Updated command list in /docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

@joshfree joshfree moved this from Untriaged to In Progress in Azure MCP Server Sep 23, 2025
@achyuth-ms achyuth-ms force-pushed the sql_cli_db_ex-ip branch 2 times, most recently from 9935ac2 to 991b484 Compare September 25, 2025 23:29
@achyuth-ms
Copy link
Member Author

/azp run mcp - pullrequest - live

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@achyuth-ms achyuth-ms marked this pull request as ready for review September 25, 2025 23:33
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 23:33
@achyuth-ms achyuth-ms requested review from a team and mitesh-pv as code owners September 25, 2025 23:33
Copy link
Contributor

@Copilot 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 a new SQL database export command to allow exporting Azure SQL databases to BACPAC files in Azure Storage. This functionality enables users to create logical backups of their database schema and data for archiving or migration purposes.

  • Implements a complete export command with validation, service integration, and comprehensive test coverage
  • Adds necessary models, options, and service methods to support the export functionality
  • Updates documentation and configuration to register the new command

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DatabaseExportCommandTests.cs Comprehensive unit tests for the new export command covering success, error, and validation scenarios
SqlSetup.cs Registers the new DatabaseExportCommand in dependency injection and command registration
SqlService.cs Implements ExportDatabaseAsync method with Azure Resource Manager integration
ISqlService.cs Adds interface definition for the export database operation
SqlOptionDefinitions.cs Defines command line options for storage URI, keys, admin credentials, and auth type
DatabaseExportOptions.cs Options class for binding export-specific parameters
SqlDatabaseExportResult.cs Result model containing export operation details
SqlJsonContext.cs Adds JSON serialization support for the new export result types
DatabaseExportCommand.cs Main command implementation with validation, execution logic, and error handling
README.md Updates documentation with export command example
CHANGELOG.md Documents the new export functionality
e2eTestPrompts.md Adds test prompts for the export command
azmcp-commands.md Documents the export command syntax and parameters

Comment on lines +101 to +106
// Debug: Add detailed error info
if (response.Status != HttpStatusCode.OK)
{
throw new Exception($"Expected OK but got {response.Status}. Message: {response.Message}");
}
Assert.Equal(HttpStatusCode.OK, response.Status);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

Debug/temporary code should be removed from production tests. This debugging logic with the throw statement appears to be temporary code that should be cleaned up.

Suggested change
// Debug: Add detailed error info
if (response.Status != HttpStatusCode.OK)
{
throw new Exception($"Expected OK but got {response.Status}. Message: {response.Message}");
}
Assert.Equal(HttpStatusCode.OK, response.Status);
Assert.Equal(HttpStatusCode.OK, response.Status); // Optionally, add a message: Assert.Equal(HttpStatusCode.OK, response.Status, $"Message: {response.Message}");

Copilot uses AI. Check for mistakes.

@achyuth-ms achyuth-ms changed the title add sql db export command Add azmcp sql db export command and unit tests Sep 25, 2025
@achyuth-ms achyuth-ms changed the title Add azmcp sql db export command and unit tests Add azmcp sql db export command and unit tests Sep 25, 2025
@ericshape
Copy link
Member

about the failed pipelines, you could run "dotnet format" in your local's mcp repo and then commit the format updates (i.e. white space)

All Azure MCP tools in a single server. The Azure MCP Server implements the [MCP specification](https://modelcontextprotocol.io) to create a seamless connection between AI agents and Azure services. Azure MCP Server can be used alone or with the [GitHub Copilot for Azure extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azure-github-copilot) in VS Code. This project is in Public Preview and implementation may significantly change prior to our General Availability.

[![Install Azure MCP in VS Code](https://img.shields.io/badge/VS_Code-Install_Azure_MCP_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:extension/ms-azuretools.vscode-azure-mcp-server) [![Install Azure MCP in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Azure_MCP_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode-insiders:extension/ms-azuretools.vscode-azure-mcp-server) [![Install Azure MCP in Visual Studio](https://img.shields.io/badge/Visual_Studio-Install_Azure_MCP_Server-C16FDE?style=flat-square&logo=visualstudio&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=github-copilot-azure.GitHubCopilotForAzure2022) [![Install Azure MCP Server](https://img.shields.io/badge/IntelliJ%20IDEA-Install%20Azure%20MCP%20Server-1495b1?style=flat-square&logo=intellijidea&logoColor=white)](https://plugins.jetbrains.com/plugin/8053)
[![Install Azure MCP in VS Code](https://img.shields.io/badge/VS_Code-Install_Azure_MCP_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:extension/ms-azuretools.vscode-azure-mcp-server) [![Install Azure MCP in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Azure_MCP_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode-insiders:extension/ms-azuretools.vscode-azure-mcp-server) [![Install Azure MCP in Visual Studio](https://img.shields.io/badge/Visual_Studio-Install_Azure_MCP_Server-C16FDE?style=flat-square&logo=visualstudio&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=github-copilot-azure.GitHubCopilotForAzure2022)
Copy link
Contributor

Choose a reason for hiding this comment

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

are you removing jetbrains

Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to rebase?

options.StorageKeyType = parseResult.GetValueOrDefault(SqlOptionDefinitions.StorageKeyTypeOption);
options.AdminUser = parseResult.GetValueOrDefault(SqlOptionDefinitions.AdminUserOption);
options.AdminPassword = parseResult.GetValueOrDefault(SqlOptionDefinitions.AdminPasswordOption);
options.AuthType = parseResult.GetValueOrDefault(SqlOptionDefinitions.AuthTypeOption);
Copy link
Contributor

Choose a reason for hiding this comment

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

@xiangyan99 pls review

var options = BindOptions(parseResult);

// Additional validation for export-specific parameters
if (string.IsNullOrEmpty(options.StorageUri))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to Validators @alzimmermsft

Comment on lines +9 to +17
[property: JsonPropertyName("operationId")] string? OperationId,
[property: JsonPropertyName("requestId")] string? RequestId,
[property: JsonPropertyName("status")] string? Status,
[property: JsonPropertyName("queuedTime")] DateTimeOffset? QueuedTime,
[property: JsonPropertyName("lastModifiedTime")] DateTimeOffset? LastModifiedTime,
[property: JsonPropertyName("serverName")] string? ServerName,
[property: JsonPropertyName("databaseName")] string? DatabaseName,
[property: JsonPropertyName("storageUri")] string? StorageUri,
[property: JsonPropertyName("message")] string? Message
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like we might not want to duplicate the names, can you use SqlOptionDefinitions.

{
ValidateRequiredParameters(serverName, resourceGroup, subscription, databaseName);

if (string.IsNullOrEmpty(storageUri))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not add to ValidateRequiredParameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants