Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for PostgreSQL", "PostgreSQL database management", "PostgreSQL firewall", "PostgreSQL backup", "Postgres".
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
azure-resource-manager-postgresql-dotnet
description
Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for PostgreSQL", "PostgreSQL database management", "PostgreSQL firewall", "PostgreSQL backup", "Postgres".
Current Version: v1.2.0 (GA) API Version: 2023-12-01-preview
Note: This skill focuses on PostgreSQL Flexible Server. Single Server is deprecated and scheduled for retirement.
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id> # Required: Azure subscription ID
AZURE_RESOURCE_GROUP=<your-resource-group> # Required: resource group name
AZURE_POSTGRESQL_SERVER_NAME=<your-postgresql-server> # Required: PostgreSQL Flexible Server name
AZURE_TOKEN_CREDENTIALS=prod
# Required only if DefaultAzureCredential is used in production
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PostgreSql;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// 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();
ArmClient client = new ArmClient(credential);
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 endpoints
Core Workflows
1. Create PostgreSQL Flexible Server
using Azure.ResourceManager.PostgreSql.FlexibleServers;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
ResourceGroupResource resourceGroup = await client
.GetDefaultSubscriptionAsync()
.Result
.GetResourceGroupAsync("my-resource-group");
PostgreSqlFlexibleServerCollection servers = resourceGroup.GetPostgreSqlFlexibleServers();
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(AzureLocation.EastUS)
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D2ds_v4", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "pgadmin",
AdministratorLoginPassword = "YourSecurePassword123!",
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}");