옵션
집 Skill DevOps 및 CI/CD azure-resource-manager-sql-dotnet

azure-resource-manager-sql-dotnet

microsoft/skills microsoft/skills

.NET용 Azure Resource Manager SDK를 사용하여 Azure SQL 리소스(서버, 데이터베이스, 탄력적 풀, 방화벽 규칙, 장애 조치 그룹)를 관리합니다.

...모든 것을 확장하십시오
1
업데이트 된 시간 2026년 9월 18일

Azure.ResourceManager.Sql (.NET)

Azure Resource Manager를 통해 Azure SQL 리소스를 프로비저닝하고 관리하기 위한 관리 플레인 SDK입니다.

⚠️ 관리 플레인 대 데이터 플레인

  • 이 SDK(Azure.ResourceManager.Sql): 서버, 데이터베이스, 탄력적 풀 생성, 방화벽 규칙 구성, 장애 조치 그룹 관리
  • 데이터 플레인 SDK(Microsoft.Data.SqlClient): 쿼리 및 저장 프로시저 실행, 연결 관리

설치

dotnet add package Azure.ResourceManager.Sql
dotnet add package Azure.Identity

현재 버전: 안정 버전 v1.3.0, 미리 보기 버전 v1.4.0-beta.3

환경 변수

AZURE_SUBSCRIPTION_ID= # 필수: Azure 구독 ID
AZURE_TOKEN_CREDENTIALS=prod  # 프로덕션 환경에서 DefaultAzureCredential을 사용하는 경우에만 필수
AZURE_TENANT_ID= # 서비스 주체 인증용 (선택 사항)
AZURE_CLIENT_ID= # 서비스 주체 인증용 (선택 사항)
AZURE_CLIENT_SECRET= # 서비스 주체 인증용 (선택 사항)

인증

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Sql;

// 로컬 개발 환경: DefaultAzureCredential. 프로덕션 환경: AZURE_TOKEN_CREDENTIALS=prod 또는 AZURE_TOKEN_CREDENTIALS=로 설정 
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// 또는 프로덕션 환경에서 특정 자격 증명을 직접 사용:
// https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes 참조
// var credential = new ManagedIdentityCredential();
var armClient = new ArmClient(credential);

// 구독 가져오기
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
    new ResourceIdentifier($"/subscriptions/{subscriptionId}"));

리소스 계층 구조

ArmClient
└── SubscriptionResource
    └── ResourceGroupResource
        └── SqlServerResource
            ├── SqlDatabaseResource
            ├── ElasticPoolResource
            │   └── ElasticPoolDatabaseResource
            ├── SqlFirewallRuleResource
            ├── FailoverGroupResource
            ├── ServerBlobAuditingPolicyResource
            ├── EncryptionProtectorResource
            └── VirtualNetworkRuleResource

핵심 워크플로

1. SQL Server 생성

using Azure.ResourceManager.Sql;
using Azure.ResourceManager.Sql.Models;

// 리소스 그룹 가져오기
var resourceGroup = await subscription
    .GetResourceGroupAsync("my-resource-group");

// 서버 정의
var serverData = new SqlServerData(AzureLocation.EastUS)
{
    AdministratorLogin = "sqladmin",
    AdministratorLoginPassword = "YourSecurePassword123!",
    Version = "12.0",
    MinimalTlsVersion = SqlMinimalTlsVersion.Tls1_2,
    PublicNetworkAccess = ServerNetworkAccessFlag.Enabled
};

// 서버 생성 (장시간 소요되는 작업)
var serverCollection = resourceGroup.Value.GetSqlServers();
var operation = await serverCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "my-sql-server",
    serverData);

SqlServerResource server = operation.Value;

2. SQL 데이터베이스 생성

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. 탄력적 풀 생성

var poolData = new ElasticPoolData(AzureLocation.EastUS)
{
    Sku = new SqlSku("StandardPool")
    {
        Tier = "Standard",
        Capacity = 100 // 100 eDTU
    },
    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. Elastic Pool에 데이터베이스 추가

var databaseData = new SqlDatabaseData(AzureLocation.EastUS)
{
    ElasticPoolId = pool.Id
};

await databaseCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "pooled-database",
    databaseData);

5. 방화벽 규칙 구성

// Azure 서비스 허용
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);

// 특정 IP 범위 허용
var clientRule = new SqlFirewallRuleData
{
    StartIPAddress = "203.0.113.0",
    EndIPAddress = "203.0.113.255"
};

await firewallCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "AllowClientIPs",
    clientRule);

6. 리소스 나열

// 구독 내의 모든 서버 나열
await foreach (var srv in subscription.GetSqlServersAsync())
{
    Console.WriteLine($"서버: {srv.Data.Name}, 위치: {srv.Data.Location}");
}

// 서버 내 데이터베이스 나열
await foreach (var db in server.GetSqlDatabases())
{
    Console.WriteLine($"데이터베이스: {db.Data.Name}, SKU: {db.Data.Sku?.Name}");
}

// 엘라스틱 풀 나열
await foreach (var ep in server.GetElasticPools())
{
    Console.WriteLine($"풀: {ep.Data.Name}, DTU: {ep.Data.Sku?.Capacity}");
}

7. 연결 문자열 가져오기

// 연결 문자열 생성 (서버 FQDN은 예측 가능)
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=;" +
    "MultipleActiveResultSets=False;" +
    "Encrypt=True;" +
    "TrustServerCertificate=False;" +
    "Connection Timeout=30;";

키 유형 참조

