All skills
microsoft avatar

/azure-resource-manager-sql-dotnet

@073741f
by microsoftmicrosoft/skills3.1k stars
351

Azure Resource Manager SDK for Azure SQL in .NET. Use for MANAGEMENT PLANE operations: creating/managing SQL servers, databases, elastic pools, firewall rules, and failover groups via Azure Resource Manager. NOT for data plane operations (executing queries) - use Microsoft.Data.SqlClient for that. Triggers: "SQL server", "create SQL database", "manage SQL resources", "ARM SQL", "SqlServerResource", "provision Azure SQL", "elastic pool", "firewall rule".

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-resource-manager-sql-dotnet

This session only. Nothing lands on disk.

referenceselastic-pools.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

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

  1. Right-size pools: Start with estimated total DTU/vCore needs, monitor, and adjust
  2. Set per-database limits: Prevent a single database from consuming all resources
  3. Use zone redundancy for production Premium/BusinessCritical pools
  4. Monitor utilization: Scale up when consistently above 80% utilization
  5. Consider Hyperscale: For databases > 4TB or needing rapid scale
  6. Use Azure Hybrid Benefit: Set LicenseType = BasePrice if you have SQL Server licenses

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill provides a standard set of instructions and code examples for managing Azure SQL resources using the official Microsoft .NET SDK. It correctly identifies the distinction between management and data plane operations and emphasizes security best practices like using managed identities for authentication.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    5/5 files flagged

Signed by skilld at 073741f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 5 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "Azure.ResourceManager.Sql"
}

README badge

README badge for microsoft/skills/azure-resource-manager-sql-dotnet