Crea un nuovo server.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2025-08-01
Parametri dell'URI
| Nome |
In |
Necessario |
Tipo |
Descrizione |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Nome del gruppo di risorse. Il nome è insensibile alle maiuscole e minuscole.
|
|
serverName
|
path |
True
|
string
minLength: 3 maxLength: 63 pattern: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
Il nome del server.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
ID della sottoscrizione di destinazione. Il valore deve essere un UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Versione dell'API da usare per questa operazione.
|
Corpo della richiesta
| Nome |
Necessario |
Tipo |
Descrizione |
|
location
|
True
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
identity
|
|
UserAssignedIdentity
|
Identità gestite assegnate dall'utente al server.
|
|
properties.administratorLogin
|
|
string
|
Nome dell'account di accesso designato come primo amministratore basato su password assegnato all'istanza di PostgreSQL. Deve essere specificato la prima volta che si abilita l'autenticazione basata su password in un server. Una volta impostato su un determinato valore, non può essere modificato per il resto della vita di un server. Se si disabilita l'autenticazione basata su password in un server in cui è abilitata, questo ruolo basato su password non viene eliminato.
|
|
properties.administratorLoginPassword
|
|
string
(password)
|
Password assegnata all'accesso amministratore. Finché l'autenticazione tramite password è abilitata, questa password può essere modificata in qualsiasi momento.
|
|
properties.authConfig
|
|
AuthConfig
|
Proprietà di configurazione dell'autenticazione di un server.
|
|
properties.availabilityZone
|
|
string
|
Zona di disponibilità di un server.
|
|
properties.backup
|
|
Backup
|
Proprietà di backup di un server.
|
|
properties.cluster
|
|
Cluster
|
Proprietà del cluster di un server.
|
|
properties.createMode
|
|
CreateMode
|
Modalità di creazione di un nuovo server.
|
|
properties.dataEncryption
|
|
DataEncryption
|
Proprietà di crittografia dei dati di un server.
|
|
properties.highAvailability
|
|
HighAvailability
|
Proprietà a disponibilità elevata di un server.
|
|
properties.maintenanceWindow
|
|
MaintenanceWindow
|
Proprietà della finestra di manutenzione di un server.
|
|
properties.network
|
|
Network
|
Proprietà di rete di un server. Necessario solo se si desidera che il server sia integrato in una rete virtuale fornita dal cliente.
|
|
properties.pointInTimeUTC
|
|
string
(date-time)
|
Ora di creazione (in formato ISO8601) del backup che si desidera ripristinare nel nuovo server. È necessario quando 'createMode' è 'PointInTimeRestore', 'GeoRestore' o 'ReviveDropped'.
|
|
properties.replica
|
|
Replica
|
Leggi le proprietà della replica di un server. Obbligatorio solo nel caso in cui si desideri promuovere un server.
|
|
properties.replicationRole
|
|
ReplicationRole
|
Ruolo del server in un set di replica.
|
|
properties.sourceServerResourceId
|
|
string
(arm-id)
|
Identificatore del server da utilizzare come origine del nuovo server. Obbligatorio quando 'createMode' è 'PointInTimeRestore', 'GeoRestore', 'Replica' o 'ReviveDropped'. Questa proprietà viene restituita solo quando il server di destinazione è una replica di lettura.
|
|
properties.storage
|
|
Storage
|
Proprietà di archiviazione di un server.
|
|
properties.version
|
|
PostgresMajorVersion
|
Versione principale del motore di database PostgreSQL.
|
|
sku
|
|
Sku
|
Livello di calcolo e dimensioni di un server.
|
|
tags
|
|
object
|
Tag di risorsa.
|
Risposte
| Nome |
Tipo |
Descrizione |
|
202 Accepted
|
|
Operazione di risorsa accettata.
Intestazioni
- Azure-AsyncOperation: string
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Risposta di errore imprevista.
|
Sicurezza
azure_auth
Azure Active Directory OAuth2 Flow.
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
| Nome |
Descrizione |
|
user_impersonation
|
rappresentare l'account utente
|
Esempio
Create a new elastic cluster.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"administratorLogin": "examplelogin",
"administratorLoginPassword": "examplepassword",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"cluster": {
"clusterSize": 2,
"defaultDatabaseName": "clusterdb"
},
"createMode": "Create",
"highAvailability": {
"mode": "Disabled"
},
"network": {
"publicNetworkAccess": "Disabled"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 256,
"tier": "P15"
},
"version": "16"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Cluster;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ServerPublicNetworkAccessState;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersClusterCreate.json
*/
/**
* Sample code: Create a new elastic cluster.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createANewElasticCluster(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withAdministratorLogin("examplelogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SIX)
.withStorage(new Storage().withStorageSizeGB(256).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P15))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.DISABLED))
.withNetwork(new Network().withPublicNetworkAccess(ServerPublicNetworkAccessState.DISABLED))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.fromString("Disabled")))
.withCreateMode(CreateMode.CREATE)
.withCluster(new Cluster().withClusterSize(2).withDefaultDatabaseName("clusterdb")).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_cluster_create.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"administratorLogin": "examplelogin",
"administratorLoginPassword": "examplepassword",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"cluster": {"clusterSize": 2, "defaultDatabaseName": "clusterdb"},
"createMode": "Create",
"highAvailability": {"mode": "Disabled"},
"network": {"publicNetworkAccess": "Disabled"},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 256, "tier": "P15"},
"version": "16",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersClusterCreate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersClusterCreate.json
func ExampleServersClient_BeginCreateOrUpdate_createANewElasticCluster() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("examplelogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupDisabled),
},
Cluster: &armpostgresqlflexibleservers.Cluster{
ClusterSize: to.Ptr[int32](2),
DefaultDatabaseName: to.Ptr("clusterdb"),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityMode("Disabled")),
},
Network: &armpostgresqlflexibleservers.Network{
PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](256),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP15),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSixteen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersClusterCreate.json
*/
async function createANewElasticCluster() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "examplelogin",
administratorLoginPassword: "examplepassword",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Disabled" },
cluster: { clusterSize: 2, defaultDatabaseName: "clusterdb" },
createMode: "Create",
highAvailability: { mode: "Disabled" },
location: "eastus",
network: { publicNetworkAccess: "Disabled" },
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 256, tier: "P15" },
version: "16",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersClusterCreate.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "examplelogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Sixteen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 256,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P15,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
PublicNetworkAccess = PostgreSqlFlexibleServerPublicNetworkAccessState.Disabled,
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.Disabled,
},
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
Cluster = new PostgreSqlFlexibleServerClusterProperties
{
ClusterSize = 2,
DefaultDatabaseName = "clusterdb",
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server in Microsoft owned virtual network with zone redundant high availability.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Enabled"
},
"createMode": "Create",
"highAvailability": {
"mode": "ZoneRedundant"
},
"network": {
"publicNetworkAccess": "Enabled"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 512,
"tier": "P20"
},
"version": "17"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
},
"tags": {
"InCustomerVnet": "false",
"InMicrosoftVnet": "true"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ServerPublicNetworkAccessState;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json
*/
/**
* Sample code: Create a new server in Microsoft owned virtual network with zone redundant high availability.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withTags(mapOf("InCustomerVnet", "false", "InMicrosoftVnet", "true"))
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withAdministratorLogin("exampleadministratorlogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SEVEN)
.withStorage(new Storage().withStorageSizeGB(512).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P20))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.ENABLED))
.withNetwork(new Network().withPublicNetworkAccess(ServerPublicNetworkAccessState.ENABLED))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.ZONE_REDUNDANT))
.withAvailabilityZone("1").withCreateMode(CreateMode.CREATE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_in_microsoft_owned_virtual_network_with_zone_redundant_high_availability.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Enabled"},
"createMode": "Create",
"highAvailability": {"mode": "ZoneRedundant"},
"network": {"publicNetworkAccess": "Enabled"},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 512, "tier": "P20"},
"version": "17",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
"tags": {"InCustomerVnet": "false", "InMicrosoftVnet": "true"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Tags: map[string]*string{
"InCustomerVnet": to.Ptr("false"),
"InMicrosoftVnet": to.Ptr("true"),
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("exampleadministratorlogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
AvailabilityZone: to.Ptr("1"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupEnabled),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
},
Network: &armpostgresqlflexibleservers.Network{
PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateEnabled),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](512),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP20),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSeventeen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json
*/
async function createANewServerInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "exampleadministratorlogin",
administratorLoginPassword: "examplepassword",
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Enabled" },
createMode: "Create",
highAvailability: { mode: "ZoneRedundant" },
location: "eastus",
network: { publicNetworkAccess: "Enabled" },
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 512, tier: "P20" },
tags: { inCustomerVnet: "false", inMicrosoftVnet: "true" },
version: "17",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "exampleadministratorlogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Seventeen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 512,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P20,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Enabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
PublicNetworkAccess = PostgreSqlFlexibleServerPublicNetworkAccessState.Enabled,
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant,
},
AvailabilityZone = "1",
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
Tags =
{
["InCustomerVnet"] = "false",
["InMicrosoftVnet"] = "true"
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server in your own virtual network with same zone high availability.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Enabled"
},
"createMode": "Create",
"highAvailability": {
"mode": "SameZone"
},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 512,
"tier": "P20"
},
"version": "17"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
},
"tags": {
"InCustomerVnet": "true",
"InMicrosoftVnet": "false"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json
*/
/**
* Sample code: Create a new server in your own virtual network with same zone high availability.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerInYourOwnVirtualNetworkWithSameZoneHighAvailability(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withTags(mapOf("InCustomerVnet", "true", "InMicrosoftVnet", "false"))
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withAdministratorLogin("exampleadministratorlogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SEVEN)
.withStorage(new Storage().withStorageSizeGB(512).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P20))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.ENABLED))
.withNetwork(new Network().withDelegatedSubnetResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet")
.withPrivateDnsZoneArmResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database"))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.SAME_ZONE))
.withAvailabilityZone("1").withCreateMode(CreateMode.CREATE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_in_your_own_virtual_network_with_same_zone_high_availability.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Enabled"},
"createMode": "Create",
"highAvailability": {"mode": "SameZone"},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database",
},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 512, "tier": "P20"},
"version": "17",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
"tags": {"InCustomerVnet": "true", "InMicrosoftVnet": "false"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerInYourOwnVirtualNetworkWithSameZoneHighAvailability() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Tags: map[string]*string{
"InCustomerVnet": to.Ptr("true"),
"InMicrosoftVnet": to.Ptr("false"),
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("exampleadministratorlogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
AvailabilityZone: to.Ptr("1"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupEnabled),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeSameZone),
},
Network: &armpostgresqlflexibleservers.Network{
DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database"),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](512),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP20),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSeventeen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json
*/
async function createANewServerInYourOwnVirtualNetworkWithSameZoneHighAvailability() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "exampleadministratorlogin",
administratorLoginPassword: "examplepassword",
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Enabled" },
createMode: "Create",
highAvailability: { mode: "SameZone" },
location: "eastus",
network: {
delegatedSubnetResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
privateDnsZoneArmResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database",
},
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 512, tier: "P20" },
tags: { inCustomerVnet: "true", inMicrosoftVnet: "false" },
version: "17",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "exampleadministratorlogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Seventeen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 512,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P20,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Enabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.private.postgres.database"),
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.SameZone,
},
AvailabilityZone = "1",
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
Tags =
{
["InCustomerVnet"] = "true",
["InMicrosoftVnet"] = "false"
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server using a backup of a server that was deleted or dropped recently.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"createMode": "ReviveDropped",
"pointInTimeUTC": "2025-06-01T18:30:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateReviveDropped.json
*/
/**
* Sample code: Create a new server using a backup of a server that was deleted or dropped recently.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerUsingABackupOfAServerThatWasDeletedOrDroppedRecently(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSourceServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver")
.withPointInTimeUtc(OffsetDateTime.parse("2025-06-01T18:30:22.123456Z"))
.withCreateMode(CreateMode.REVIVE_DROPPED).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_revive_dropped.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"createMode": "ReviveDropped",
"pointInTimeUTC": "2025-06-01T18:30:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver",
},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReviveDropped.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReviveDropped.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerUsingABackupOfAServerThatWasDeletedOrDroppedRecently() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeReviveDropped),
PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReviveDropped.json
*/
async function createANewServerUsingABackupOfAServerThatWasDeletedOrDroppedRecently() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
createMode: "ReviveDropped",
location: "eastus",
pointInTimeUTC: new Date("2025-06-01T18:30:22.123456Z"),
sourceServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReviveDropped.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampledeletedserver"),
PointInTimeUtc = DateTimeOffset.Parse("2025-06-01T18:30:22.123456Z"),
CreateMode = PostgreSqlFlexibleServerCreateMode.ReviveDropped,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server using a point in time restore of a backup of an existing server.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"createMode": "PointInTimeRestore",
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreatePointInTimeRestore.json
*/
/**
* Sample code: Create a new server using a point in time restore of a backup of an existing server.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerUsingAPointInTimeRestoreOfABackupOfAnExistingServer(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSourceServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver")
.withPointInTimeUtc(OffsetDateTime.parse("2025-06-01T18:35:22.123456Z"))
.withCreateMode(CreateMode.POINT_IN_TIME_RESTORE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_point_in_time_restore.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"createMode": "PointInTimeRestore",
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreatePointInTimeRestore.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreatePointInTimeRestore.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerUsingAPointInTimeRestoreOfABackupOfAnExistingServer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModePointInTimeRestore),
PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreatePointInTimeRestore.json
*/
async function createANewServerUsingAPointInTimeRestoreOfABackupOfAnExistingServer() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
createMode: "PointInTimeRestore",
location: "eastus",
pointInTimeUTC: new Date("2025-06-01T18:35:22.123456Z"),
sourceServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreatePointInTimeRestore.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
PointInTimeUtc = DateTimeOffset.Parse("2025-06-01T18:35:22.123456Z"),
CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server using a restore of a geographically redundant backup of an existing server, with data encryption based on customer managed key with automatic key version update.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
}
},
"location": "eastus",
"properties": {
"createMode": "GeoRestore",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"
},
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json
*/
/**
* Sample code: Create a new server using a restore of a geographically redundant backup of an existing server, with
* data encryption based on customer managed key with automatic key version update.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
new UserIdentity(),
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder")
.withGeoBackupUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity")
.withType(DataEncryptionType.AZURE_KEY_VAULT))
.withSourceServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver")
.withPointInTimeUtc(OffsetDateTime.parse("2025-06-01T18:35:22.123456Z"))
.withCreateMode(CreateMode.GEO_RESTORE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_geo_restore_with_data_encryption_enabled_auto_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
"location": "eastus",
"properties": {
"createMode": "GeoRestore",
"dataEncryption": {
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"type": "AzureKeyVault",
},
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeGeoRestore),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr("https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey"),
GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity"),
PrimaryKeyURI: to.Ptr("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
},
PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json
*/
async function createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
createMode: "GeoRestore",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI: "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey",
geoBackupUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
primaryKeyURI: "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/examplegeoredundantidentity":
{},
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/exampleprimaryidentity":
{},
},
},
location: "eastus",
pointInTimeUTC: new Date("2025-06-01T18:35:22.123456Z"),
sourceServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity"] = new UserAssignedIdentity(),
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"] = new UserAssignedIdentity()
},
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
PrimaryKeyUri = new Uri("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
GeoBackupKeyUri = new Uri("https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey"),
GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
PointInTimeUtc = DateTimeOffset.Parse("2025-06-01T18:35:22.123456Z"),
CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server using a restore of a geographically redundant backup of an existing server, with data encryption based on customer managed key.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
}
},
"location": "eastus",
"properties": {
"createMode": "GeoRestore",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"
},
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateGeoRestoreWithDataEncryptionEnabled.json
*/
/**
* Sample code: Create a new server using a restore of a geographically redundant backup of an existing server, with
* data encryption based on customer managed key.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKey(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
new UserIdentity(),
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder")
.withGeoBackupUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity")
.withType(DataEncryptionType.AZURE_KEY_VAULT))
.withSourceServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver")
.withPointInTimeUtc(OffsetDateTime.parse("2025-06-01T18:35:22.123456Z"))
.withCreateMode(CreateMode.GEO_RESTORE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_geo_restore_with_data_encryption_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
"location": "eastus",
"properties": {
"createMode": "GeoRestore",
"dataEncryption": {
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"type": "AzureKeyVault",
},
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabled.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKey() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeGeoRestore),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr("https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"),
GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity"),
PrimaryKeyURI: to.Ptr("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
},
PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabled.json
*/
async function createANewServerUsingARestoreOfAGeographicallyRedundantBackupOfAnExistingServerWithDataEncryptionBasedOnCustomerManagedKey() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
createMode: "GeoRestore",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI:
"https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
geoBackupUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
primaryKeyURI:
"https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/examplegeoredundantidentity":
{},
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/exampleprimaryidentity":
{},
},
},
location: "eastus",
pointInTimeUTC: new Date("2025-06-01T18:35:22.123456Z"),
sourceServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabled.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity"] = new UserAssignedIdentity(),
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"] = new UserAssignedIdentity()
},
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
PrimaryKeyUri = new Uri("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
GeoBackupKeyUri = new Uri("https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"),
GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
PointInTimeUtc = DateTimeOffset.Parse("2025-06-01T18:35:22.123456Z"),
CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server with data encryption based on customer managed key with automatic key version update.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
}
},
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Create",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"
},
"highAvailability": {
"mode": "ZoneRedundant"
},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 512,
"tier": "P20"
},
"version": "17"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateWithDataEncryptionEnabledAutoUpdate.json
*/
/**
* Sample code: Create a new server with data encryption based on customer managed key with automatic key version
* update.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withAdministratorLogin("exampleadministratorlogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SEVEN)
.withStorage(new Storage().withStorageSizeGB(512).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P20))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder").withGeoBackupUserAssignedIdentityId("")
.withType(DataEncryptionType.AZURE_KEY_VAULT))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.DISABLED))
.withNetwork(new Network().withDelegatedSubnetResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet")
.withPrivateDnsZoneArmResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.ZONE_REDUNDANT))
.withAvailabilityZone("1").withCreateMode(CreateMode.CREATE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_with_data_encryption_enabled_auto_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
},
},
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Create",
"dataEncryption": {
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"type": "AzureKeyVault",
},
"highAvailability": {"mode": "ZoneRedundant"},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 512, "tier": "P20"},
"version": "17",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabledAutoUpdate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabledAutoUpdate.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("exampleadministratorlogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
AvailabilityZone: to.Ptr("1"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupDisabled),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr(""),
GeoBackupUserAssignedIdentityID: to.Ptr(""),
PrimaryKeyURI: to.Ptr("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
},
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
},
Network: &armpostgresqlflexibleservers.Network{
DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](512),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP20),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSeventeen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabledAutoUpdate.json
*/
async function createANewServerWithDataEncryptionBasedOnCustomerManagedKeyWithAutomaticKeyVersionUpdate() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "exampleadministratorlogin",
administratorLoginPassword: "examplepassword",
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Disabled" },
createMode: "Create",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI: "",
geoBackupUserAssignedIdentityId: "",
primaryKeyURI: "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
},
highAvailability: { mode: "ZoneRedundant" },
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/exampleprimaryidentity":
{},
},
},
location: "eastus",
network: {
delegatedSubnetResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
privateDnsZoneArmResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 512, tier: "P20" },
version: "17",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabledAutoUpdate.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"] = new UserAssignedIdentity()
},
},
AdministratorLogin = "exampleadministratorlogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Seventeen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 512,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P20,
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
PrimaryKeyUri = new Uri("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
GeoBackupKeyUri = new Uri(""),
GeoBackupUserAssignedIdentityId = "",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant,
},
AvailabilityZone = "1",
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server with data encryption based on customer managed key.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
}
},
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Create",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"
},
"highAvailability": {
"mode": "ZoneRedundant"
},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 512,
"tier": "P20"
},
"version": "17"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateWithDataEncryptionEnabled.json
*/
/**
* Sample code: Create a new server with data encryption based on customer managed key.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createANewServerWithDataEncryptionBasedOnCustomerManagedKey(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withAdministratorLogin("exampleadministratorlogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SEVEN)
.withStorage(new Storage().withStorageSizeGB(512).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P20))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder").withGeoBackupUserAssignedIdentityId("")
.withType(DataEncryptionType.AZURE_KEY_VAULT))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.DISABLED))
.withNetwork(new Network().withDelegatedSubnetResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet")
.withPrivateDnsZoneArmResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.ZONE_REDUNDANT))
.withAvailabilityZone("1").withCreateMode(CreateMode.CREATE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_with_data_encryption_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
},
},
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"availabilityZone": "1",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Create",
"dataEncryption": {
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"type": "AzureKeyVault",
},
"highAvailability": {"mode": "ZoneRedundant"},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 512, "tier": "P20"},
"version": "17",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabled.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerWithDataEncryptionBasedOnCustomerManagedKey() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("exampleadministratorlogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
AvailabilityZone: to.Ptr("1"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupDisabled),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr(""),
GeoBackupUserAssignedIdentityID: to.Ptr(""),
PrimaryKeyURI: to.Ptr("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
},
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
},
Network: &armpostgresqlflexibleservers.Network{
DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](512),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP20),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSeventeen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabled.json
*/
async function createANewServerWithDataEncryptionBasedOnCustomerManagedKey() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "exampleadministratorlogin",
administratorLoginPassword: "examplepassword",
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Disabled" },
createMode: "Create",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI: "",
geoBackupUserAssignedIdentityId: "",
primaryKeyURI:
"https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
},
highAvailability: { mode: "ZoneRedundant" },
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/exampleprimaryidentity":
{},
},
},
location: "eastus",
network: {
delegatedSubnetResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
privateDnsZoneArmResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 512, tier: "P20" },
version: "17",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabled.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"] = new UserAssignedIdentity()
},
},
AdministratorLogin = "exampleadministratorlogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Seventeen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 512,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P20,
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
PrimaryKeyUri = new Uri("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
GeoBackupKeyUri = new Uri(""),
GeoBackupUserAssignedIdentityId = "",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant,
},
AvailabilityZone = "1",
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a new server with Microsoft Entra authentication enabled in your own virtual network and without high availability.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt"
},
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Create",
"dataEncryption": {
"type": "SystemManaged"
},
"highAvailability": {
"mode": "Disabled"
},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"storage": {
"autoGrow": "Disabled",
"storageSizeGB": 512,
"tier": "P20"
},
"version": "17"
},
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AuthConfig;
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.GeographicallyRedundantBackup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.postgresqlflexibleserver.models.HighAvailabilityMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MicrosoftEntraAuth;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Network;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PasswordBasedAuth;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PostgresMajorVersion;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json
*/
/**
* Sample code: Create a new server with Microsoft Entra authentication enabled in your own virtual network and
* without high availability.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createANewServerWithMicrosoftEntraAuthenticationEnabledInYourOwnVirtualNetworkAndWithoutHighAvailability(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withSku(new Sku().withName("Standard_D4ds_v5").withTier(SkuTier.GENERAL_PURPOSE))
.withAdministratorLogin("exampleadministratorlogin").withAdministratorLoginPassword("examplepassword")
.withVersion(PostgresMajorVersion.ONE_SEVEN)
.withStorage(new Storage().withStorageSizeGB(512).withAutoGrow(StorageAutoGrow.DISABLED)
.withTier(AzureManagedDiskPerformanceTier.P20))
.withAuthConfig(new AuthConfig().withActiveDirectoryAuth(MicrosoftEntraAuth.ENABLED)
.withPasswordAuth(PasswordBasedAuth.ENABLED).withTenantId("tttttt-tttt-tttt-tttt-tttttttttttt"))
.withDataEncryption(new DataEncryption().withType(DataEncryptionType.SYSTEM_MANAGED))
.withBackup(
new Backup().withBackupRetentionDays(7).withGeoRedundantBackup(GeographicallyRedundantBackup.DISABLED))
.withNetwork(new Network().withDelegatedSubnetResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet")
.withPrivateDnsZoneArmResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"))
.withHighAvailability(new HighAvailability().withMode(HighAvailabilityMode.fromString("Disabled")))
.withAvailabilityZone("1").withCreateMode(CreateMode.CREATE).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_with_microsoft_entra_enabled_in_your_own_virtual_network_without_high_availability.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"location": "eastus",
"properties": {
"administratorLogin": "exampleadministratorlogin",
"administratorLoginPassword": "examplepassword",
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt",
},
"availabilityZone": "1",
"backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Create",
"dataEncryption": {"type": "SystemManaged"},
"highAvailability": {"mode": "Disabled"},
"network": {
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
"storage": {"autoGrow": "Disabled", "storageSizeGB": 512, "tier": "P20"},
"version": "17",
},
"sku": {"name": "Standard_D4ds_v5", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json
func ExampleServersClient_BeginCreateOrUpdate_createANewServerWithMicrosoftEntraAuthenticationEnabledInYourOwnVirtualNetworkAndWithoutHighAvailability() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("exampleadministratorlogin"),
AdministratorLoginPassword: to.Ptr("examplepassword"),
AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.MicrosoftEntraAuthEnabled),
PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordBasedAuthEnabled),
TenantID: to.Ptr("tttttt-tttt-tttt-tttt-tttttttttttt"),
},
AvailabilityZone: to.Ptr("1"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeographicallyRedundantBackupDisabled),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeSystemManaged),
},
HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityMode("Disabled")),
},
Network: &armpostgresqlflexibleservers.Network{
DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
StorageSizeGB: to.Ptr[int32](512),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTierP20),
},
Version: to.Ptr(armpostgresqlflexibleservers.PostgresMajorVersionSeventeen),
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D4ds_v5"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json
*/
async function createANewServerWithMicrosoftEntraAuthenticationEnabledInYourOwnVirtualNetworkAndWithoutHighAvailability() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
administratorLogin: "exampleadministratorlogin",
administratorLoginPassword: "examplepassword",
authConfig: {
activeDirectoryAuth: "Enabled",
passwordAuth: "Enabled",
tenantId: "tttttt-tttt-tttt-tttt-tttttttttttt",
},
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Disabled" },
createMode: "Create",
dataEncryption: { type: "SystemManaged" },
highAvailability: { mode: "Disabled" },
location: "eastus",
network: {
delegatedSubnetResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
privateDnsZoneArmResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com",
},
sku: { name: "Standard_D4ds_v5", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", storageSizeGB: 512, tier: "P20" },
version: "17",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D4ds_v5", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "exampleadministratorlogin",
AdministratorLoginPassword = "examplepassword",
Version = PostgreSqlFlexibleServerVersion.Seventeen,
Storage = new PostgreSqlFlexibleServerStorage
{
StorageSizeInGB = 512,
AutoGrow = StorageAutoGrow.Disabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P20,
},
AuthConfig = new PostgreSqlFlexibleServerAuthConfig
{
ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled,
PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled,
TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"),
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
KeyType = PostgreSqlFlexibleServerKeyType.SystemManaged,
},
Backup = new PostgreSqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7,
GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled,
},
Network = new PostgreSqlFlexibleServerNetwork
{
DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet"),
PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"),
},
HighAvailability = new PostgreSqlFlexibleServerHighAvailability
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.Disabled,
},
AvailabilityZone = "1",
CreateMode = PostgreSqlFlexibleServerCreateMode.Create,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Create a read replica of an existing server.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2025-08-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
}
},
"location": "eastus",
"properties": {
"createMode": "Replica",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"
},
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryptionType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersCreateReplica.json
*/
/**
* Sample code: Create a read replica of an existing server.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAReadReplicaOfAnExistingServer(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().define("exampleserver").withRegion("eastus").withExistingResourceGroup("exampleresourcegroup")
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder").withGeoBackupUserAssignedIdentityId("")
.withType(DataEncryptionType.AZURE_KEY_VAULT))
.withSourceServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver")
.withPointInTimeUtc(OffsetDateTime.parse("2025-06-01T18:35:22.123456Z")).withCreateMode(CreateMode.REPLICA)
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_create_replica.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create_or_update(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {}
},
},
"location": "eastus",
"properties": {
"createMode": "Replica",
"dataEncryption": {
"geoBackupKeyURI": "",
"geoBackupUserAssignedIdentityId": "",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"type": "AzureKeyVault",
},
"pointInTimeUTC": "2025-06-01T18:35:22.123456Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReplica.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e96c24570a484cff13d153fb472f812878866a39/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReplica.json
func ExampleServersClient_BeginCreateOrUpdate_createAReadReplicaOfAnExistingServer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreateOrUpdate(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.Server{
Location: to.Ptr("eastus"),
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeReplica),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr(""),
GeoBackupUserAssignedIdentityID: to.Ptr(""),
PrimaryKeyURI: to.Ptr("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
},
PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Creates a new server.
*
* @summary Creates a new server.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReplica.json
*/
async function createAReadReplicaOfAnExistingServer() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const parameters = {
createMode: "Replica",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI: "",
geoBackupUserAssignedIdentityId: "",
primaryKeyURI:
"https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/exampleresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/exampleprimaryidentity":
{},
},
},
location: "eastus",
pointInTimeUTC: new Date("2025-06-01T18:35:22.123456Z"),
sourceServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginCreateOrUpdateAndWait(
resourceGroupName,
serverName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReplica.json
// this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://dotnet.territoriali.olinfo.it/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this PostgreSqlFlexibleServerResource
PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers();
// invoke the operation
string serverName = "exampleserver";
PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus"))
{
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"] = new UserAssignedIdentity()
},
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption
{
PrimaryKeyUri = new Uri("https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity"),
GeoBackupKeyUri = new Uri(""),
GeoBackupUserAssignedIdentityId = "",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/examplesourceserver"),
PointInTimeUtc = DateTimeOffset.Parse("2025-06-01T18:35:22.123456Z"),
CreateMode = PostgreSqlFlexibleServerCreateMode.Replica,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/azureAsyncOperation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa?api-version=2025-06-01-preview
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/eastus/operationResults/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb?api-version=2025-06-01-preview
Definizioni
AuthConfig
Oggetto
Proprietà di configurazione dell'autenticazione di un server.
| Nome |
Tipo |
Valore predefinito |
Descrizione |
|
activeDirectoryAuth
|
MicrosoftEntraAuth
|
|
Indica se il server supporta l'autenticazione Microsoft Entra.
|
|
passwordAuth
|
PasswordBasedAuth
|
Enabled
|
Indica se il server supporta l'autenticazione basata su password.
|
|
tenantId
|
string
|
|
Identificatore del tenant della risorsa delegata.
|
Enumerazione
Livello di archiviazione di un server.
| Valore |
Descrizione |
|
P1
|
SSD entry-level per IOPS minimi, ideale per carichi di lavoro di sviluppo o test leggeri.
|
|
P2
|
IOPS leggermente superiori per applicazioni su piccola scala che richiedono una bassa latenza costante.
|
|
P3
|
Prestazioni bilanciate per carichi di lavoro di produzione di base con velocità effettiva moderata.
|
|
P4
|
IOPS migliorati per le app in crescita con esigenze di prestazioni prevedibili.
|
|
P6
|
SSD di livello intermedio per carichi di lavoro costanti che richiedono throughput e latenza affidabili.
|
|
P10
|
Scelta popolare per carichi di lavoro di produzione generici con prestazioni scalabili.
|
|
P15
|
Livello di IOPS elevato per app complesse con operazioni di lettura/scrittura frequenti.
|
|
P20
|
Punto di ingresso per dischi a stato solido (SSD) ad alte prestazioni, adatti per carichi di lavoro ad alta intensità di I/O su piccola scala.
|
|
P30
|
Livello bilanciato per velocità effettiva moderata e applicazioni sensibili alla latenza.
|
|
P40
|
Prestazioni migliorate per carichi di lavoro di produzione in crescita con richieste di IOPS coerenti.
|
|
P50
|
Ottimizzato per applicazioni di livello aziendale che richiedono un throughput elevato e sostenuto.
|
|
P60
|
Livello ad alta capacità per database di grandi dimensioni e carichi di lavoro di analisi con operazioni di I/O al secondo elevate.
|
|
P70
|
Progettato per sistemi mission-critical che richiedono latenza estremamente bassa e concorrenza elevata.
|
|
P80
|
SSD di alto livello per il massimo IOPS e throughput, ideale per i carichi di lavoro più impegnativi.
|
Backup
Oggetto
Proprietà di backup di un server.
| Nome |
Tipo |
Valore predefinito |
Descrizione |
|
backupRetentionDays
|
integer
(int32)
|
7
|
Giorni di conservazione dei backup per il server.
|
|
earliestRestoreDate
|
string
(date-time)
|
|
Ora del punto di ripristino meno recente (formato ISO8601) per un server.
|
|
geoRedundantBackup
|
GeographicallyRedundantBackup
|
Disabled
|
Indica se il server è configurato per la creazione di backup con ridondanza geografica.
|
Cluster
Oggetto
Proprietà del cluster di un server.
| Nome |
Tipo |
Valore predefinito |
Descrizione |
|
clusterSize
|
integer
(int32)
|
0
|
Numero di nodi assegnati al cluster elastico.
|
|
defaultDatabaseName
|
string
|
|
Nome del database predefinito per il cluster elastico.
|
createdByType
Enumerazione
Tipo di identità che ha creato la risorsa.
| Valore |
Descrizione |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
CreateMode
Enumerazione
Modalità di creazione di un nuovo server.
| Valore |
Descrizione |
|
Default
|
Se l'operazione viene attivata su un server non esistente, equivale a "Crea". Se l'operazione viene attivata su un server esistente, equivale a "Aggiorna".
|
|
Create
|
L'operazione crea un nuovo server.
|
|
Update
|
L'operazione aggiorna un server esistente.
|
|
PointInTimeRestore
|
L'operazione ripristina un backup esistente di un server esistente. Questa operazione crea un nuovo server e quindi ripristina su di esso il backup di un server esistente in un momento specifico.
|
|
GeoRestore
|
L'operazione ripristina un backup esistente di un server esistente, nell'area abbinata del server esistente. Questa operazione crea un nuovo server nell'area abbinata del server esistente e quindi ripristina su di esso il backup di un server esistente in un momento specifico, in un'area diversa. Questa operazione è supportata solo nei server esistenti creati con i backup con ridondanza geografica abilitati.
|
|
Replica
|
L'operazione crea una replica di un server esistente. Questa operazione crea un nuovo server, ripristina un backup di base del server esistente (denominato primario) e configura la replica fisica per il flusso asincrono di tutte le modifiche registrate nel log delle transazioni del server primario.
|
|
ReviveDropped
|
L'operazione crea un nuovo server, inizializzato con il backup di un server che è stato eliminato di recente.
|
DataEncryption
Oggetto
Proprietà di crittografia dei dati di un server.
| Nome |
Tipo |
Descrizione |
|
geoBackupEncryptionKeyStatus
|
EncryptionKeyStatus
|
Stato della chiave utilizzata da un server configurato con la crittografia dei dati basata sulla chiave gestita dal cliente, per crittografare lo storage con ridondanza geografica associato al server quando è configurato per supportare backup con ridondanza geografica.
|
|
geoBackupKeyURI
|
string
|
Identificatore dell'identità gestita assegnata dall'utente utilizzato per accedere alla chiave in Azure Key Vault per la crittografia dei dati dello storage geograficamente ridondante associato a un server configurato per supportare backup geograficamente ridondanti.
|
|
geoBackupUserAssignedIdentityId
|
string
|
Identificatore dell'identità gestita assegnata dall'utente utilizzato per accedere alla chiave in Azure Key Vault per la crittografia dei dati dello storage geograficamente ridondante associato a un server configurato per supportare backup geograficamente ridondanti.
|
|
primaryEncryptionKeyStatus
|
EncryptionKeyStatus
|
Stato della chiave utilizzata da un server configurato con la crittografia dei dati basata sulla chiave gestita dal cliente, per crittografare l'archiviazione primaria associata al server.
|
|
primaryKeyURI
|
string
|
URI della chiave in Azure Key Vault utilizzata per la crittografia dei dati dello storage principale associato a un server.
|
|
primaryUserAssignedIdentityId
|
string
|
Identificatore dell'identità gestita assegnata dall'utente utilizzato per accedere alla chiave in Azure Key Vault per la crittografia dei dati dello storage principale associato a un server.
|
|
type
|
DataEncryptionType
|
Tipo di crittografia dei dati utilizzato da un server.
|
DataEncryptionType
Enumerazione
Tipo di crittografia dei dati utilizzato da un server.
| Valore |
Descrizione |
|
SystemManaged
|
Crittografia gestita da Azure utilizzando chiavi gestite dalla piattaforma per semplicità e conformità.
|
|
AzureKeyVault
|
Crittografia utilizzando chiavi gestite dal cliente memorizzate in Azure Key Vault per un controllo e una sicurezza migliori.
|
EncryptionKeyStatus
Enumerazione
Stato della chiave utilizzata da un server configurato con la crittografia dei dati basata sulla chiave gestita dal cliente, per crittografare l'archiviazione primaria associata al server.
| Valore |
Descrizione |
|
Valid
|
La chiave è valida e può essere utilizzata per la crittografia.
|
|
Invalid
|
La chiave non è valida e non può essere utilizzata per la crittografia. Le possibili cause includono l'eliminazione della chiave, la modifica delle autorizzazioni, la disabilitazione della chiave, il tipo di chiave non supportato o la data corrente al di fuori del periodo di validità associato alla chiave.
|
ErrorAdditionalInfo
Oggetto
Informazioni aggiuntive sull'errore di gestione delle risorse.
| Nome |
Tipo |
Descrizione |
|
info
|
object
|
Informazioni aggiuntive.
|
|
type
|
string
|
Tipo di informazioni aggiuntive.
|
ErrorDetail
Oggetto
Dettagli dell'errore.
| Nome |
Tipo |
Descrizione |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Informazioni aggiuntive sull'errore.
|
|
code
|
string
|
Codice di errore.
|
|
details
|
ErrorDetail[]
|
Dettagli dell'errore.
|
|
message
|
string
|
Messaggio di errore.
|
|
target
|
string
|
Destinazione dell'errore.
|
ErrorResponse
Oggetto
Risposta di errore
GeographicallyRedundantBackup
Enumerazione
Indica se il server è configurato per la creazione di backup con ridondanza geografica.
| Valore |
Descrizione |
|
Enabled
|
Il server è configurato per creare backup geograficamente ridondanti.
|
|
Disabled
|
Il server non è configurato per creare backup geograficamente ridondanti.
|
HighAvailability
Oggetto
Proprietà a disponibilità elevata di un server.
| Nome |
Tipo |
Valore predefinito |
Descrizione |
|
mode
|
PostgreSqlFlexibleServerHighAvailabilityMode
|
Disabled
|
Modalità a disponibilità elevata per un server.
|
|
standbyAvailabilityZone
|
string
|
|
Zona di disponibilità associata al server di standby creata quando la disponibilità elevata è impostata su SameZone o ZoneRedundant.
|
|
state
|
HighAvailabilityState
|
|
Possibili stati del server di standby creati quando la disponibilità elevata è impostata su SameZone o ZoneRedundant.
|
HighAvailabilityState
Enumerazione
Possibili stati del server di standby creati quando la disponibilità elevata è impostata su SameZone o ZoneRedundant.
| Valore |
Descrizione |
|
NotEnabled
|
La disponibilità elevata non è abilitata per il server.
|
|
CreatingStandby
|
È in corso la creazione del server di standby.
|
|
ReplicatingData
|
I dati vengono replicati sul server di standby.
|
|
FailingOver
|
L'operazione di failover sul server di standby è in corso.
|
|
Healthy
|
Il server di standby è integro e pronto a subentrare in caso di failover.
|
|
RemovingStandby
|
Il server di standby è in fase di rimozione.
|
|
RecreatingStandby
|
Il server di standby viene ricreato.
|
|
ComputeUpdatingByFailover
|
Il calcolo viene aggiornato a causa di un failover.
|
IdentityType
Enumerazione
Tipi di identità associate a un server.
| Valore |
Descrizione |
|
None
|
Al server non è assegnata alcuna identità gestita.
|
|
UserAssigned
|
Al server vengono assegnate una o più identità gestite fornite dall'utente.
|
|
SystemAssigned
|
Azure crea e gestisce automaticamente l'identità associata al ciclo di vita del server.
|
|
SystemAssigned,UserAssigned
|
Al server vengono assegnate sia le identità assegnate dal sistema che quelle assegnate dall'utente.
|
MaintenanceWindow
Oggetto
Proprietà della finestra di manutenzione di un server.
| Nome |
Tipo |
Valore predefinito |
Descrizione |
|
customWindow
|
string
|
Disabled
|
Indica se la finestra personalizzata è abilitata o disabilitata.
|
|
dayOfWeek
|
integer
(int32)
|
0
|
Giorno della settimana da utilizzare per la finestra di manutenzione.
|
|
startHour
|
integer
(int32)
|
0
|
Ora di inizio da utilizzare per la finestra di manutenzione.
|
|
startMinute
|
integer
(int32)
|
0
|
Minuto di inizio da utilizzare per la finestra di manutenzione.
|
MicrosoftEntraAuth
Enumerazione
Indica se il server supporta l'autenticazione Microsoft Entra.
| Valore |
Descrizione |
|
Enabled
|
Il server supporta l'autenticazione Microsoft Entra.
|
|
Disabled
|
Server non supporta l'autenticazione Microsoft Entra.
|
Network
Oggetto
Proprietà di rete di un server.
| Nome |
Tipo |
Descrizione |
|
delegatedSubnetResourceId
|
string
(arm-id)
|
Identificatore della risorsa della subnet delegata. Necessario durante la creazione di un nuovo server, nel caso in cui si desideri che il server sia integrato nella propria rete virtuale. Per un'operazione di aggiornamento, è sufficiente fornire questa proprietà se si desidera modificare il valore assegnato per la zona DNS privata.
|
|
privateDnsZoneArmResourceId
|
string
(arm-id)
|
Identificatore della zona DNS privata. Necessario durante la creazione di un nuovo server, nel caso in cui si desideri che il server sia integrato nella propria rete virtuale. Per un'operazione di aggiornamento, è sufficiente fornire questa proprietà se si desidera modificare il valore assegnato per la zona DNS privata.
|
|
publicNetworkAccess
|
ServerPublicNetworkAccessState
|
Indica se l'accesso alla rete pubblica è abilitato o meno. Questa opzione è supportata solo per i server che non sono integrati in una rete virtuale di proprietà e fornita dal cliente al momento della distribuzione del server.
|
PasswordBasedAuth
Enumerazione
Indica se il server supporta l'autenticazione basata su password.
| Valore |
Descrizione |
|
Enabled
|
Il server supporta l'autenticazione basata su password.
|
|
Disabled
|
Il server non supporta l'autenticazione basata su password.
|
PostgresMajorVersion
Enumerazione
Versione principale del motore di database PostgreSQL.
| Valore |
Descrizione |
|
18
|
PostgreSQL 18.
|
|
17
|
PostgreSQL 17.
|
|
16
|
PostgreSQL 16.
|
|
15
|
PostgreSQL 15.
|
|
14
|
PostgreSQL 14.
|
|
13
|
PostgreSQL 13.
|
|
12
|
PostgreSQL 12.
|
|
11
|
PostgreSQL 11.
|
PostgreSqlFlexibleServerHighAvailabilityMode
Enumerazione
Modalità di alta disponibilità supportata per questo calcolo.
| Valore |
Descrizione |
|
Disabled
|
La disponibilità elevata è disabilitata per il server.
|
|
ZoneRedundant
|
La disponibilità elevata è abilitata per il server, con il server di standby in una zona di disponibilità diversa da quella del server primario.
|
|
SameZone
|
La disponibilità elevata è abilitata per il server, con il server di standby nella stessa zona di disponibilità del server primario.
|
PrivateEndpoint
Oggetto
Risorsa endpoint privato.
| Nome |
Tipo |
Descrizione |
|
id
|
string
|
Identificatore arm per l'endpoint privato.
|
PrivateEndpointConnection
Oggetto
Risorsa di connessione dell'endpoint privato.
| Nome |
Tipo |
Descrizione |
|
id
|
string
(arm-id)
|
ID risorsa completo per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
Nome della risorsa
|
|
properties.groupIds
|
string[]
|
ID gruppo per la risorsa endpoint privato.
|
|
properties.privateEndpoint
|
PrivateEndpoint
|
Risorsa endpoint privato.
|
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
Raccolta di informazioni sullo stato della connessione tra consumer di servizi e provider.
|
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
Stato di provisioning della risorsa di connessione dell'endpoint privato.
|
|
systemData
|
systemData
|
Azure Resource Manager metadati contenenti informazioni createBy e modifiedBy.
|
|
type
|
string
|
Tipo di risorsa. Ad esempio: "Microsoft. Compute/virtualMachines" oppure "Microsoft. Storage/storageAccounts"
|
PrivateEndpointConnectionProvisioningState
Enumerazione
Stato di provisioning corrente.
| Valore |
Descrizione |
|
Succeeded
|
|
|
Creating
|
|
|
Deleting
|
|
|
Failed
|
|
PrivateEndpointServiceConnectionStatus
Enumerazione
Stato della connessione dell'endpoint privato.
| Valore |
Descrizione |
|
Pending
|
|
|
Approved
|
|
|
Rejected
|
|
PrivateLinkServiceConnectionState
Oggetto
Raccolta di informazioni sullo stato della connessione tra consumer di servizi e provider.
| Nome |
Tipo |
Descrizione |
|
actionsRequired
|
string
|
Messaggio che indica se le modifiche apportate al provider di servizi richiedono aggiornamenti sul consumer.
|
|
description
|
string
|
Motivo dell'approvazione/rifiuto della connessione.
|
|
status
|
PrivateEndpointServiceConnectionStatus
|
Indica se la connessione è stata approvata/rifiutata/rimossa dal proprietario del servizio.
|
Enumerazione
Tipo di operazione da applicare alla replica di lettura. Questa proprietà è di sola scrittura.
| Valore |
Descrizione |
|
Standalone
|
La replica di lettura diventerà un server indipendente e un'entità completamente indipendente dal set di replicazione.
|
|
Switchover
|
La replica di lettura scambierà i ruoli con il server primario.
|
Enumerazione
Opzione di sincronizzazione dei dati da utilizzare durante l'elaborazione dell'operazione specificata nella proprietà promoteMode. Questa proprietà è di sola scrittura.
| Valore |
Descrizione |
|
Planned
|
Aspettare che i dati nella replica di lettura siano completamente sincronizzati con il server sorgente prima che inizi l'operazione.
|
|
Forced
|
Avviare immediatamente l'operazione, senza attendere che i dati nella replica di lettura vengano sincronizzati con il suo server sorgente.
|
Replica
Oggetto
Proprietà di replica di un server.
| Nome |
Tipo |
Descrizione |
|
capacity
|
integer
(int32)
|
Numero massimo di repliche di lettura consentite per un server.
|
|
promoteMode
|
ReadReplicaPromoteMode
|
Tipo di operazione da applicare alla replica di lettura. Questa proprietà è di sola scrittura. Standalone significa che la replica di lettura verrà promossa a server standalone e diventerà un'entità completamente indipendente dal set di replica. Lo switchover significa che la replica di lettura avrà un ruolo con il server primario.
|
|
promoteOption
|
ReadReplicaPromoteOption
|
Opzione di sincronizzazione dei dati da utilizzare durante l'elaborazione dell'operazione specificata nella proprietà promoteMode. Questa proprietà è di sola scrittura.
|
|
replicationState
|
ReplicationState
|
Indica lo stato di replica di una replica di lettura. Questa proprietà viene restituita solo quando il server di destinazione è una replica di lettura. I valori possibili sono Attivo, Interrotto, Recupero, Provisioning, Riconfigurazione e Aggiornamento
|
|
role
|
ReplicationRole
|
Ruolo del server in un set di replica.
|
ReplicationRole
Enumerazione
Ruolo del server in un set di replica.
| Valore |
Descrizione |
|
None
|
Nessun ruolo di replica assegnato; Il server funziona in modo indipendente.
|
|
Primary
|
Funge da server di origine per la replica in una o più repliche.
|
|
AsyncReplica
|
Riceve i dati in modo asincrono da un server primario all'interno della stessa area.
|
|
GeoAsyncReplica
|
Riceve i dati in modo asincrono da un server primario in un'area diversa per la ridondanza geografica.
|
ReplicationState
Enumerazione
Indica lo stato di replica di una replica di lettura. Questa proprietà viene restituita solo quando il server di destinazione è una replica di lettura.
| Valore |
Descrizione |
|
Active
|
Il server replica di lettura è completamente sincronizzato e replica attivamente i dati dal server principale.
|
|
Catchup
|
Il server replica di lettura è indietro rispetto al server primario e sta attualmente recuperando le modifiche in corso.
|
|
Provisioning
|
Un server replica di lettura è in fase di creazione ed è in fase di inizializzazione.
|
|
Updating
|
Il server replica Read sta subendo alcune modifiche, può essere che stia modificando la dimensione di calcolo o la sua promozione al server principale.
|
|
Broken
|
La replica non è riuscita o è stata interrotta.
|
|
Reconfiguring
|
Il server replica di lettura è in fase di riconfigurazione, forse a causa di cambiamenti nella sorgente o nelle impostazioni.
|
Server
Oggetto
Proprietà di un server.
| Nome |
Tipo |
Descrizione |
|
id
|
string
(arm-id)
|
ID risorsa completo per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
UserAssignedIdentity
|
Identità gestite assegnate dall'utente al server.
|
|
location
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
name
|
string
|
Nome della risorsa
|
|
properties.administratorLogin
|
string
|
Nome dell'account di accesso designato come primo amministratore basato su password assegnato all'istanza di PostgreSQL. Deve essere specificato la prima volta che si abilita l'autenticazione basata su password in un server. Una volta impostato su un determinato valore, non può essere modificato per il resto della vita di un server. Se si disabilita l'autenticazione basata su password in un server in cui è abilitata, questo ruolo basato su password non viene eliminato.
|
|
properties.administratorLoginPassword
|
string
(password)
|
Password assegnata all'accesso amministratore. Finché l'autenticazione tramite password è abilitata, questa password può essere modificata in qualsiasi momento.
|
|
properties.authConfig
|
AuthConfig
|
Proprietà di configurazione dell'autenticazione di un server.
|
|
properties.availabilityZone
|
string
|
Zona di disponibilità di un server.
|
|
properties.backup
|
Backup
|
Proprietà di backup di un server.
|
|
properties.cluster
|
Cluster
|
Proprietà del cluster di un server.
|
|
properties.createMode
|
CreateMode
|
Modalità di creazione di un nuovo server.
|
|
properties.dataEncryption
|
DataEncryption
|
Proprietà di crittografia dei dati di un server.
|
|
properties.fullyQualifiedDomainName
|
string
|
Nome di dominio completo di un server.
|
|
properties.highAvailability
|
HighAvailability
|
Proprietà a disponibilità elevata di un server.
|
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Proprietà della finestra di manutenzione di un server.
|
|
properties.minorVersion
|
string
|
Versione secondaria del motore di database PostgreSQL.
|
|
properties.network
|
Network
|
Proprietà di rete di un server. Necessario solo se si desidera che il server sia integrato in una rete virtuale fornita dal cliente.
|
|
properties.pointInTimeUTC
|
string
(date-time)
|
Ora di creazione (in formato ISO8601) del backup che si desidera ripristinare nel nuovo server. È necessario quando 'createMode' è 'PointInTimeRestore', 'GeoRestore' o 'ReviveDropped'.
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
Elenco delle connessioni endpoint private associate al server specificato.
|
|
properties.replica
|
Replica
|
Leggi le proprietà della replica di un server. Obbligatorio solo nel caso in cui si desideri promuovere un server.
|
|
properties.replicaCapacity
|
integer
(int32)
|
Numero massimo di repliche di lettura consentite per un server.
|
|
properties.replicationRole
|
ReplicationRole
|
Ruolo del server in un set di replica.
|
|
properties.sourceServerResourceId
|
string
(arm-id)
|
Identificatore del server da utilizzare come origine del nuovo server. Obbligatorio quando 'createMode' è 'PointInTimeRestore', 'GeoRestore', 'Replica' o 'ReviveDropped'. Questa proprietà viene restituita solo quando il server di destinazione è una replica di lettura.
|
|
properties.state
|
ServerState
|
Possibili stati di un server.
|
|
properties.storage
|
Storage
|
Proprietà di archiviazione di un server.
|
|
properties.version
|
PostgresMajorVersion
|
Versione principale del motore di database PostgreSQL.
|
|
sku
|
Sku
|
Livello di calcolo e dimensioni di un server.
|
|
systemData
|
systemData
|
Azure Resource Manager metadati contenenti informazioni createBy e modifiedBy.
|
|
tags
|
object
|
Tag di risorsa.
|
|
type
|
string
|
Tipo di risorsa. Ad esempio: "Microsoft. Compute/virtualMachines" oppure "Microsoft. Storage/storageAccounts"
|
ServerPublicNetworkAccessState
Enumerazione
Indica se l'accesso alla rete pubblica è abilitato o meno.
| Valore |
Descrizione |
|
Enabled
|
L'accesso alla rete pubblica è abilitato. In questo modo è possibile accedere al server dalla rete Internet pubblica, a condizione che sia presente la regola del firewall necessaria che consente il traffico in ingresso proveniente dal client di connessione. Ciò è compatibile con l'uso di endpoint privati per connettersi a questo server.
|
|
Disabled
|
L'accesso alla rete pubblica è disabilitato. Ciò significa che non è possibile accedere al server dalla rete Internet pubblica, ma solo tramite endpoint privati.
|
ServerState
Enumerazione
Stato di un server.
| Valore |
Descrizione |
|
Ready
|
Il server è integro e non è in corso alcuna operazione a livello di piano di gestione o di controllo. Ciò non significa che il server sia completamente operativo a livello di piano dati.
|
|
Dropping
|
Il server è in fase di eliminazione.
|
|
Disabled
|
Il server è disabilitato. I motivi tipici includono: la sottoscrizione in cui viene distribuito il server è disabilitata o annullata in modo esplicito dall'amministratore, il limite di spesa è stato raggiunto o la fattura è scaduta. Può verificarsi anche quando il server viene spostato in un altro gruppo di risorse o in un'altra sottoscrizione.
|
|
Starting
|
Il motore di database PostgreSQL è in fase di riavvio.
|
|
Stopping
|
Le risorse di calcolo associate al server vengono arrestate e deallocate. Se nel server è abilitata la disponibilità elevata, anche le risorse di calcolo del server di standby vengono arrestate e deallocate.
|
|
Stopped
|
Le risorse di calcolo associate al server vengono arrestate e deallocate.
|
|
Updating
|
Il server sta subendo alcune modifiche che possono influire o meno sulla disponibilità del motore di database PostgreSQL. Ad esempio, le risorse di calcolo del server vengono ridimensionate verso l'alto o verso il basso, il che può causare l'indisponibilità temporanea del motore di database. Oppure, ad esempio, viene aggiunta o rimossa una regola del firewall, che non causa alcuna indisponibilità del motore di database.
|
|
Restarting
|
Il motore di database PostgreSQL è in fase di riavvio.
|
|
Inaccessible
|
Il server non è accessibile, perché la chiave fornita per crittografare e decrittografare i dati è in stato non valido.
|
|
Provisioning
|
Il server è in fase di creazione.
|
Sku
Oggetto
Calcola le informazioni di un server.
| Nome |
Tipo |
Descrizione |
|
name
|
string
|
Nome con cui è nota una data dimensione di calcolo assegnata a un server.
|
|
tier
|
SkuTier
|
Livello di calcolo assegnato a un server.
|
SkuTier
Enumerazione
Livello di calcolo assegnato a un server.
| Valore |
Descrizione |
|
Burstable
|
Livello conveniente per l'utilizzo poco frequente della CPU, ideale per carichi di lavoro di sviluppo e test con bassi requisiti di prestazioni.
|
|
GeneralPurpose
|
Calcolo e memoria bilanciati per la maggior parte dei carichi di lavoro, che offrono prestazioni scalabili e throughput di I/O.
|
|
MemoryOptimized
|
Elevato rapporto memoria/core per carichi di lavoro impegnativi che richiedono un'elaborazione in-memory rapida e un'elevata concorrenza.
|
Storage
Oggetto
Proprietà di archiviazione di un server.
| Nome |
Tipo |
Descrizione |
|
autoGrow
|
StorageAutoGrow
|
Contrassegnare per abilitare o disabilitare l'aumento automatico delle dimensioni di archiviazione di un server quando lo spazio disponibile si avvicina allo zero e le condizioni consentono l'aumento automatico delle dimensioni di archiviazione.
|
|
iops
|
integer
(int32)
|
Numero massimo di operazioni di I/O al secondo supportate per l'archiviazione. Obbligatorio quando il tipo di archiviazione è PremiumV2_LRS o UltraSSD_LRS.
|
|
storageSizeGB
|
integer
(int32)
|
Dimensione dello spazio di archiviazione assegnato a un server.
|
|
throughput
|
integer
(int32)
|
Velocità effettiva massima supportata per l'archiviazione. Obbligatorio quando il tipo di archiviazione è PremiumV2_LRS o UltraSSD_LRS.
|
|
tier
|
AzureManagedDiskPerformanceTier
|
Livello di archiviazione di un server.
|
|
type
|
StorageType
|
Tipo di archiviazione assegnata a un server. I valori consentiti sono Premium_LRS, PremiumV2_LRS o UltraSSD_LRS. Se non specificato, il valore predefinito è Premium_LRS.
|
StorageAutoGrow
Enumerazione
Indica se il server è configurato per aumentare automaticamente la dimensione di spazio quando lo spazio disponibile si avvicina a zero e le condizioni permettono una crescita automatica della dimensione dello storage.
| Valore |
Descrizione |
|
Enabled
|
Il server dovrebbe aumentare automaticamente le dimensioni di archiviazione quando lo spazio disponibile si avvicina allo zero e le condizioni consentono di aumentare automaticamente le dimensioni di archiviazione.
|
|
Disabled
|
Il server non deve aumentare automaticamente le dimensioni di archiviazione quando lo spazio disponibile è vicino allo zero.
|
StorageType
Enumerazione
Tipo di archiviazione assegnata a un server. Se non specificato, il valore predefinito è Premium_LRS.
| Valore |
Descrizione |
|
Premium_LRS
|
Storage standard supportato da dischi a stato solido (SSD) che offre prestazioni costanti per carichi di lavoro generici.
|
|
PremiumV2_LRS
|
Storage SSD (Solid State Disk) di nuova generazione con scalabilità e prestazioni migliorate per carichi di lavoro aziendali impegnativi.
|
|
UltraSSD_LRS
|
Storage SSD (Solid State Disk) di fascia alta progettato per operazioni di I/O al secondo estreme e applicazioni sensibili alla latenza.
|
systemData
Oggetto
Metadati relativi alla creazione e all'ultima modifica della risorsa.
| Nome |
Tipo |
Descrizione |
|
createdAt
|
string
(date-time)
|
Timestamp della creazione della risorsa (UTC).
|
|
createdBy
|
string
|
Identità che ha creato la risorsa.
|
|
createdByType
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
lastModifiedAt
|
string
(date-time)
|
Timestamp dell'ultima modifica della risorsa (UTC)
|
|
lastModifiedBy
|
string
|
Identità che ha modificato l'ultima volta la risorsa.
|
|
lastModifiedByType
|
createdByType
|
Tipo di identità che ha modificato l'ultima volta la risorsa.
|
UserAssignedIdentity
Oggetto
Identità associate a un server.
| Nome |
Tipo |
Descrizione |
|
principalId
|
string
|
Identificatore dell'oggetto dell'entità servizio associata all'identità gestita assegnata dall'utente.
|
|
tenantId
|
string
|
Identificatore del tenant di un server.
|
|
type
|
IdentityType
|
Tipi di identità associate a un server.
|
|
userAssignedIdentities
|
<string,
UserIdentity>
|
Mappa delle identità gestite assegnate dall'utente.
|
UserIdentity
Oggetto
Identità gestita assegnata dall'utente associata a un server.
| Nome |
Tipo |
Descrizione |
|
clientId
|
string
|
Identificatore del client dell'entità servizio associata all'identità gestita assegnata dall'utente.
|
|
principalId
|
string
|
Identificatore dell'oggetto dell'entità servizio associata all'identità gestita assegnata dall'utente.
|