유형 용도
ArmClient 모든 ARM 작업의 진입점
SqlServerResource Azure SQL 서버를 나타냅니다
SqlServerCollection 서버 CRUD를 위한 컬렉션
SqlDatabaseResource SQL 데이터베이스를 나타냅니다
SqlDatabaseCollection 데이터베이스 CRUD용 컬렉션
ElasticPoolResource 탄력적 풀을 나타냅니다
ElasticPoolCollection 엘라스틱 풀 CRUD용 컬렉션
SqlFirewallRuleResource 방화벽 규칙을 나타냅니다
SqlFirewallRuleCollection 방화벽 규칙 CRUD를 위한 컬렉션
SqlServerData 서버 생성/업데이트 페이로드
SqlDatabaseData 데이터베이스 생성/업데이트 페이로드
ElasticPoolData 탄력적 풀 생성/업데이트 페이로드
SqlFirewallRuleData 방화벽 규칙 생성/업데이트 페이로드
SqlSku SKU 구성(계층, 용량)

일반 SKU

데이터베이스 SKU

SKU 이름 계층 설명
기본 기본 5 DTU, 최대 2 GB
S0-S12 표준 10~3000 DTU
P1-P15 프리미엄 125-4000 DTU
GP_Gen5_2 범용 vCore 기반, 2개의 vCore
BC_Gen5_2 비즈니스 크리티컬 vCore 기반, 2개의 vCore
HS_Gen5_2 하이퍼스케일 vCore 기반, vCore 2개

탄력적 풀 SKU

SKU 이름 계층 설명
BasicPool 기본 50~1,600 eDTU
StandardPool StandardPool 50~3000 eDTU
프리미엄 풀 프리미엄 125~4,000 eDTU
GP_Gen5_2 GeneralPurpose vCore 기반
BC_Gen5_2 비즈니스 크리티컬 vCore 기반

모범 사례

  1. 진행하기 전에 반드시 완료되어야 하는 작업에는 WaitUntil.Completed를 사용하십시오
  2. 수동으로 폴링하거나 작업을 병렬로 실행하려는 경우 WaitUntil.Started를 사용하십시오
  3. 항상 DefaultAzureCredential을 사용하십시오. 프로덕션 환경에서는 절대로 비밀번호를 하드코딩하지 마십시오
  4. ARM API 오류가 발생하면 RequestFailedException을 처리하십시오
  5. 이멧포텐트 작업에는 CreateOrUpdateAsync를 사용하십시오
  6. Get* 메서드(예: server.GetSqlDatabases())를 통해계층 구조를 탐색하십시오
  7. 여러 데이터베이스를 관리할 때 비용 최적화를 위해탄력적 풀을 사용하십시오
  8. 연결을 시도하기 전에방화벽 규칙을 구성하십시오

오류 처리

using Azure;

try
{
    var operation = await serverCollection.CreateOrUpdateAsync(
        WaitUntil.Completed, serverName, serverData);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
    Console.WriteLine("서버가 이미 존재합니다");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
    Console.WriteLine($"잘못된 요청: {ex.Message}");
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"ARM 오류: {ex.Status} - {ex.ErrorCode}: {ex.Message}");
}

참조 파일

파일 읽어야 할 시기
references/server-management.md 서버 CRUD, 관리자 자격 증명, Azure AD 인증, 네트워킹
references/database-operations.md 데이터베이스 CRUD, 확장, 백업, 복원, 복사
references/elastic-pools.md 풀 관리, 데이터베이스 추가/제거, 확장

관련 SDK

SDK 목적 설치
Microsoft.Data.SqlClient 데이터 플레인(쿼리 및 저장 프로시저 실행) dotnet add package Microsoft.Data.SqlClient
Azure.ResourceManager.Sql 관리 계층(이 SDK) dotnet add package Azure.ResourceManager.Sql
Microsoft.EntityFrameworkCore.SqlServer SQL Server용 ORM dotnet add package Microsoft.EntityFrameworkCore.SqlServer
GitHub에서 보기
---
name: azure-resource-manager-sql-dotnet
description: Manage Azure SQL resources (servers, databases, elastic pools, firewall rules, failover groups) using the Azure Resource Manager SDK for .NET.
license: MIT
---

# 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

```bash
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

```bash
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

```csharp
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

```csharp
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

```csharp
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

```csharp
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

```csharp
var databaseData = new SqlDatabaseData(AzureLocation.EastUS)
{
    ElasticPoolId = pool.Id
};

await databaseCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "pooled-database",
    databaseData);
```

### 5. Configure Firewall Rules

```csharp
// 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

```csharp
// 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

```csharp
// 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

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

```csharp
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](references/server-management.md) | Server CRUD, admin credentials, Azure AD auth, networking |
| [references/database-operations.md](references/database-operations.md) | Database CRUD, scaling, backup, restore, copy |
| [references/elastic-pools.md](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` |

모든 파일

0개 파일

azure-resource-manager-sql-dotnet 설치

스킬 파일을 다운로드하여 .claude/skills/ 디렉터리에 압축을 풀어주세요.

ZIP 다운로드

저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.

git clone https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-resource-manager-sql-dotnet # Copy SKILL.md to your .claude/skills/ directory

복사 복사
빠른 설정: 스킬 폴더를 .claude/skills/로 복사하세요. Claude가 해당 스킬을 자동으로 감지하여 사용할 것입니다.
저장소 microsoft/skills

관련 스킬

Verification &amp; Quality Assurance
업데이트 된 시간 2026년 6월 29일
base44-cli
업데이트 된 시간 2026년 6월 29일
klingai-upgrade-migration
업데이트 된 시간 2026년 7월 3일
Railway CLI Management
업데이트 된 시간 2026년 7월 2일
OR