Generated banner for Azure Resource Manager SQL Dotnet
Generated logo for Azure Resource Manager SQL Dotnet

Azure Resource Manager SQL Dotnet

MicrosoftOfficialCreated by Microsoft

  • Skill
  • Tool integration
  • Cloud and DevOps
  • MIT
  • No issues found

From the author

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".
— the description by Microsoft

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

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/microsoft/azure-resource-manager-sql-dotnet/download
  2. Unzip 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.Identity

Current 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
            └── VirtualNetworkRuleResource

Core 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

TypePurpose
ArmClientEntry point for all ARM operations
SqlServerResourceRepresents an Azure SQL server
SqlServerCollectionCollection for server CRUD
SqlDatabaseResourceRepresents a SQL database
SqlDatabaseCollectionCollection for database CRUD
ElasticPoolResourceRepresents an elastic pool
ElasticPoolCollectionCollection for elastic pool CRUD
SqlFirewallRuleResourceRepresents a firewall rule
SqlFirewallRuleCollectionCollection for firewall rule CRUD
SqlServerDataServer creation/update payload
SqlDatabaseDataDatabase creation/update payload
ElasticPoolDataElastic pool creation/update payload
SqlFirewallRuleDataFirewall rule creation/update payload
SqlSkuSKU configuration (tier, capacity)

Common SKUs

Database SKUs
SKU NameTierDescription
BasicBasic5 DTUs, 2 GB max
S0-S12Standard10-3000 DTUs
P1-P15Premium125-4000 DTUs
GP_Gen5_2GeneralPurposevCore-based, 2 vCores
BC_Gen5_2BusinessCriticalvCore-based, 2 vCores
HS_Gen5_2HyperscalevCore-based, 2 vCores
Elastic Pool SKUs
SKU NameTierDescription
BasicPoolBasic50-1600 eDTUs
StandardPoolStandard50-3000 eDTUs
PremiumPoolPremium125-4000 eDTUs
GP_Gen5_2GeneralPurposevCore-based
BC_Gen5_2BusinessCriticalvCore-based

Best Practices

  1. Use WaitUntil.Completed for operations that must finish before proceeding

  2. Use WaitUntil.Started when you want to poll manually or run operations in parallel

  3. Always use DefaultAzureCredential — never hardcode passwords in production

  4. Handle RequestFailedException for ARM API errors

  5. Use CreateOrUpdateAsync for idempotent operations

  6. Navigate hierarchy via Get* methods (e.g., server.GetSqlDatabases())

  7. Use elastic pools for cost optimization when managing multiple databases

  8. 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

FileWhen to Read
references/server-management.mdServer CRUD, admin credentials, Azure AD auth, networking
references/database-operations.mdDatabase CRUD, scaling, backup, restore, copy
references/elastic-pools.mdPool management, adding/removing databases, scaling
SDKPurposeInstall
Microsoft.Data.SqlClientData plane (execute queries, stored procedures)dotnet add package Microsoft.Data.SqlClient
Azure.ResourceManager.SqlManagement plane (this SDK)dotnet add package Azure.ResourceManager.Sql
Microsoft.EntityFrameworkCore.SqlServerORM for SQL Serverdotnet add package Microsoft.EntityFrameworkCore.SqlServer

Files

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 NameTiereDTU RangeMax DBs
BasicPoolBasic50-1600500
StandardPoolStandard50-3000500
PremiumPoolPremium125-4000100
vCore-Based Pools
SKU PatternTiervCore Range
GP_Gen5_{n}GeneralPurpose2-80
GP_Fsv2_{n}GeneralPurpose8-72
GP_DC_{n}GeneralPurpose2-8
BC_Gen5_{n}BusinessCritical2-80
BC_DC_{n}BusinessCritical2-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

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