azure-sql-optimization — Claude Code skill: what it does
azure-sql-optimization — a skill for tuning Azure SQL Database: tier choice, automatic tuning, Hyperscale, Serverless and elastic pools.
MIT 164 installs ★ 66 updated 2026-06-18
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a claude-codeWhat azure-sql-optimization does
The skill puts an Azure SQL Database reference into one file: a tier table from Basic through Hyperscale, a DTU versus vCore comparison, and DMV queries against sys.dm_db_resource_stats and sys.resource_stats for CPU, IO and log write pressure. Query Store snippets return the top 20 queries by CPU for the past hour.
Automatic tuning gets its own section. You get the ALTER DATABASE statement that switches on FORCE_LAST_GOOD_PLAN, CREATE_INDEX and DROP_INDEX, a query for sys.dm_db_tuning_recommendations, and the sp_query_store_force_plan call for pinning a plan by hand.
Hyperscale and Serverless are covered as well: storage that grows on its own up to 128 TB, read-only routing with ApplicationIntent=ReadOnly, named replicas, auto-pause delay. Then the limits. Azure SQL has no SQL Agent and no linked servers, so scheduled jobs move to Azure Functions and cross-database reads go through Elastic Query. Plan for that before you migrate.
What it helps with
- choose between DTU and vCore without over-provisioning
- turn on automatic tuning for plan regressions and missing indexes
- pull the top 20 CPU queries from Query Store
- set an auto-pause delay on a Serverless database
- move a
BULK INSERTfrom a local file to Blob Storage
Example prompts for the agent
- Compare DTU and vCore for our workload and tell me which tier fits.
- Enable automatic tuning on the database and list what
sys.dm_db_tuning_recommendationssuggests. - Write a query against
sys.dm_db_resource_statsshowing CPU and IO for the last 15 minutes.
How to install azure-sql-optimization
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a claude-code2Manually: put the files in place
~/.claude/skills/azure-sql-optimization/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/azure-sql-optimization/
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a codex2Manually: put the files in place
.agents/skills/azure-sql-optimization/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a cursor2Manually: put the files in place
.cursor/skills/azure-sql-optimization/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install JosiahSiegel/claude-plugin-marketplace plugins/tsql-master/skills/azure-sql-optimization2Manually: put the files in place
.github/skills/azure-sql-optimization/SKILL.md1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a gemini-cli2Platform CLI
gemini skills install https://github.com/JosiahSiegel/claude-plugin-marketplace --path plugins/tsql-master/skills/azure-sql-optimizationManually: put the files in place
.devin/skills/azure-sql-optimization/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about azure-sql-optimization
How do I install azure-sql-optimization in Claude Code?
Run npx skills add JosiahSiegel/claude-plugin-marketplace --skill azure-sql-optimization -a claude-code, and the skill file lands at ~/.claude/skills/azure-sql-optimization/SKILL.md.
What does azure-sql-optimization do?
It hands the agent ready SQL and step-by-step guidance for Azure SQL Database: tier selection, resource monitoring through DMVs, enabling automatic tuning, and configuring Hyperscale, Serverless and elastic pools.
Which Azure SQL features are missing, and what replaces them?
SQL Agent, linked servers, FILESTREAM and cross-database queries on one server. The skill points to substitutes: Azure Functions for jobs, Elastic Query for linked servers, Blob Storage loading instead of BULK INSERT from a file.
Source text
SKILL.md · MIT
---
name: azure-sql-optimization
description: |
Azure SQL Database optimization and platform-specific features.
PROACTIVELY activate for: (1) Azure SQL Database optimization, (2) DTU vs vCore selection and right-sizing, (3) automatic tuning (force last good plan, create/drop index), (4) Hyperscale tier and read replicas, (5) Serverless tier and auto-pause, (6) Azure SQL performance monitoring (Query Performance Insight, Intelligent Insights), (7) elastic pools, (8) Always Encrypted with secure enclaves, (9) Managed Instance vs Azure SQL DB tradeoffs, (10) failover groups and geo-replication.
Provides: tier-selection matrix, automatic-tuning enablement steps, Hyperscale architecture overview, monitoring queries, and elastic pool sizing guidance.
---
# Azure SQL Database Optimization
Platform-specific optimization for Azure SQL Database.
## Quick Reference
### Service Tier Comparison
| Tier | Best For | Max Size | Key Features |
|------|----------|----------|--------------|
| Basic | Dev/test, light workloads | 2 GB | Low cost |
| Standard | General workloads | 1 TB | S0-S12 DTUs |
| Premium | High I/O, low latency | 4 TB | P1-P15 DTUs |
| General Purpose (vCore) | Most workloads | 16 TB | Serverless option |
| Business Critical | High availability | 4 TB | In-memory, read replicas |
| Hyperscale | Large databases | 100 TB | Auto-scaling storage |
### DTU vs vCore
| Aspect | DTU | vCore |
|--------|-----|-------|
| Pricing | Bundled resources | Separate compute/storage |
| Control | Limited | Fine-grained |
| Reserved capacity | No | Yes (up to 72% savings) |
| Serverless | No | Yes (General Purpose) |
| Best for | Simple workloads | Predictable, migrated workloads |
## Performance Monitoring
### Resource Consumption
```sql
-- Last 15 minutes (avg 15-second intervals)
SELECT
end_time,
avg_cpu_percent,
avg_data_io_percent,
avg_log_write_percent,
avg_memory_usage_percent,
max_worker_percent,
max_session_percent
FROM sys.dm_db_resource_stats
ORDER BY end_time DESC;
-- Historical (last 14 days, hourly)
SELECT
start_time,
end_time,
avg_cpu_percent,
avg_data_io_percent,
avg_log_write_percent
FROM sys.resource_stats
WHERE database_name = DB_NAME()
ORDER BY start_time DESC;
```
### Query Performance Insight
```sql
-- Top CPU consumers last hour
SELECT TOP 20
qt.query_sql_text,
rs.avg_cpu_time / 1000 AS avg_cpu_ms,
rs.count_executions,
rs.avg_cpu_time * rs.count_executions / 1000 AS total_cpu_ms
FROM sys.query_store_query q
JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
JOIN sys.query_store_plan p ON q.query_id = p.query_id
JOIN sys.query_store_runtime_stats rs ON p.plan_id = rs.plan_id
JOIN sys.query_store_runtime_stats_interval rsi ON rs.runtime_stats_interval_id = rsi.runtime_stats_interval_id
WHERE rsi.start_time >= DATEADD(hour, -1, GETUTCDATE())
ORDER BY rs.avg_cpu_time * rs.count_executions DESC;
```
## Automatic Tuning
### Enable Automatic Tuning
```sql
-- Enable all auto-tuning options
ALTER DATABASE current
SET AUTOMATIC_TUNING (
FORCE_LAST_GOOD_PLAN = ON,
CREATE_INDEX = ON,
DROP_INDEX = ON
);
-- Check current settings
SELECT * FROM sys.database_automatic_tuning_options;
```
### View Tuning Recommendations
```sql
-- Current recommendations
SELECT
name,
reason,
score,
state_desc,
is_revertable_action,
is_executable_action,
details
FROM sys.dm_db_tuning_recommendations;
```
### Apply Recommendations
```sql
-- Force a specific query plan
EXEC sp_query_store_force_plan @query_id = 12345, @plan_id = 67890;
-- Unforce plan
EXEC sp_query_store_unforce_plan @query_id = 12345, @plan_id = 67890;
```
## Hyperscale Features
### Storage Auto-Scaling
- Automatically grows up to 128 TB
- No need to pre-provision storage
- Pay only for storage used
### Read Scale-Out
```sql
-- Connection string option
ApplicationIntent=ReadOnly
-- In application code
"Server=myserver.database.windows.net;Database=mydb;ApplicationIntent=ReadOnly;..."
```
### Named Replicas
```sql
-- Create named replica
ALTER DATABASE MyDatabase
ADD SECONDARY ON SERVER MySecondaryServer
WITH (SERVICE_OBJECTIVE = 'HS_Gen5_2', SECONDARY_TYPE = Named, NAME = N'MyReadReplica');
```
## Serverless Configuration
### Configure Auto-Pause
```sql
-- Via Azure Portal, CLI, or PowerShell
-- Set auto-pause delay (minutes), min/max vCores
-- Check current usage
SELECT
cpu_percent,
auto_pause_delay_in_minutes_configured
FROM sys.dm_db_resource_stats_serverless;
```
### Serverless Best Practices
1. **Use for intermittent workloads** - Saves cost during idle periods
2. **Set appropriate min vCores** - Prevents cold starts for time-sensitive apps
3. **Monitor auto-pause** - Auto-resume adds latency
4. **Consider always-on for consistent workloads** - Provisioned may be cheaper
## Connection Optimization
### Connection Pooling
```csharp
// .NET connection string
"Server=tcp:myserver.database.windows.net,1433;Database=mydb;
Min Pool Size=10;Max Pool Size=100;Connection Timeout=30;"
```
### Retry Logic
```csharp
// Azure SQL requires retry logic for transient faults
var options = new SqlRetryLogicOption()
{
NumberOfTries = 5,
DeltaTime = TimeSpan.FromSeconds(1),
MaxTimeInterval = TimeSpan.FromSeconds(30)
};
```
### Connection Best Practices
1. **Use connection pooling** - Reduce connection overhead
2. **Implement retry logic** - Handle transient faults (error 40613, 40197)
3. **Use redirect connection mode** - Better performance after initial connection
4. **Close connections promptly** - Don't hold connections unnecessarily
## Azure-Specific Limitations
### Not Supported
- SQL Agent (use Azure Functions, Logic Apps)
- BULK INSERT from files (use Blob Storage)
- Linked servers (use Elastic Query)
- FILESTREAM
- Cross-database queries in same server (use Elastic Query)
### Workarounds
#### Bulk Insert from Blob Storage
```sql
-- Create credential
CREATE DATABASE SCOPED CREDENTIAL BlobCredential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = 'your_sas_token';
-- Create external data source
CREATE EXTERNAL DATA SOURCE BlobStorage
WITH (
TYPE = BLOB_STORAGE,
LOCATION = 'https://youraccount.blob.core.windows.net/container',
CREDENTIAL = BlobCredential
);
-- Bulk insert
BULK INSERT MyTable
FROM 'data.csv'
WITH (DATA_SOURCE = 'BlobStorage', FORMAT = 'CSV', FIRSTROW = 2);
```
#### Elastic Query for Cross-Database
```sql
-- On target database
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';
CREATE DATABASE SCOPED CREDENTIAL ElasticCredential
WITH IDENTITY = 'username', SECRET = 'password';
CREATE EXTERNAL DATA SOURCE RemoteDB
WITH (
TYPE = RDBMS,
LOCATION = 'remote-server.database.windows.net',
DATABASE_NAME = 'RemoteDatabase',
CREDENTIAL = ElasticCredential
);
CREATE EXTERNAL TABLE dbo.RemoteTable (...)
WITH (DATA_SOURCE = RemoteDB);
```
## Cost Optimization
### Reserved Capacity
- Up to 72% savings vs pay-as-you-go
- 1-year or 3-year terms
- Exchange/refund flexibility
### Right-Sizing
```sql
-- Check if over-provisioned
SELECT
AVG(avg_cpu_percent) AS avg_cpu,
MAX(avg_cpu_percent) AS max_cpu,
AVG(avg_data_io_percent) AS avg_io,
MAX(avg_data_io_percent) AS max_io
FROM sys.dm_db_resource_stats
WHERE end_time >= DATEADD(day, -7, GETUTCDATE());
-- If avg < 40% consistently, consider downsizing
```
### Hyperscale Cost Considerations
- Compute: Per-second billing
- Storage: Per-hour billing for used space
- Read replicas: Additional compute cost
- Memory not automatically released (monitor and scale appropriately)
© JosiahSiegel · MIT · JosiahSiegel/claude-plugin-marketplace