Azure Resource Manager SQL Dotnet
MicrosoftOfficialCreated by Microsoft
- Skill
- Tool integration
- Cloud and DevOps
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Azure.ResourceManager.Sql SDK provides a .NET interface for management plane operations on Azure SQL. It allows developers to automate the provisioning and configuration of SQL servers, databases, elastic pools, and security settings like firewall rules. This SDK is strictly for infrastructure management and should not be used for executing data queries, which require the Microsoft.Data.SqlClient library.
What it does
- Provision and configure Azure SQL servers and databases.
- Manage elastic pools for cost-effective resource sharing.
- Configure network security via firewall rules.
- Handle failover groups and auditing policies.
- Scale database performance tiers and vCore capacities.
- Perform database lifecycle tasks like copying, restoring, and geo-recovery.
When to use it
- When automating infrastructure-as-code for Azure SQL environments.
- When you need to dynamically scale databases or elastic pools based on application load.
- When managing SQL server security configurations programmatically.
- When building custom tools for Azure SQL resource lifecycle management.
Advantages
- Native .NET integration for Azure management operations.
- Supports complex resource hierarchies and long-running operations.
- Enables programmatic cost optimization through elastic pool management.
- Strongly typed models for resource configuration.
- Seamless integration with Azure Identity for secure authentication.
Usage examples
- “How do I create a new Azure SQL server using the .NET SDK?”
- The agent provides a code snippet using SqlServerData and the CreateOrUpdateAsync method on the SqlServerCollection to provision a new server.
- “How can I move an existing database into an elastic pool?”
- The agent demonstrates updating the database's ElasticPoolId property using the SqlDatabaseData model and the CreateOrUpdateAsync method.
- “What is the correct way to restore a deleted database?”
- The agent shows how to list restorable dropped databases using GetRestorableDroppedDatabases and then restore one using the CreateMode.Restore setting.
- “How do I configure a firewall rule to allow specific IP addresses?”
- The agent provides a code example using SqlFirewallRuleData to define StartIPAddress and EndIPAddress, then applying it via the server's firewall collection.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/azure-resource-manager-sql-dotnet/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip azure-resource-manager-sql-dotnet.zip -d .agents/skills
Documentation by Microsoft
Azure.ResourceManager.Sql (.NET)
Management plane SDK for provisioning and managing Azure SQL resources via Azure Resource Manager.
⚠️ Management vs Data Plane
This SDK (Azure.ResourceManager.Sql): Create servers, databases, elastic pools, configure firewall rules, manage failover groups
Data Plane SDK (Microsoft.Data.SqlClient): Execute queries, stored procedures, manage connections
Installation
dotnet add package Azure.ResourceManager.Sql
dotnet add package Azure.IdentityCurrent Versions: Stable v1.3.0, Preview v1.4.0-beta.3
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id> # Required: Azure subscription ID
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
AZURE_TENANT_ID=<tenant-id> # For service principal auth (optional)
AZURE_CLIENT_ID=<client-id> # For service principal auth (optional)
AZURE_CLIENT_SECRET=<client-secret> # For service principal auth (optional)Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Sql;
// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
var credential = new DefaultAzureCredential(
DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
var armClient = new ArmClient(credential);
// Get subscription
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
new ResourceIdentifier($"/subscriptions/{subscriptionId}"));Resource Hierarchy
ArmClient
└── SubscriptionResource
└── ResourceGroupResource
└── SqlServerResource
├── SqlDatabaseResource
├── ElasticPoolResource
│ └── ElasticPoolDatabaseResource
├── SqlFirewallRuleResource
├── FailoverGroupResource
├── ServerBlobAuditingPolicyResource
├── EncryptionProtectorResource
└── VirtualNetworkRuleResourceCore Workflow
1. Create SQL Server
using Azure.ResourceManager.Sql;
using Azure.ResourceManager.Sql.Models;
// Get resource group
var resourceGroup = await subscription
.GetResourceGroupAsync("my-resource-group");
// Define server
var serverData = new SqlServerData(AzureLocation.EastUS)
{
AdministratorLogin = "sqladmin",
AdministratorLoginPassword = "YourSecurePassword123!",
Version = "12.0",
MinimalTlsVersion = SqlMinimalTlsVersion.Tls1_2,
PublicNetworkAccess = ServerNetworkAccessFlag.Enabled
};
// Create server (long-running operation)
var serverCollection = resourceGroup.Value.GetSqlServers();
var operation = await serverCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-sql-server",
serverData);
SqlServerResource server = operation.Value;2. Create SQL Database
var databaseData = new SqlDatabaseData(AzureLocation.EastUS)
{
Sku = new SqlSku("S0") { Tier = "Standard" },
MaxSizeBytes = 2L * 1024 * 1024 * 1024, // 2 GB
Collation = "SQL_Latin1_General_CP1_CI_AS",
RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Local
};
var databaseCollection = server.GetSqlDatabases();
var dbOperation = await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-database",
databaseData);
SqlDatabaseResource database = dbOperation.Value;3. Create Elastic Pool
var poolData = new ElasticPoolData(AzureLocation.EastUS)
{
Sku = new SqlSku("StandardPool")
{
Tier = "Standard",
Capacity = 100 // 100 eDTUs
},
PerDatabaseSettings = new ElasticPoolPerDatabaseSettings
{
MinCapacity = 0,
MaxCapacity = 100
}
};
var poolCollection = server.GetElasticPools();
var poolOperation = await poolCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-elastic-pool",
poolData);
ElasticPoolResource pool = poolOperation.Value;4. Add Database to Elastic Pool
var databaseData = new SqlDatabaseData(AzureLocation.EastUS)
{
ElasticPoolId = pool.Id
};
await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"pooled-database",
databaseData);5. Configure Firewall Rules
// Allow Azure services
var azureServicesRule = new SqlFirewallRuleData
{
StartIPAddress = "0.0.0.0",
EndIPAddress = "0.0.0.0"
};
var firewallCollection = server.GetSqlFirewallRules();
await firewallCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"AllowAzureServices",
azureServicesRule);
// Allow specific IP range
var clientRule = new SqlFirewallRuleData
{
StartIPAddress = "203.0.113.0",
EndIPAddress = "203.0.113.255"
};
await firewallCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"AllowClientIPs",
clientRule);6. List Resources
// List all servers in subscription
await foreach (var srv in subscription.GetSqlServersAsync())
{
Console.WriteLine($"Server: {srv.Data.Name} in {srv.Data.Location}");
}
// List databases in a server
await foreach (var db in server.GetSqlDatabases())
{
Console.WriteLine($"Database: {db.Data.Name}, SKU: {db.Data.Sku?.Name}");
}
// List elastic pools
await foreach (var ep in server.GetElasticPools())
{
Console.WriteLine($"Pool: {ep.Data.Name}, DTU: {ep.Data.Sku?.Capacity}");
}7. Get Connection String
// Build connection string (server FQDN is predictable)
var serverFqdn = $"{server.Data.Name}.database.windows.net";
var connectionString = $"Server=tcp:{serverFqdn},1433;" +
$"Initial Catalog={database.Data.Name};" +
"Persist Security Info=False;" +
$"User ID={server.Data.AdministratorLogin};" +
"Password=<your-password>;" +
"MultipleActiveResultSets=False;" +
"Encrypt=True;" +
"TrustServerCertificate=False;" +
"Connection Timeout=30;";Key Types Reference
| Type | Purpose |
|---|---|
ArmClient | Entry point for all ARM operations |
SqlServerResource | Represents an Azure SQL server |
SqlServerCollection | Collection for server CRUD |
SqlDatabaseResource | Represents a SQL database |
SqlDatabaseCollection | Collection for database CRUD |
ElasticPoolResource | Represents an elastic pool |
ElasticPoolCollection | Collection for elastic pool CRUD |
SqlFirewallRuleResource | Represents a firewall rule |
SqlFirewallRuleCollection | Collection for firewall rule CRUD |
SqlServerData | Server creation/update payload |
SqlDatabaseData | Database creation/update payload |
ElasticPoolData | Elastic pool creation/update payload |
SqlFirewallRuleData | Firewall rule creation/update payload |
SqlSku | SKU configuration (tier, capacity) |
Common SKUs
Database SKUs
| SKU Name | Tier | Description |
|---|---|---|
Basic | Basic | 5 DTUs, 2 GB max |
S0-S12 | Standard | 10-3000 DTUs |
P1-P15 | Premium | 125-4000 DTUs |
GP_Gen5_2 | GeneralPurpose | vCore-based, 2 vCores |
BC_Gen5_2 | BusinessCritical | vCore-based, 2 vCores |
HS_Gen5_2 | Hyperscale | vCore-based, 2 vCores |
Elastic Pool SKUs
| SKU Name | Tier | Description |
|---|---|---|
BasicPool | Basic | 50-1600 eDTUs |
StandardPool | Standard | 50-3000 eDTUs |
PremiumPool | Premium | 125-4000 eDTUs |
GP_Gen5_2 | GeneralPurpose | vCore-based |
BC_Gen5_2 | BusinessCritical | vCore-based |
Best Practices
Use
WaitUntil.Completedfor operations that must finish before proceedingUse
WaitUntil.Startedwhen you want to poll manually or run operations in parallelAlways use
DefaultAzureCredential— never hardcode passwords in productionHandle
RequestFailedExceptionfor ARM API errorsUse
CreateOrUpdateAsyncfor idempotent operationsNavigate hierarchy via
Get*methods (e.g.,server.GetSqlDatabases())Use elastic pools for cost optimization when managing multiple databases
Configure firewall rules before attempting connections
Error Handling
using Azure;
try
{
var operation = await serverCollection.CreateOrUpdateAsync(
WaitUntil.Completed, serverName, serverData);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
Console.WriteLine("Server already exists");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
Console.WriteLine($"Invalid request: {ex.Message}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");
}Reference Files
| File | When to Read |
|---|---|
| references/server-management.md | Server CRUD, admin credentials, Azure AD auth, networking |
| references/database-operations.md | Database CRUD, scaling, backup, restore, copy |
| references/elastic-pools.md | Pool management, adding/removing databases, scaling |
Related SDKs
| SDK | Purpose | Install |
|---|---|---|
Microsoft.Data.SqlClient | Data plane (execute queries, stored procedures) | dotnet add package Microsoft.Data.SqlClient |
Azure.ResourceManager.Sql | Management plane (this SDK) | dotnet add package Azure.ResourceManager.Sql |
Microsoft.EntityFrameworkCore.SqlServer | ORM for SQL Server | dotnet add package Microsoft.EntityFrameworkCore.SqlServer |
Files
- ATTRIBUTION.mdAdded by AutoGineer1010 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md10.3 KiB
- references/database-operations.md6.8 KiB
- references/elastic-pools.md5.8 KiB
- references/server-management.md5.2 KiB
references/elastic-pools.md
Elastic Pools
Elastic pool management for Azure SQL.
Create DTU-Based Elastic Pool
using Azure.ResourceManager.Sql;
using Azure.ResourceManager.Sql.Models;
var poolData = new ElasticPoolData(AzureLocation.EastUS)
{
Sku = new SqlSku("StandardPool")
{
Tier = "Standard",
Capacity = 100 // 100 eDTUs
},
PerDatabaseSettings = new ElasticPoolPerDatabaseSettings
{
MinCapacity = 0, // Min eDTUs per database
MaxCapacity = 100 // Max eDTUs per database
}
};
var poolCollection = server.GetElasticPools();
var operation = await poolCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-standard-pool",
poolData);
ElasticPoolResource pool = operation.Value;Create vCore-Based Elastic Pool
var poolData = new ElasticPoolData(AzureLocation.EastUS)
{
Sku = new SqlSku("GP_Gen5_2")
{
Tier = "GeneralPurpose",
Family = "Gen5",
Capacity = 2 // vCores
},
PerDatabaseSettings = new ElasticPoolPerDatabaseSettings
{
MinCapacity = 0,
MaxCapacity = 2
},
ZoneRedundant = false,
LicenseType = DatabaseLicenseType.LicenseIncluded // or BasePrice for Azure Hybrid Benefit
};
await poolCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-vcore-pool",
poolData);Create Premium Elastic Pool with Zone Redundancy
var poolData = new ElasticPoolData(AzureLocation.EastUS)
{
Sku = new SqlSku("PremiumPool")
{
Tier = "Premium",
Capacity = 125 // 125 eDTUs
},
PerDatabaseSettings = new ElasticPoolPerDatabaseSettings
{
MinCapacity = 0,
MaxCapacity = 125
},
ZoneRedundant = true
};
await poolCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-premium-pool",
poolData);Add Database to Elastic Pool
// Create new database in pool
var databaseData = new SqlDatabaseData(AzureLocation.EastUS)
{
ElasticPoolId = pool.Id
};
await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"pooled-database",
databaseData);Move Existing Database to Elastic Pool
// Get existing database
var database = await databaseCollection.GetAsync("standalone-database");
// Update to use elastic pool
var updateData = new SqlDatabaseData(database.Value.Data.Location)
{
ElasticPoolId = pool.Id
};
await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"standalone-database",
updateData);Remove Database from Elastic Pool
// Move database out of pool by assigning a standalone SKU
var updateData = new SqlDatabaseData(database.Value.Data.Location)
{
Sku = new SqlSku("S0") { Tier = "Standard" },
ElasticPoolId = null
};
await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"pooled-database",
updateData);Scale Elastic Pool
var pool = await poolCollection.GetAsync("my-elastic-pool");
var updateData = new ElasticPoolData(pool.Value.Data.Location)
{
Sku = new SqlSku("StandardPool")
{
Tier = "Standard",
Capacity = 200 // Scale up to 200 eDTUs
},
PerDatabaseSettings = new ElasticPoolPerDatabaseSettings
{
MinCapacity = 10,
MaxCapacity = 100
}
};
await poolCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-elastic-pool",
updateData);List Databases in Elastic Pool
var pool = await poolCollection.GetAsync("my-elastic-pool");
// Get databases in this pool
var poolDatabases = pool.Value.GetElasticPoolDatabases();
await foreach (var db in poolDatabases)
{
Console.WriteLine($"Database: {db.Data.Name}");
Console.WriteLine($" Current SKU: {db.Data.CurrentSku?.Name}");
Console.WriteLine($" Max Size: {db.Data.MaxSizeBytes / (1024 * 1024 * 1024)} GB");
}Monitor Elastic Pool Metrics
// Get pool resource utilization
var pool = await poolCollection.GetAsync("my-elastic-pool");
// Pool metrics are available via Azure Monitor
// Use Azure.ResourceManager.Monitor for detailed metrics
Console.WriteLine($"Pool: {pool.Value.Data.Name}");
Console.WriteLine($"State: {pool.Value.Data.State}");
Console.WriteLine($"Max Size: {pool.Value.Data.MaxSizeBytes / (1024 * 1024 * 1024)} GB");
Console.WriteLine($"DTU Capacity: {pool.Value.Data.Sku?.Capacity}");Delete Elastic Pool
// First, move all databases out of the pool or delete them
var pool = await poolCollection.GetAsync("my-elastic-pool");
// Check for databases
var poolDatabases = pool.Value.GetElasticPoolDatabases();
await foreach (var db in poolDatabases)
{
// Either delete or move to standalone
await db.DeleteAsync(WaitUntil.Completed);
}
// Now delete the pool
await pool.Value.DeleteAsync(WaitUntil.Completed);Elastic Pool SKU Reference
DTU-Based Pools
| SKU Name | Tier | eDTU Range | Max DBs |
|---|---|---|---|
BasicPool | Basic | 50-1600 | 500 |
StandardPool | Standard | 50-3000 | 500 |
PremiumPool | Premium | 125-4000 | 100 |
vCore-Based Pools
| SKU Pattern | Tier | vCore Range |
|---|---|---|
GP_Gen5_{n} | GeneralPurpose | 2-80 |
GP_Fsv2_{n} | GeneralPurpose | 8-72 |
GP_DC_{n} | GeneralPurpose | 2-8 |
BC_Gen5_{n} | BusinessCritical | 2-80 |
BC_DC_{n} | BusinessCritical | 2-8 |
Best Practices
Right-size pools: Start with estimated total DTU/vCore needs, monitor, and adjust
Set per-database limits: Prevent a single database from consuming all resources
Use zone redundancy for production Premium/BusinessCritical pools
Monitor utilization: Scale up when consistently above 80% utilization
Consider Hyperscale: For databases > 4TB or needing rapid scale
Use Azure Hybrid Benefit: Set
LicenseType = BasePriceif you have SQL Server licenses
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-dotnet/skills/azure-resource-manager-sql-dotnet · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download azure-resource-manager-sql-dotnet.zip