azure-resource-manager-postgresql-dotnet – Writing & Content skill for AI agents
Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments.
Install the azure-resource-manager-postgresql-dotnet skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-resource-manager-postgresql-dotnet-eaf51.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /azure-resource-manager-postgresql-dotnet – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-resource-manager-postgresql-dotnet-eaf51.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $azure-resource-manager-postgresql-dotnet – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-resource-manager-postgresql-dotnet-eaf51.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /azure-resource-manager-postgresql-dotnet – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-resource-manager-postgresql-dotnet-eaf51.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /azure-resource-manager-postgresql-dotnet – then describe the task you want done.
SKILL.md content
Azure.ResourceManager.PostgreSql (.NET)
Azure Resource Manager SDK for managing PostgreSQL Flexible Server deployments.
Installation
dotnet add package Azure.ResourceManager.PostgreSql
dotnet add package Azure.IdentityExample baseline: SDK v1.2.0 / API 2023-12-01-preview. This is not a current-version assertion; select and pin a supported SDK/API for the target subscription and compile these snippets against it.
> Note: This skill focuses on PostgreSQL Flexible Server. Single Server is retired; use Flexible Server and check current regional/version support.
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
AZURE_RESOURCE_GROUP=<your-resource-group>
AZURE_POSTGRESQL_SERVER_NAME=<your-postgresql-server>Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PostgreSql;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
ArmClient client = new ArmClient(new DefaultAzureCredential());Resource Hierarchy
Subscription
└── ResourceGroup
└── PostgreSqlFlexibleServer # PostgreSQL Flexible Server instance
├── PostgreSqlFlexibleServerDatabase # Database within the server
├── PostgreSqlFlexibleServerFirewallRule # IP firewall rules
├── PostgreSqlFlexibleServerConfiguration # Server parameters
├── PostgreSqlFlexibleServerBackup # Backup information
├── PostgreSqlFlexibleServerActiveDirectoryAdministrator # Entra ID admin
└── PostgreSqlFlexibleServerVirtualEndpoint # Read replica endpointsCore Workflows
These are separate illustrative snippets, not one compilable program. Add imports (Azure, Azure.Core, resource-group types) as required by the installed SDK. Confirm subscription/resource IDs, cost, availability and rollback before provisioning or resizing; confirm a recoverable backup and exact target before deletion. ARM credentials manage infrastructure; database connections separately need authorized database roles. Refresh Entra tokens for newly opened pooled connections using Npgsql’s password-provider API rather than retaining one token indefinitely.
1. Create PostgreSQL Flexible Server
using System;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
var subscription = await client.GetDefaultSubscriptionAsync();
ResourceGroupResource resourceGroup = (await subscription.GetResourceGroupAsync("my-resource-group")).Value;
PostgreSqlFlexibleServerCollection servers = resourceGroup.GetPostgreSqlFlexibleServers();
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(AzureLocation.EastUS)
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D2ds_v4", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "pgadmin",
AdministratorLoginPassword = Environment.GetEnvironmentVariable("POSTGRES_ADMIN_PASSWORD") ?? throw new InvalidOperationException("POSTGRES_ADMIN_PASSWORD is required"),
Version = PostgreSqlFlexibleServerVersion.Ver16,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 128,
AutoGrow = StorageAutoGrow.Enabled,
Tier = PostgreSqlStorageTierName.P30
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant,
StandbyAvailabilityZone = "2"
},
AvailabilityZone = "1",
AuthConfig = new PostgreSqlFlexibleServerAuthConfig
{
ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled,
PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled
}
};
ArmOperation<PostgreSqlFlexibleServerResource> operation = await servers
.CreateOrUpdateAsync(WaitUntil.Completed, "my-postgresql-server", data);
PostgreSqlFlexibleServerResource server = operation.Value;
Console.WriteLine($"Server created: {server.Data.FullyQualifiedDomainName}");2. Create Database
PostgreSqlFlexibleServerResource server = await resourceGroup
.GetPostgreSqlFlexibleServerAsync("my-postgresql-server");
PostgreSqlFlexibleServerDatabaseCollection databases = server.GetPostgreSqlFlexibleServerDatabases();
PostgreSqlFlexibleServerDatabaseData dbData = new PostgreSqlFlexibleServerDatabaseData
{
Charset = "UTF8",
Collation = "en_US.utf8"
};
ArmOperation<PostgreSqlFlexibleServerDatabaseResource> operation = await databases
.CreateOrUpdateAsync(WaitUntil.Completed, "myappdb", dbData);
PostgreSqlFlexibleServerDatabaseResource database = operation.Value;
Console.WriteLine($"Database created: {database.Data.Name}");3. Configure Firewall Rules
PostgreSqlFlexibleServerFirewallRuleCollection firewallRules = server.GetPostgreSqlFlexibleServerFirewallRules();
// Public-access firewall rules require the client’s public egress IP, not its private VNet address.
// Example documentation range only; replace with the approved public egress range.
PostgreSqlFlexibleServerFirewallRuleData ruleData = new PostgreSqlFlexibleServerFirewallRuleData
{
StartIPAddress = System.Net.IPAddress.Parse("203.0.113.10"),
EndIPAddress = System.Net.IPAddress.Parse("203.0.113.10")
};
ArmOperation<PostgreSqlFlexibleServerFirewallRuleResource> operation = await firewallRules
.CreateOrUpdateAsync(WaitUntil.Completed, "allow-internal", ruleData);
// OPTIONAL broad exception: 0.0.0.0 allows Azure services from OTHER customers’ subscriptions too.
// Do not apply without explicit approval; prefer specific egress IPs or private networking.
PostgreSqlFlexibleServerFirewallRuleData azureServicesRule = new PostgreSqlFlexibleServerFirewallRuleData
{
StartIPAddress = System.Net.IPAddress.Parse("0.0.0.0"),
EndIPAddress = System.Net.IPAddress.Parse("0.0.0.0")
};
await firewallRules.CreateOrUpdateAsync(WaitUntil.Completed, "AllowAllAzureServicesAndResourcesWithinAzureIps", azureServicesRule);4. Update Server Configuration
PostgreSqlFlexibleServerConfigurationCollection configurations = server.GetPostgreSqlFlexibleServerConfigurations();
// Get current configuration
PostgreSqlFlexibleServerConfigurationResource config = await configurations
.GetAsync("max_connections");
// Update configuration
PostgreSqlFlexibleServerConfigurationData configData = new PostgreSqlFlexibleServerConfigurationData
{
Value = "500",
Source = "user-override"
};
ArmOperation<PostgreSqlFlexibleServerConfigurationResource> operation = await configurations
.CreateOrUpdateAsync(WaitUntil.Completed, "max_connections", configData);
// Common PostgreSQL configurations to tune
string[] commonParams = {
"max_connections",
"shared_buffers",
"work_mem",
"maintenance_work_mem",
"effective_cache_size",
"log_min_duration_statement"
};5. Configure Entra ID Administrator
PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection admins =
server.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators();
PostgreSqlFlexibleServerActiveDirectoryAdministratorData adminData =
new PostgreSqlFlexibleServerActiveDirectoryAdministratorData
{
PrincipalType = PostgreSqlFlexibleServerPrincipalType.User,
PrincipalName = "[email protected]",
TenantId = Guid.Parse("<tenant-id>")
};
ArmOperation<PostgreSqlFlexibleServerActiveDirectoryAdministratorResource> operation = await admins
.CreateOrUpdateAsync(WaitUntil.Completed, "<entra-object-id>", adminData);6. List and Manage Servers
// List servers in resource group
await foreach (PostgreSqlFlexibleServerResource server in resourceGroup.GetPostgreSqlFlexibleServers())
{
Console.WriteLine($"Server: {server.Data.Name}");
Console.WriteLine($" FQDN: {server.Data.FullyQualifiedDomainName}");
Console.WriteLine($" Version: {server.Data.Version}");
Console.WriteLine($" State: {server.Data.State}");
Console.WriteLine($" SKU: {server.Data.Sku.Name} ({server.Data.Sku.Tier})");
Console.WriteLine($" HA: {server.Data.HighAvailability?.Mode}");
}
// List databases in server
await foreach (PostgreSqlFlexibleServerDatabaseResource db in server.GetPostgreSqlFlexibleServerDatabases())
{
Console.WriteLine($"Database: {db.Data.Name}");
}7. Backup and Point-in-Time Restore
// List available backups
await foreach (PostgreSqlFlexibleServerBackupResource backup in server.GetPostgreSqlFlexibleServerBackups())
{
Console.WriteLine($"Backup: {backup.Data.Name}");
Console.WriteLine($" Type: {backup.Data.BackupType}");
Console.WriteLine($" Completed: {backup.Data.CompletedOn}");
}
// Point-in-time restore
PostgreSqlFlexibleServerData restoreData … (full content is in the download package)
Related skills
- on-call-handoff-patterns – Master on-call shift handoffs with context transfer, escalation procedures, and…
- sms – When the user wants to plan, build, or optimize SMS, MMS, or WhatsApp marketing —…
- postmortem-writing – Write effective blameless postmortems with root cause analysis, timelines, and action…
- eu-ai-act-specialist – EU AI Act (Regulation (EU) 2024/1689) operational compliance for compliance teams. Three…
- bash-defensive-patterns – Master defensive Bash programming techniques for production-grade scripts. Use when…
- eu-ai-act-specialist – EU AI Act (Regulation (EU) 2024/1689) operational compliance for compliance teams. Three…
- video – When the user wants to create, generate, or produce video content using AI tools or…
- beautiful-prose – A hard-edged writing style contract for timeless, forceful English prose without modern…