Crea una nuova migrazione.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}?api-version=2025-08-01
Parametri dell'URI
| Nome |
In |
Necessario |
Tipo |
Descrizione |
|
migrationName
|
path |
True
|
string
pattern: ^[a-z][a-z0-9]*$
|
Nome della migrazione.
|
|
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
|
|
properties.cancel
|
|
Cancel
|
Indica se l'annullamento deve essere attivato per l'intera migrazione.
|
|
properties.dbsToCancelMigrationOn
|
|
string[]
|
Quando si desidera attivare l'annullamento per database specifici, impostare 'triggerCutover' su 'True' e i nomi dei database specifici in questo array.
|
|
properties.dbsToMigrate
|
|
string[]
|
Nomi dei database di cui eseguire la migrazione.
|
|
properties.dbsToTriggerCutoverOn
|
|
string[]
|
Quando si desidera attivare il cutover per database specifici, impostare 'triggerCutover' su 'True' e i nomi dei database specifici in questo array.
|
|
properties.migrateRoles
|
|
MigrateRolesAndPermissions
|
Indica se è necessario eseguire la migrazione di ruoli e autorizzazioni.
|
|
properties.migrationInstanceResourceId
|
|
string
(arm-id)
|
Identificatore dell'istanza di migrazione dell'endpoint privato.
|
|
properties.migrationMode
|
|
MigrationMode
|
Modalità utilizzata per eseguire la migrazione: Online o Offline.
|
|
properties.migrationOption
|
|
MigrationOption
|
Opzione supportata per una migrazione.
|
|
properties.migrationWindowEndTimeInUtc
|
|
string
(date-time)
|
Ora di fine (UTC) per la finestra di migrazione.
|
|
properties.migrationWindowStartTimeInUtc
|
|
string
(date-time)
|
Ora di inizio (UTC) per la finestra di migrazione.
|
|
properties.overwriteDbsInTarget
|
|
OverwriteDatabasesOnTargetServer
|
Indica se i database nel server di destinazione possono essere sovrascritti quando sono già presenti. Se impostato su 'False', quando il flusso di lavoro di migrazione rileva che il database esiste già sul server di destinazione, attenderà una conferma.
|
|
properties.secretParameters
|
|
MigrationSecretParameters
|
Parametri del segreto di migrazione.
|
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
|
LogicalReplicationOnSourceServer
|
Indica se configurare la replica logica nel server di origine, se necessario.
|
|
properties.sourceDbServerFullyQualifiedDomainName
|
|
string
|
Nome di dominio completo (FQDN) o indirizzo IP del server di origine. Questa proprietà è facoltativa. Quando fornito, il servizio di migrazione lo utilizzerà sempre per connettersi al server di origine.
|
|
properties.sourceDbServerResourceId
|
|
string
|
Identificatore della risorsa del server di database di origine, quando 'sourceType' è 'PostgreSQLSingleServer'. Per altri tipi di origine questo deve essere impostato su ipaddress:port@username o hostname:port@username.
|
|
properties.sourceType
|
|
SourceType
|
Tipo di server di origine usato per la migrazione: ApsaraDB_RDS, AWS, AWS_AURORA, AWS_EC2, AWS_RDS, AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, Digital_Ocean_PostgreSQL, EDB, EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, GCP_CloudSQL, GCP_Compute, Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, PostgreSQLCosmosDB, PostgreSQLFlexibleServer, PostgreSQLSingleServer o Supabase_PostgreSQL
|
|
properties.sslMode
|
|
SslMode
|
Modalità SSL utilizzata da una migrazione. La modalità SSL predefinita per 'PostgreSQLSingleServer' è 'VerifyFull'. La modalità SSL predefinita per altri tipi di origine è "Preferisci".
|
|
properties.startDataMigration
|
|
StartDataMigration
|
Indica se la migrazione dei dati deve essere avviata immediatamente.
|
|
properties.targetDbServerFullyQualifiedDomainName
|
|
string
|
Nome di dominio completo (FQDN) o indirizzo IP del server di destinazione. Questa proprietà è facoltativa. Quando viene fornito, il servizio di migrazione lo utilizzerà sempre per connettersi al server di destinazione.
|
|
properties.triggerCutover
|
|
TriggerCutover
|
Indica se il cutover deve essere attivato per l'intera migrazione.
|
|
tags
|
|
object
|
Tag di risorsa.
|
Risposte
| Nome |
Tipo |
Descrizione |
|
200 OK
|
Migration
|
Operazione di aggiornamento 'Migrazione' della risorsa riuscita
|
|
201 Created
|
Migration
|
Risorsa 'Migrazione' crea operazione con successo
|
|
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 migration for validating only.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationMode": "Offline",
"migrationOption": "Validate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateValidateOnly.json
*/
/**
* Sample code: Create a migration for validating only.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigrationForValidatingOnly(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE).withMigrationOption(MigrationOption.VALIDATE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE).create();
}
}
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 migrations_create_validate_only.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationMode": "Offline",
"migrationOption": "Validate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateValidateOnly.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/MigrationsCreateValidateOnly.json
func ExampleMigrationsClient_Create_createAMigrationForValidatingOnly() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidate),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstateValidationInProgress),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidate),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateValidateOnly.json
*/
async function createAMigrationForValidatingOnly() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationMode: "Offline",
migrationOption: "Validate",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateValidateOnly.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
MigrationOption = MigrationOption.Validate,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationOption": "Validate",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
}
}
Create a migration specifying user names.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationMode": "Offline",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
},
"sourceServerUsername": "newadmin@examplesource",
"targetServerUsername": "targetadmin"
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateWithOtherUsers.json
*/
/**
* Sample code: Create a migration specifying user names.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigrationSpecifyingUserNames(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSecretParameters(new MigrationSecretParameters()
.withAdminCredentials(new AdminCredentials().withSourceServerPassword("fakeTokenPlaceholder")
.withTargetServerPassword("fakeTokenPlaceholder"))
.withSourceServerUsername("newadmin@examplesource").withTargetServerUsername("targetadmin"))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.create();
}
}
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 migrations_create_with_other_users.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationMode": "Offline",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
},
"sourceServerUsername": "newadmin@examplesource",
"targetServerUsername": "targetadmin",
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithOtherUsers.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/MigrationsCreateWithOtherUsers.json
func ExampleMigrationsClient_Create_createAMigrationSpecifyingUserNames() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
SourceServerUsername: to.Ptr("newadmin@examplesource"),
TargetServerUsername: to.Ptr("targetadmin"),
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerFalse),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithOtherUsers.json
*/
async function createAMigrationSpecifyingUserNames() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationMode: "Offline",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
sourceServerUsername: "newadmin@examplesource",
targetServerUsername: "targetadmin",
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithOtherUsers.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword"))
{
SourceServerUsername = "newadmin@examplesource",
TargetServerUsername = "targetadmin",
},
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationMode": "Offline",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "False",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationMode": "Offline",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "False",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
}
}
Create a migration with fully qualified domain names for source and target servers.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "xxxxxxxx",
"targetServerPassword": "xxxxxxxx"
}
},
"sourceDbServerFullyQualifiedDomainName": "examplesource.contoso.com",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerFullyQualifiedDomainName": "exampletarget.contoso.com"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateWithFullyQualifiedDomainName.json
*/
/**
* Sample code: Create a migration with fully qualified domain names for source and target servers.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigrationWithFullyQualifiedDomainNamesForSourceAndTargetServers(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSourceDbServerFullyQualifiedDomainName("examplesource.contoso.com")
.withTargetDbServerFullyQualifiedDomainName("exampletarget.contoso.com")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE).create();
}
}
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 migrations_create_with_fully_qualified_domain_name.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerFullyQualifiedDomainName": "examplesource.contoso.com",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerFullyQualifiedDomainName": "exampletarget.contoso.com",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithFullyQualifiedDomainName.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/MigrationsCreateWithFullyQualifiedDomainName.json
func ExampleMigrationsClient_Create_createAMigrationWithFullyQualifiedDomainNamesForSourceAndTargetServers() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerFullyQualifiedDomainName: to.Ptr("examplesource.contoso.com"),
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
TargetDbServerFullyQualifiedDomainName: to.Ptr("exampletarget.contoso.com"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerFullyQualifiedDomainName: to.Ptr("examplesource.contoso.com"),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerFullyQualifiedDomainName: to.Ptr("exampletarget.contoso.com"),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithFullyQualifiedDomainName.json
*/
async function createAMigrationWithFullyQualifiedDomainNamesForSourceAndTargetServers() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerFullyQualifiedDomainName: "examplesource.contoso.com",
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
targetDbServerFullyQualifiedDomainName: "exampletarget.contoso.com",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithFullyQualifiedDomainName.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SourceDbServerFullyQualifiedDomainName = "examplesource.contoso.com",
TargetDbServerFullyQualifiedDomainName = "exampletarget.contoso.com",
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerFullyQualifiedDomainName": "examplesource.contoso.com",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerFullyQualifiedDomainName": "exampletarget.contoso.com",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerFullyQualifiedDomainName": "examplesource.contoso.com",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerFullyQualifiedDomainName": "exampletarget.contoso.com",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
Create a migration with other source type for validating and migrating.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationMode": "Offline",
"migrationOption": "ValidateAndMigrate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"sourceType": "OnPremises",
"sslMode": "Prefer"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SourceType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SslMode;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateOtherSourceTypesValidateMigrate.json
*/
/**
* Sample code: Create a migration with other source type for validating and migrating.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigrationWithOtherSourceTypeForValidatingAndMigrating(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE).withMigrationOption(MigrationOption.VALIDATE_AND_MIGRATE)
.withSourceType(SourceType.ON_PREMISES).withSslMode(SslMode.PREFER)
.withSourceDbServerResourceId("examplesource:5432@exampleuser")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE).create();
}
}
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 migrations_create_other_source_types_validate_migrate.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationMode": "Offline",
"migrationOption": "ValidateAndMigrate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
}
},
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"sourceType": "OnPremises",
"sslMode": "Prefer",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateOtherSourceTypesValidateMigrate.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/MigrationsCreateOtherSourceTypesValidateMigrate.json
func ExampleMigrationsClient_Create_createAMigrationWithOtherSourceTypeForValidatingAndMigrating() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidateAndMigrate),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
},
SourceDbServerResourceID: to.Ptr("examplesource:5432@exampleuser"),
SourceType: to.Ptr(armpostgresqlflexibleservers.SourceTypeOnPremises),
SSLMode: to.Ptr(armpostgresqlflexibleservers.SSLModePrefer),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstateValidationInProgress),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidateAndMigrate),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("examplesource:5432@exampleuser"),
// SourceType: to.Ptr(armpostgresqlflexibleservers.SourceTypeOnPremises),
// SSLMode: to.Ptr(armpostgresqlflexibleservers.SSLModePrefer),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateOtherSourceTypesValidateMigrate.json
*/
async function createAMigrationWithOtherSourceTypeForValidatingAndMigrating() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationMode: "Offline",
migrationOption: "ValidateAndMigrate",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
},
sourceDbServerResourceId: "examplesource:5432@exampleuser",
sourceType: "OnPremises",
sslMode: "Prefer",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateOtherSourceTypesValidateMigrate.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
MigrationOption = MigrationOption.ValidateAndMigrate,
SourceType = PostgreSqlFlexibleServersSourceType.OnPremises,
SslMode = PostgreSqlFlexibleServersSslMode.Prefer,
SourceDbServerResourceId = new ResourceIdentifier("examplesource:5432@exampleuser"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationOption": "ValidateAndMigrate",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"sourceType": "OnPremises",
"sslMode": "Prefer",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationOption": "ValidateAndMigrate",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"sourceType": "OnPremises",
"sslMode": "Prefer",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
}
}
Create a migration with private endpoint.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateWithPrivateEndpointServers.json
*/
/**
* Sample code: Create a migration with private endpoint.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigrationWithPrivateEndpoint(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationInstanceResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE).create();
}
}
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 migrations_create_with_private_endpoint_servers.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithPrivateEndpointServers.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/MigrationsCreateWithPrivateEndpointServers.json
func ExampleMigrationsClient_Create_createAMigrationWithPrivateEndpoint() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration"),
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithPrivateEndpointServers.json
*/
async function createAMigrationWithPrivateEndpoint() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationInstanceResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithPrivateEndpointServers.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationInstanceResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration"),
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
Create a migration with roles.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "True",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrateRolesAndPermissions;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* MigrationsCreateWithRoles.json
*/
/**
* Sample code: Create a migration with roles.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createAMigrationWithRoles(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE)
.withMigrateRoles(MigrateRolesAndPermissions.TRUE).create();
}
}
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 migrations_create_with_roles.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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrateRoles": "True",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithRoles.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/MigrationsCreateWithRoles.json
func ExampleMigrationsClient_Create_createAMigrationWithRoles() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsTrue),
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsTrue),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithRoles.json
*/
async function createAMigrationWithRoles() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrateRoles: "True",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithRoles.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
MigrateRoles = MigrateRolesEnum.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "True",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "True",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
Create a migration.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/migrations/examplemigration?api-version=2025-08-01
{
"location": "eastus",
"properties": {
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDatabasesOnTargetServer;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreate.
* json
*/
/**
* Sample code: Create a migration.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createAMigration(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("examplemigration").withRegion("eastus")
.withExistingFlexibleServer("exampleresourcegroup", "exampleserver")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(
Arrays.asList("exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"))
.withOverwriteDbsInTarget(OverwriteDatabasesOnTargetServer.TRUE).create();
}
}
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 migrations_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.migrations.create(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
migration_name="examplemigration",
parameters={
"location": "eastus",
"properties": {
"dbsToMigrate": ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword",
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreate.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/MigrationsCreate.json
func ExampleMigrationsClient_Create_createAMigration() {
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)
}
res, err := clientFactory.NewMigrationsClient().Create(ctx, "exampleresourcegroup", "exampleserver", "examplemigration", armpostgresqlflexibleservers.Migration{
Location: to.Ptr("eastus"),
Properties: &armpostgresqlflexibleservers.MigrationProperties{
DbsToMigrate: []*string{
to.Ptr("exampledatabase1"),
to.Ptr("exampledatabase2"),
to.Ptr("exampledatabase3"),
to.Ptr("exampledatabase4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("examplesourcepassword"),
TargetServerPassword: to.Ptr("exampletargetpassword"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Migration = armpostgresqlflexibleservers.Migration{
// Name: to.Ptr("examplemigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration"),
// Location: to.Ptr("eastus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubstateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubstatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("exampledatabase1"),
// to.Ptr("exampledatabase2"),
// to.Ptr("exampledatabase3"),
// to.Ptr("exampledatabase4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesAndPermissionsFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDatabasesOnTargetServerTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceServerFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverFalse),
// },
// }
}
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 migration.
*
* @summary Creates a new migration.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreate.json
*/
async function createAMigration() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "exampleresourcegroup";
const serverName = "exampleserver";
const migrationName = "examplemigration";
const parameters = {
dbsToMigrate: ["exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4"],
location: "eastus",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "examplesourcepassword",
targetServerPassword: "exampletargetpassword",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.migrations.create(
resourceGroupName,
serverName,
migrationName,
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.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreate.json
// this example is just showing the usage of "Migrations_Create" 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 PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "exampleresourcegroup";
string serverName = "exampleserver";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "examplemigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("eastus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("examplesourcepassword", "exampletargetpassword")),
DbsToMigrate = { "exampledatabase1", "exampledatabase2", "exampledatabase3", "exampledatabase4" },
OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True,
};
ArmOperation<PostgreSqlMigrationResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data);
PostgreSqlMigrationResource 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
PostgreSqlMigrationData 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
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
{
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"location": "eastus",
"properties": {
"currentStatus": {
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
},
"error": "",
"state": "InProgress"
},
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"migrateRoles": "False",
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationWindowStartTimeInUtc": "2025-06-01T18:30:22.123456Z",
"overwriteDbsInTarget": "True",
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"startDataMigration": "False",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"triggerCutover": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
Definizioni
AdminCredentials
Oggetto
Credenziali degli utenti amministratori per i server di origine e di destinazione.
| Nome |
Tipo |
Descrizione |
|
sourceServerPassword
|
string
(password)
|
Password per l'utente del server di origine.
|
|
targetServerPassword
|
string
(password)
|
Password per l'utente del server di destinazione.
|
Cancel
Enumerazione
Indica se l'annullamento deve essere attivato per l'intera migrazione.
| Valore |
Descrizione |
|
True
|
L'opzione Annulla deve essere attivata per l'intera migrazione.
|
|
False
|
L'opzione Annulla non deve essere attivata per l'intera migrazione.
|
createdByType
Enumerazione
Tipo di identità che ha creato la risorsa.
| Valore |
Descrizione |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DatabaseMigrationState
Oggetto
Stato di migrazione di un database.
| Nome |
Tipo |
Descrizione |
|
appliedChanges
|
integer
(int32)
|
Contatore delle modifiche applicate da Change Data Capture.
|
|
cdcDeleteCounter
|
integer
(int32)
|
Contatore di eliminazione Change Data Capture.
|
|
cdcInsertCounter
|
integer
(int32)
|
Contatore di inserimento Change Data Capture.
|
|
cdcUpdateCounter
|
integer
(int32)
|
Contatore degli aggiornamenti di Change Data Capture.
|
|
databaseName
|
string
|
Nome del database.
|
|
endedOn
|
string
(date-time)
|
Ora di fine di uno stato di migrazione.
|
|
fullLoadCompletedTables
|
integer
(int32)
|
Numero di tabelle caricate durante la migrazione di un database.
|
|
fullLoadErroredTables
|
integer
(int32)
|
Numero di tabelle che riscontrano errori durante la migrazione di un database.
|
|
fullLoadLoadingTables
|
integer
(int32)
|
Numero di tabelle caricate durante la migrazione di un database.
|
|
fullLoadQueuedTables
|
integer
(int32)
|
Numero di tabelle accodate per la migrazione di un database.
|
|
incomingChanges
|
integer
(int32)
|
Contatore delle modifiche in ingresso Change Data Capture.
|
|
latency
|
integer
(int32)
|
Ritardo in secondi tra l'origine e la destinazione durante la fase online.
|
|
message
|
string
|
Messaggio di errore, se presente, per lo stato di migrazione.
|
|
migrationOperation
|
string
|
Operazione di migrazione di un database.
|
|
migrationState
|
MigrationDatabaseState
|
Stato di migrazione di un database.
|
|
startedOn
|
string
(date-time)
|
Ora di inizio di uno stato di migrazione.
|
DbLevelValidationStatus
Oggetto
Riepilogo dello stato di convalida per un database.
| Nome |
Tipo |
Descrizione |
|
databaseName
|
string
|
Nome del database.
|
|
endedOn
|
string
(date-time)
|
Ora di fine di una convalida a livello di database.
|
|
startedOn
|
string
(date-time)
|
Ora di inizio di una convalida a livello di database.
|
|
summary
|
ValidationSummaryItem[]
|
Riepilogo delle convalide a livello di database.
|
Oggetto
Metadati del server di database.
| Nome |
Tipo |
Descrizione |
|
location
|
string
|
Ubicazione del server di database.
|
|
sku
|
ServerSku
|
Livello di calcolo e dimensioni del server di database. Questo oggetto è vuoto per un server singolo Database di Azure per PostgreSQL.
|
|
storageMb
|
integer
(int32)
|
Dimensioni di archiviazione (in MB) per il server di database.
|
|
version
|
string
|
Versione principale del motore di database PostgreSQL.
|
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
LogicalReplicationOnSourceServer
Enumerazione
Indica se configurare la replica logica nel server di origine, se necessario.
| Valore |
Descrizione |
|
True
|
La replica logica verrà configurata nel server di origine.
|
|
False
|
La replica logica non verrà configurata nel server di origine.
|
MigrateRolesAndPermissions
Enumerazione
Indica se è necessario eseguire la migrazione di ruoli e autorizzazioni.
| Valore |
Descrizione |
|
True
|
Verrà eseguita la migrazione dei ruoli e delle autorizzazioni.
|
|
False
|
I ruoli e le autorizzazioni non verranno migrati.
|
Migration
Oggetto
Proprietà di una migrazione.
| Nome |
Tipo |
Descrizione |
|
id
|
string
(arm-id)
|
ID risorsa completo per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
location
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
name
|
string
|
Nome della risorsa
|
|
properties.cancel
|
Cancel
|
Indica se l'annullamento deve essere attivato per l'intera migrazione.
|
|
properties.currentStatus
|
MigrationStatus
|
Stato corrente di una migrazione.
|
|
properties.dbsToCancelMigrationOn
|
string[]
|
Quando si desidera attivare l'annullamento per database specifici, impostare 'triggerCutover' su 'True' e i nomi dei database specifici in questo array.
|
|
properties.dbsToMigrate
|
string[]
|
Nomi dei database di cui eseguire la migrazione.
|
|
properties.dbsToTriggerCutoverOn
|
string[]
|
Quando si desidera attivare il cutover per database specifici, impostare 'triggerCutover' su 'True' e i nomi dei database specifici in questo array.
|
|
properties.migrateRoles
|
MigrateRolesAndPermissions
|
Indica se è necessario eseguire la migrazione di ruoli e autorizzazioni.
|
|
properties.migrationId
|
string
|
Identificatore di una migrazione.
|
|
properties.migrationInstanceResourceId
|
string
(arm-id)
|
Identificatore dell'istanza di migrazione dell'endpoint privato.
|
|
properties.migrationMode
|
MigrationMode
|
Modalità utilizzata per eseguire la migrazione: Online o Offline.
|
|
properties.migrationOption
|
MigrationOption
|
Opzione supportata per una migrazione.
|
|
properties.migrationWindowEndTimeInUtc
|
string
(date-time)
|
Ora di fine (UTC) per la finestra di migrazione.
|
|
properties.migrationWindowStartTimeInUtc
|
string
(date-time)
|
Ora di inizio (UTC) per la finestra di migrazione.
|
|
properties.overwriteDbsInTarget
|
OverwriteDatabasesOnTargetServer
|
Indica se i database nel server di destinazione possono essere sovrascritti quando sono già presenti. Se impostato su 'False', quando il flusso di lavoro di migrazione rileva che il database esiste già sul server di destinazione, attenderà una conferma.
|
|
properties.secretParameters
|
MigrationSecretParameters
|
Parametri del segreto di migrazione.
|
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
LogicalReplicationOnSourceServer
|
Indica se configurare la replica logica nel server di origine, se necessario.
|
|
properties.sourceDbServerFullyQualifiedDomainName
|
string
|
Nome di dominio completo (FQDN) o indirizzo IP del server di origine. Questa proprietà è facoltativa. Quando fornito, il servizio di migrazione lo utilizzerà sempre per connettersi al server di origine.
|
|
properties.sourceDbServerMetadata
|
DbServerMetadata
|
Metadati del server di database di origine.
|
|
properties.sourceDbServerResourceId
|
string
|
Identificatore della risorsa del server di database di origine, quando 'sourceType' è 'PostgreSQLSingleServer'. Per altri tipi di origine questo deve essere impostato su ipaddress:port@username o hostname:port@username.
|
|
properties.sourceType
|
SourceType
|
Tipo di server di origine usato per la migrazione: ApsaraDB_RDS, AWS, AWS_AURORA, AWS_EC2, AWS_RDS, AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, Digital_Ocean_PostgreSQL, EDB, EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, GCP_CloudSQL, GCP_Compute, Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, PostgreSQLCosmosDB, PostgreSQLFlexibleServer, PostgreSQLSingleServer o Supabase_PostgreSQL
|
|
properties.sslMode
|
SslMode
|
Modalità SSL utilizzata da una migrazione. La modalità SSL predefinita per 'PostgreSQLSingleServer' è 'VerifyFull'. La modalità SSL predefinita per altri tipi di origine è "Preferisci".
|
|
properties.startDataMigration
|
StartDataMigration
|
Indica se la migrazione dei dati deve essere avviata immediatamente.
|
|
properties.targetDbServerFullyQualifiedDomainName
|
string
|
Nome di dominio completo (FQDN) o indirizzo IP del server di destinazione. Questa proprietà è facoltativa. Quando viene fornito, il servizio di migrazione lo utilizzerà sempre per connettersi al server di destinazione.
|
|
properties.targetDbServerMetadata
|
DbServerMetadata
|
Metadati del server di database di destinazione.
|
|
properties.targetDbServerResourceId
|
string
|
Identificatore della risorsa del server di database di destinazione.
|
|
properties.triggerCutover
|
TriggerCutover
|
Indica se il cutover deve essere attivato per l'intera migrazione.
|
|
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"
|
MigrationDatabaseState
Enumerazione
Stato di migrazione di un database.
| Valore |
Descrizione |
|
InProgress
|
La migrazione del database è in corso.
|
|
WaitingForCutoverTrigger
|
La migrazione è in attesa del trigger di cutover per il database.
|
|
Failed
|
La migrazione del database non è riuscita.
|
|
Canceled
|
La migrazione del database è stata annullata.
|
|
Succeeded
|
La migrazione del database è riuscita.
|
|
Canceling
|
La migrazione del database viene cancellata.
|
MigrationMode
Enumerazione
Modalità utilizzata per eseguire la migrazione.
| Valore |
Descrizione |
|
Offline
|
Modalità di migrazione offline.
|
|
Online
|
Modalità di migrazione online.
|
MigrationOption
Enumerazione
Opzione supportata per una migrazione.
| Valore |
Descrizione |
|
Validate
|
Convalidare la migrazione senza eseguirla.
|
|
Migrate
|
Eseguire la migrazione.
|
|
ValidateAndMigrate
|
Convalidare ed eseguire la migrazione.
|
MigrationSecretParameters
Oggetto
Parametri del segreto di migrazione.
| Nome |
Tipo |
Descrizione |
|
adminCredentials
|
AdminCredentials
(password)
|
Credenziali degli utenti amministratori per i server di origine e di destinazione.
|
|
sourceServerUsername
|
string
|
Ottiene o imposta il nome dell'utente per il server di origine. Non è necessario che l'utente sia un amministratore.
|
|
targetServerUsername
|
string
|
Ottiene o imposta il nome dell'utente per il server di destinazione. Non è necessario che l'utente sia un amministratore.
|
MigrationState
Enumerazione
Stato di migrazione.
| Valore |
Descrizione |
|
InProgress
|
La migrazione è in corso.
|
|
WaitingForUserAction
|
La migrazione è in attesa dell'azione dell'utente.
|
|
Canceled
|
La migrazione è stata annullata.
|
|
Failed
|
La migrazione non è riuscita.
|
|
Succeeded
|
La migrazione è riuscita.
|
|
ValidationFailed
|
La convalida per la migrazione non è riuscita.
|
|
CleaningUp
|
La migrazione consiste nel ripulire le risorse.
|
MigrationStatus
Oggetto
Stato di migrazione.
| Nome |
Tipo |
Descrizione |
|
currentSubStateDetails
|
MigrationSubstateDetails
|
Dettagli dello stato secondario della migrazione corrente.
|
|
error
|
string
|
Messaggio di errore, se presente, per lo stato di migrazione.
|
|
state
|
MigrationState
|
Stato di migrazione.
|
MigrationSubstate
Enumerazione
Sottostato della migrazione.
| Valore |
Descrizione |
|
PerformingPreRequisiteSteps
|
Esecuzione dei passaggi preliminari per la migrazione.
|
|
WaitingForLogicalReplicationSetupRequestOnSourceDB
|
In attesa della richiesta di configurazione della replica logica nel database di origine.
|
|
WaitingForDBsToMigrateSpecification
|
In attesa della migrazione della specifica dei database.
|
|
WaitingForTargetDBOverwriteConfirmation
|
In attesa della conferma di sovrascrittura del database di destinazione.
|
|
WaitingForDataMigrationScheduling
|
In attesa della pianificazione della migrazione dei dati.
|
|
WaitingForDataMigrationWindow
|
In attesa della finestra di migrazione dei dati.
|
|
MigratingData
|
Migrazione dei dati.
|
|
WaitingForCutoverTrigger
|
In attesa del trigger di cutover.
|
|
CompletingMigration
|
Completamento della migrazione.
|
|
Completed
|
Migrazione completata.
|
|
CancelingRequestedDBMigrations
|
Annullamento delle migrazioni di database richieste.
|
|
ValidationInProgress
|
Convalida in corso.
|
MigrationSubstateDetails
Oggetto
Dettagli del sottostato di migrazione.
OverwriteDatabasesOnTargetServer
Enumerazione
Indica se i database nel server di destinazione possono essere sovrascritti quando sono già presenti.
| Valore |
Descrizione |
|
True
|
I database sul server di destinazione possono essere sovrascritti quando sono già presenti.
|
|
False
|
I database sul server di destinazione non possono essere sovrascritti se sono già presenti. Quando il flusso di lavoro di migrazione rileva che il database esiste già sul server target, attende una conferma.
|
ServerSku
Oggetto
Calcola le informazioni di un server.
| Nome |
Tipo |
Descrizione |
|
name
|
string
|
Livello di calcolo e dimensioni del server di database. Questo oggetto è vuoto per un server singolo Database di Azure per PostgreSQL.
|
|
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.
|
SourceType
Enumerazione
Tipo di server sorgente utilizzato per la migrazione.
| Valore |
Descrizione |
|
OnPremises
|
Server PostgreSQL locale.
|
|
AWS
|
Server PostgreSQL di Amazon Web Services.
|
|
GCP
|
Server PostgreSQL di Google Cloud Platform.
|
|
AzureVM
|
Azure Virtual Machine PostgreSQL server.
|
|
PostgreSQLSingleServer
|
Database di Azure per PostgreSQL single server.
|
|
AWS_RDS
|
Amazon RDS per PostgreSQL.
|
|
AWS_AURORA
|
Amazon Aurora per PostgreSQL.
|
|
AWS_EC2
|
Amazon EC2 per PostgreSQL.
|
|
GCP_CloudSQL
|
Google Cloud SQL per PostgreSQL.
|
|
GCP_AlloyDB
|
Google Cloud AlloyDB per PostgreSQL.
|
|
GCP_Compute
|
Google Compute Engine per PostgreSQL.
|
|
EDB
|
Server PostgreSQL di EnterpriseDB.
|
|
EDB_Oracle_Server
|
Server Oracle di EnterpriseDB.
|
|
EDB_PostgreSQL
|
Server PostgreSQL di EnterpriseDB.
|
|
PostgreSQLFlexibleServer
|
Database di Azure per PostgreSQL flexible server.
|
|
PostgreSQLCosmosDB
|
.NET Cosmos DB per PostgreSQL
|
|
Huawei_RDS
|
Huawei RDS per PostgreSQL
|
|
Huawei_Compute
|
Huawei Compute per PostgreSQL
|
|
Heroku_PostgreSQL
|
Heroku PostgreSQL
|
|
Crunchy_PostgreSQL
|
PostgreSQL croccante
|
|
ApsaraDB_RDS
|
ApsaraDB RDS per PostgreSQL
|
|
Digital_Ocean_Droplets
|
Goccioline oceaniche digitali per PostgreSQL
|
|
Digital_Ocean_PostgreSQL
|
PostgreSQL oceanico digitale
|
|
Supabase_PostgreSQL
|
Supabase PostgreSQL
|
SslMode
Enumerazione
Modalità SSL utilizzata da una migrazione. La modalità SSL predefinita per 'PostgreSQLSingleServer' è 'VerifyFull'. La modalità SSL predefinita per altri tipi di origine è "Preferisci".
| Valore |
Descrizione |
|
Prefer
|
Preferisci la connessione SSL. Se il server non supporta SSL, la connessione verrà stabilita senza SSL.
|
|
Require
|
Richiedi connessione SSL. Se il server non supporta SSL, la connessione non riuscirà.
|
|
VerifyCA
|
Richiedi la connessione SSL e verifica il certificato del server rispetto al certificato CA.
|
|
VerifyFull
|
Richiedi connessione SSL, verifica il certificato del server rispetto al certificato CA e verifica che il nome host del server corrisponda al certificato.
|
StartDataMigration
Enumerazione
Indica se la migrazione dei dati deve essere avviata immediatamente.
| Valore |
Descrizione |
|
True
|
La migrazione dei dati deve iniziare immediatamente.
|
|
False
|
La migrazione dei dati non deve iniziare immediatamente.
|
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.
|
TriggerCutover
Enumerazione
Indica se il cutover deve essere attivato per l'intera migrazione.
| Valore |
Descrizione |
|
True
|
Il cutover deve essere attivato per l'intera migrazione.
|
|
False
|
Il cutover non deve essere attivato per l'intera migrazione.
|
ValidationDetails
Oggetto
Dettagli per la convalida per la migrazione.
| Nome |
Tipo |
Descrizione |
|
dbLevelValidationDetails
|
DbLevelValidationStatus[]
|
Dettagli delle convalide a livello di server.
|
|
serverLevelValidationDetails
|
ValidationSummaryItem[]
|
Dettagli delle convalide a livello di server.
|
|
status
|
ValidationState
|
Stato di convalida per la migrazione.
|
|
validationEndTimeInUtc
|
string
(date-time)
|
Ora di fine (UTC) per la convalida.
|
|
validationStartTimeInUtc
|
string
(date-time)
|
Ora di inizio (UTC) per la convalida.
|
ValidationMessage
Oggetto
Oggetto messaggio di convalida.
| Nome |
Tipo |
Descrizione |
|
message
|
string
|
Stringa del messaggio di convalida.
|
|
state
|
ValidationState
|
Gravità del messaggio di convalida.
|
ValidationState
Enumerazione
Stato di validazione per la migrazione.
| Valore |
Descrizione |
|
Failed
|
Convalida non riuscita.
|
|
Succeeded
|
La convalida è riuscita.
|
|
Warning
|
La convalida è riuscita con avvisi.
|
ValidationSummaryItem
Oggetto
Oggetto di riepilogo della convalida.
| Nome |
Tipo |
Descrizione |
|
messages
|
ValidationMessage[]
|
Messaggi di convalida.
|
|
state
|
ValidationState
|
Stato di convalida per la migrazione.
|
|
type
|
string
|
Tipo di convalida.
|