Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c7b0df6
Using ARG query to list & get Sql data
ArthurMa1978 Aug 11, 2025
a6f267e
update
ArthurMa1978 Aug 12, 2025
6348e68
update
ArthurMa1978 Aug 12, 2025
762f37d
update doc
ArthurMa1978 Aug 12, 2025
d856d23
update
ArthurMa1978 Aug 12, 2025
d57e70d
update
ArthurMa1978 Aug 12, 2025
9e1d572
update
ArthurMa1978 Aug 12, 2025
5aa0562
update
ArthurMa1978 Aug 13, 2025
eca7dd4
update
ArthurMa1978 Aug 13, 2025
f6856c6
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 13, 2025
57dd806
update
ArthurMa1978 Aug 13, 2025
a39d6bc
update
ArthurMa1978 Aug 13, 2025
e4e324a
update
ArthurMa1978 Aug 14, 2025
c6b4574
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 14, 2025
fe8ed38
update
ArthurMa1978 Aug 14, 2025
e588fad
revert vscode/README.md
ArthurMa1978 Aug 14, 2025
228ffc0
udpate
ArthurMa1978 Aug 14, 2025
a7c3c06
update
ArthurMa1978 Aug 15, 2025
b7d3879
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 15, 2025
0661eac
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 15, 2025
e391dab
update changelog
ArthurMa1978 Aug 15, 2025
84acd0b
update changelog
ArthurMa1978 Aug 15, 2025
54986bf
update checklist
ArthurMa1978 Aug 15, 2025
04b5116
Update the identify unused properteis check
ArthurMa1978 Aug 15, 2025
caecb2e
update
ArthurMa1978 Aug 15, 2025
631c25e
fix typo
ArthurMa1978 Aug 15, 2025
7f1cc08
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 18, 2025
9a5418e
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 19, 2025
3bdb737
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 19, 2025
4bd863c
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 20, 2025
67818a9
Merge branch 'main' into mgmt-sql
ArthurMa1978 Aug 20, 2025
c985dbe
update changelog
ArthurMa1978 Aug 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"cslschema",
"codeql",
"codesign",
"cutover",
"Commmand",
"Commitish",
"datatable",
Expand All @@ -108,6 +109,7 @@
"globaltool",
"glsl",
"Groq",
"Hyperscale",
"HKCU",
"HKEY_CURRENT_USER",
"hotmail",
Expand Down
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<PackageVersion Include="Azure.ResourceManager.Redis" Version="1.5.1" />
<PackageVersion Include="Azure.ResourceManager.RedisEnterprise" Version="1.2.1" />
<PackageVersion Include="Azure.ResourceManager.LoadTesting" Version="1.1.2" />
<PackageVersion Include="Azure.ResourceManager.Sql" Version="1.4.0-beta.3" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.7.0" />
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageVersion Include="Azure.Security.KeyVault.Certificates" Version="4.7.0" />
Expand Down
1 change: 0 additions & 1 deletion areas/sql/src/AzureMcp.Sql/AzureMcp.Sql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<ItemGroup />
<ItemGroup>
<PackageReference Include="Azure.ResourceManager" />
<PackageReference Include="Azure.ResourceManager.Sql" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="ModelContextProtocol" />
<PackageReference Include="System.CommandLine" />
Expand Down
5 changes: 5 additions & 0 deletions areas/sql/src/AzureMcp.Sql/Commands/SqlJsonContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AzureMcp.Sql.Commands.EntraAdmin;
using AzureMcp.Sql.Commands.FirewallRule;
using AzureMcp.Sql.Models;
using AzureMcp.Sql.Services.Models;

namespace AzureMcp.Sql.Commands;

