-
Notifications
You must be signed in to change notification settings - Fork 228
Add azmcp sql db export
command and unit tests
#526
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
base: main
Are you sure you want to change the base?
Conversation
9935ac2
to
991b484
Compare
/azp run mcp - pullrequest - live |
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. |
There was a problem hiding this 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 |
// 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); |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
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.
// 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.
tools/Azure.Mcp.Tools.Sql/src/Commands/Database/DatabaseExportCommand.cs
Show resolved
Hide resolved
azmcp sql db export
command and unit tests
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) |
b0c9b23
to
e1bd045
Compare
e1bd045
to
e77a6ec
Compare
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. | ||
|
||
[](https://vscode.dev/redirect?url=vscode:extension/ms-azuretools.vscode-azure-mcp-server) [](https://vscode.dev/redirect?url=vscode-insiders:extension/ms-azuretools.vscode-azure-mcp-server) [](https://marketplace.visualstudio.com/items?itemName=github-copilot-azure.GitHubCopilotForAzure2022) [](https://plugins.jetbrains.com/plugin/8053) | ||
[](https://vscode.dev/redirect?url=vscode:extension/ms-azuretools.vscode-azure-mcp-server) [](https://vscode.dev/redirect?url=vscode-insiders:extension/ms-azuretools.vscode-azure-mcp-server) [](https://marketplace.visualstudio.com/items?itemName=github-copilot-azure.GitHubCopilotForAzure2022) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you removing jetbrains
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to Validators @alzimmermsft
[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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
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
servers/Azure.Mcp.Server/CHANGELOG.md
and/orservers/Fabric.Mcp.Server/CHANGELOG.md
for product changes (features, bug fixes, UI/UX, updated dependencies
)servers/Azure.Mcp.Server/README.md
and/orservers/Fabric.Mcp.Server/README.md
documentation/docs/azmcp-commands.md
and/or/docs/fabric-commands.md
ToolDescriptionEvaluator
and obtained a score of0.4
or more and a top 3 ranking for all related test prompts/docs/e2eTestPrompts.md
crypto mining, spam, data exfiltration, etc.
)/azp run mcp - pullrequest - live
to run Live Test Pipeline