Expand All @@ -22,6 +23,10 @@ namespace AzureMcp.Sql.Commands;
[JsonSerializable(typeof(DatabaseSku))]
[JsonSerializable(typeof(ElasticPoolSku))]
[JsonSerializable(typeof(ElasticPoolPerDatabaseSettings))]
[JsonSerializable(typeof(SqlDatabaseData))]
[JsonSerializable(typeof(SqlServerAadAdministratorData))]
[JsonSerializable(typeof(SqlElasticPoolData))]
[JsonSerializable(typeof(SqlFirewallRuleData))]
[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = true,
Expand Down
21 changes: 21 additions & 0 deletions areas/sql/src/AzureMcp.Sql/Services/Models/DatabaseIdentity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

using System.Text.Json.Serialization;

namespace AzureMcp.Sql.Services.Models
{
/// <summary> Azure Active Directory identity configuration for a resource. </summary>
internal sealed class DatabaseIdentity
{
/// <summary> The identity type. </summary>
[JsonPropertyName("type")]
public string IdentityType { get; set; }
/// <summary> The Azure Active Directory tenant id. </summary>
public Guid? TenantId { get; set; }
/// <summary> The resource ids of the user assigned identities to use. </summary>
public IDictionary<string, SqlUserAssignedIdentity> UserAssignedIdentities { get; set; }
}
}
47 changes: 47 additions & 0 deletions areas/sql/src/AzureMcp.Sql/Services/Models/SqlDatabaseData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

using System.Text.Json.Serialization;
using AzureMcp.Sql.Commands;

namespace AzureMcp.Sql.Services.Models
{
/// <summary>
/// A class representing the SqlDatabase data model.
/// A database resource.
/// </summary>
internal sealed class SqlDatabaseData
{
/// <summary> The resource ID for the resource. </summary>
[JsonPropertyName("id")]
public string ResourceId { get; set; }
/// <summary> The type of the resource. </summary>
[JsonPropertyName("type")]
public string ResourceType { get; set; }
/// <summary> The name of the resource. </summary>
[JsonPropertyName("name")]
public string ResourceName { get; set; }
/// <summary> The location of the resource. </summary>
public string Location { get; set; }
/// <summary> The database SKU. </summary>
public SqlSku Sku { get; set; }
/// <summary> Kind of database. This is metadata used for the Azure portal experience. </summary>
public string Kind { get; set; }
/// <summary> Resource that manages the database. </summary>
public string ManagedBy { get; set; }
/// <summary> The Azure Active Directory identity of the database. </summary>
public DatabaseIdentity Identity { get; set; }
/// <summary> The tags of the resource. </summary>
public IDictionary<string, string> Tags { get; set; }
/// <summary> Properties of the Sql database. </summary>
public SqlDatabaseProperties Properties { get; set; }

// Read the JSON response content and create a model instance from it.
public static SqlDatabaseData FromJson(JsonElement source)
{
return JsonSerializer.Deserialize<SqlDatabaseData>(source, SqlJsonContext.Default.SqlDatabaseData);
}
}
}
26 changes: 26 additions & 0 deletions areas/sql/src/AzureMcp.Sql/Services/Models/SqlDatabaseKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

using System.Text.Json.Serialization;

namespace AzureMcp.Sql.Services.Models
{
/// <summary> Database level key used for encryption at rest. </summary>
internal sealed class SqlDatabaseKey
{
/// <summary> The database key type. Only supported value is 'AzureKeyVault'. </summary>
[JsonPropertyName("type")]
public string KeyType { get; set; }
/// <summary> Thumbprint of the database key. </summary>
public string Thumbprint { get; set; }
/// <summary> The database key creation date. </summary>
[JsonPropertyName("creationDate")]
public DateTimeOffset? CreatedOn { get; set; }
/// <summary> Subregion of the server key. </summary>
public string Subregion { get; set; }
/// <summary> The database key's version. </summary>
public string KeyVersion { get; set; }
}
}
155 changes: 155 additions & 0 deletions areas/sql/src/AzureMcp.Sql/Services/Models/SqlDatabaseProperties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

using System.Text.Json.Serialization;

namespace AzureMcp.Sql.Services.Models
{
/// <summary>
/// A class representing the SqlDatabase properties model.
/// A database resource properties.
/// </summary>
internal sealed class SqlDatabaseProperties
{
/// <summary> Specifies the mode of database creation. </summary>
public string CreateMode { get; set; }
/// <summary> The collation of the database. </summary>
public string Collation { get; set; }
/// <summary> The max size of the database expressed in bytes. </summary>
public long? MaxSizeBytes { get; set; }
/// <summary> The name of the sample schema to apply when creating this database. </summary>
public string SampleName { get; set; }
/// <summary> The resource identifier of the elastic pool containing this database. </summary>
public string ElasticPoolId { get; set; }
/// <summary> The resource identifier of the source database associated with create operation of this database. </summary>
public string SourceDatabaseId { get; set; }
/// <summary> The status of the database. </summary>
public string Status { get; set; }
/// <summary> The ID of the database. </summary>
public Guid? DatabaseId { get; set; }
/// <summary> The creation date of the database (ISO8601 format). </summary>
[JsonPropertyName("creationDate")]
public DateTimeOffset? CreatedOn { get; set; }
/// <summary> The current service level objective name of the database. </summary>
public string CurrentServiceObjectiveName { get; set; }
/// <summary> The requested service level objective name of the database. </summary>
public string RequestedServiceObjectiveName { get; set; }
/// <summary> The default secondary region for this database. </summary>
public string DefaultSecondaryLocation { get; set; }
/// <summary> Failover Group resource identifier that this database belongs to. </summary>
public string FailoverGroupId { get; set; }
/// <summary> Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. </summary>
[JsonPropertyName("restorePointInTime")]
public DateTimeOffset? RestorePointInTime { get; set; }
/// <summary> Specifies the time that the database was deleted. </summary>
[JsonPropertyName("sourceDatabaseDeletionDate")]
public DateTimeOffset? SourceDatabaseDeletedOn { get; set; }
/// <summary> The resource identifier of the recovery point associated with create operation of this database. </summary>
public string RecoveryServicesRecoveryPointId { get; set; }
/// <summary> The resource identifier of the long term retention backup associated with create operation of this database. </summary>
public string LongTermRetentionBackupResourceId { get; set; }
/// <summary> The resource identifier of the recoverable database associated with create operation of this database. </summary>
public string RecoverableDatabaseId { get; set; }
/// <summary> The resource identifier of the restorable dropped database associated with create operation of this database. </summary>
public string RestorableDroppedDatabaseId { get; set; }
/// <summary> Collation of the metadata catalog. </summary>
public string CatalogCollation { get; set; }
/// <summary> Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. </summary>
public bool? IsZoneRedundant { get; set; }
/// <summary> The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. </summary>
public string LicenseType { get; set; }
/// <summary> The max log size for this database. </summary>
public long? MaxLogSizeBytes { get; set; }
/// <summary> This records the earliest start date and time that restore is available for this database (ISO8601 format). </summary>
[JsonPropertyName("earliestRestoreDate")]
public DateTimeOffset? EarliestRestoreOn { get; set; }
/// <summary> The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool. </summary>
public string ReadScale { get; set; }
/// <summary> The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale edition database that are used to provide high availability. Not applicable to a Hyperscale database within an elastic pool. </summary>
public int? HighAvailabilityReplicaCount { get; set; }
/// <summary> The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby. </summary>
public string SecondaryType { get; set; }
/// <summary> The name and tier of the SKU. </summary>
public SqlSku CurrentSku { get; set; }
/// <summary> Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled. </summary>
public int? AutoPauseDelay { get; set; }
/// <summary> The storage account type used to store backups for this database. </summary>
public string CurrentBackupStorageRedundancy { get; set; }
/// <summary> The storage account type to be used to store backups for this database. </summary>
public string RequestedBackupStorageRedundancy { get; set; }
/// <summary> Minimal capacity that database will always have allocated, if not paused. </summary>
public double? MinCapacity { get; set; }
/// <summary> The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. </summary>
[JsonPropertyName("pausedDate")]
public DateTimeOffset? PausedOn { get; set; }
/// <summary> The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. </summary>
[JsonPropertyName("resumedDate")]
public DateTimeOffset? ResumedOn { get; set; }
/// <summary> Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur. </summary>
public string MaintenanceConfigurationId { get; set; }
/// <summary> Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. </summary>
public bool? IsLedgerOn { get; set; }
/// <summary> Infra encryption is enabled for this database. </summary>
public bool? IsInfraEncryptionEnabled { get; set; }
/// <summary> The Client id used for cross tenant per database CMK scenario. </summary>
public Guid? FederatedClientId { get; set; }
/// <summary> The resource ids of the user assigned identities to use. </summary>
public IDictionary<string, SqlDatabaseKey> Keys { get; set; }
/// <summary> The azure key vault URI of the database if it's configured with per Database Customer Managed Keys. </summary>
public string EncryptionProtector { get; set; }
/// <summary> Type of enclave requested on the database i.e. Default or VBS enclaves. </summary>
public string PreferredEnclaveType { get; set; }
/// <summary> Whether or not the database uses free monthly limits. Allowed on one database in a subscription. </summary>
public bool? UseFreeLimit { get; set; }
/// <summary>
/// Specifies the behavior when monthly free limits are exhausted for the free database.
///
/// AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the month.
///
/// BillForUsage: The database will continue to be online upon exhaustion of free limits and any overage will be billed.
/// </summary>
public string FreeLimitExhaustionBehavior { get; set; }
/// <summary>
/// The resource identifier of the source associated with the create operation of this database.
///
/// This property is only supported for DataWarehouse edition and allows to restore across subscriptions.
///
/// When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode must be PointInTimeRestore, Restore or Recover.
///
/// When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing database or existing sql pool, and restorePointInTime must be specified.
///
/// When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped database or restorable dropped sql pool.
///
/// When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or recoverable sql pool.
///
/// When source subscription belongs to a different tenant than target subscription, “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. For more details about “x-ms-authorization-auxiliary” header see https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
/// </summary>
public string SourceResourceId { get; set; }
/// <summary>
/// Whether or not customer controlled manual cutover needs to be done during Update Database operation to Hyperscale tier.
///
/// This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier.
///
/// When manualCutover is specified, the scaling operation will wait for user input to trigger cutover to Hyperscale database.
///
/// To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in Waiting state.
/// </summary>
public bool? ManualCutover { get; set; }
/// <summary>
/// To trigger customer controlled manual cutover during the wait state while Scaling operation is in progress.
///
/// This property parameter is only applicable for scaling operations that are initiated along with 'manualCutover' parameter.
///
/// This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier is already in progress.
///
/// When performCutover is specified, the scaling operation will trigger cutover and perform role-change to Hyperscale database.
/// </summary>
public bool? PerformCutover { get; set; }
/// <summary> Specifies the availability zone the database is pinned to. </summary>
public string AvailabilityZone { get; set; }
/// <summary> The flag to enable or disable auto rotation of database encryption protector AKV key. </summary>
public bool? EncryptionProtectorAutoRotation { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

using System.Text.Json.Serialization;
using AzureMcp.Sql.Commands;

namespace AzureMcp.Sql.Services.Models
{
/// <summary>
/// A class representing the ElasticPool data model.
/// An elastic pool.
/// </summary>
internal sealed class SqlElasticPoolData
{
/// <summary> The resource ID for the resource. </summary>
[JsonPropertyName("id")]
public string ResourceId { get; set; }
/// <summary> The type of the resource. </summary>
[JsonPropertyName("type")]
public string ResourceType { get; set; }
/// <summary> The name of the resource. </summary>
[JsonPropertyName("name")]
public string ResourceName { get; set; }
/// <summary> The location of the resource. </summary>
public string Location { get; set; }
/// <summary> The database SKU. </summary>
public SqlSku Sku { get; set; }
/// <summary> Kind of elastic pool. This is metadata used for the Azure portal experience. </summary>
public string Kind { get; set; }
/// <summary> The tags of the resource. </summary>
public IDictionary<string, string> Tags { get; set; }
/// <summary> The properties of elastic pool. </summary>
public SqlElasticPoolProperties Properties { get; set; }

// Read the JSON response content and create a model instance from it.
public static SqlElasticPoolData FromJson(JsonElement source)
{
return JsonSerializer.Deserialize<SqlElasticPoolData>(source, SqlJsonContext.Default.SqlElasticPoolData);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable disable

namespace AzureMcp.Sql.Services.Models
{
/// <summary> Per database settings of an elastic pool. </summary>
internal sealed class SqlElasticPoolPerDatabaseSettings
{
/// <summary> The minimum capacity all databases are guaranteed. </summary>
public double? MinCapacity { get; set; }
/// <summary> The maximum capacity any one database can consume. </summary>
public double? MaxCapacity { get; set; }
/// <summary> Auto Pause Delay for per database within pool. </summary>
public int? AutoPauseDelay { get; set; }
}
}
Loading
Loading