创建新的迁移。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}?api-version=2025-08-01
URI 参数
| 名称 |
在 |
必需 |
类型 |
说明 |
|
migrationName
|
path |
True
|
string
pattern: ^[a-z][a-z0-9]*$
|
迁移名称。
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
资源组的名称。 此名称不区分大小写。
|
|
serverName
|
path |
True
|
string
minLength: 3 maxLength: 63 pattern: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
服务器的名称。
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
目标订阅的 ID。 该值必须是 UUID。
|
|
api-version
|
query |
True
|
string
minLength: 1
|
要用于此操作的 API 版本。
|
请求正文
| 名称 |
必需 |
类型 |
说明 |
|
location
|
True
|
string
|
资源所在的地理位置
|
|
properties.cancel
|
|
Cancel
|
指示是否必须为整个迁移触发 cancel。
|
|
properties.dbsToCancelMigrationOn
|
|
string[]
|
如果要为特定数据库触发 cancel,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
|
properties.dbsToMigrate
|
|
string[]
|
要迁移的数据库的名称。
|
|
properties.dbsToTriggerCutoverOn
|
|
string[]
|
如果要触发特定数据库的直接转换,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
|
properties.migrateRoles
|
|
MigrateRolesAndPermissions
|
指示是否必须迁移角色和权限。
|
|
properties.migrationInstanceResourceId
|
|
string
(arm-id)
|
私有终端节点迁移实例的标识符。
|
|
properties.migrationMode
|
|
MigrationMode
|
用于执行迁移的模式:联机或脱机。
|
|
properties.migrationOption
|
|
MigrationOption
|
迁移的支持选项。
|
|
properties.migrationWindowEndTimeInUtc
|
|
string
(date-time)
|
迁移时段的结束时间 (UTC)。
|
|
properties.migrationWindowStartTimeInUtc
|
|
string
(date-time)
|
迁移时段的开始时间 (UTC)。
|
|
properties.overwriteDbsInTarget
|
|
OverwriteDatabasesOnTargetServer
|
指示目标服务器上的数据库在已存在时是否可以被覆盖。 如果设置为 'False',则当迁移工作流检测到目标服务器上已存在数据库时,它将等待确认。
|
|
properties.secretParameters
|
|
MigrationSecretParameters
|
迁移机密参数。
|
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
|
LogicalReplicationOnSourceServer
|
指示是否在源服务器上设置逻辑复制(如果需要)。
|
|
properties.sourceDbServerFullyQualifiedDomainName
|
|
string
|
源服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 如果提供,迁移服务将始终使用它来连接到源服务器。
|
|
properties.sourceDbServerResourceId
|
|
string
|
当 'sourceType' 为 'PostgreSQLSingleServer' 时,源数据库服务器资源的标识符。 对于其他源类型,必须将其设置为 ipaddress:port@username 或 hostname:port@username。
|
|
properties.sourceType
|
|
SourceType
|
用于迁移的源服务器类型: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 或 Supabase_PostgreSQL
|
|
properties.sslMode
|
|
SslMode
|
迁移使用的 SSL 模式。 “PostgreSQLSingleServer”的默认 SSL 模式为“VerifyFull”。 其他源类型的默认 SSL 模式为 'Prefer'。
|
|
properties.startDataMigration
|
|
StartDataMigration
|
指示是否必须立即开始数据迁移。
|
|
properties.targetDbServerFullyQualifiedDomainName
|
|
string
|
目标服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 提供后,迁移服务将始终使用它来连接到目标服务器。
|
|
properties.triggerCutover
|
|
TriggerCutover
|
指示是否必须为整个迁移触发直接转换。
|
|
tags
|
|
object
|
资源标记。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 Flow.
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 |
说明 |
|
user_impersonation
|
模拟用户帐户
|
示例
Create a migration for validating only.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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.
示例请求
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
示例响应
{
"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"
}
}
定义
AdminCredentials
对象
源服务器和目标服务器的管理员用户的凭据。
| 名称 |
类型 |
说明 |
|
sourceServerPassword
|
string
(password)
|
源服务器用户的密码。
|
|
targetServerPassword
|
string
(password)
|
目标服务器用户的密码。
|
Cancel
枚举
指示是否必须为整个迁移触发 cancel。
| 值 |
说明 |
|
True
|
必须为整个迁移触发取消。
|
|
False
|
不得为整个迁移触发取消。
|
createdByType
枚举
创建资源的标识的类型。
| 值 |
说明 |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DatabaseMigrationState
对象
数据库的迁移状态。
| 名称 |
类型 |
说明 |
|
appliedChanges
|
integer
(int32)
|
Change Data Capture applied changes 计数器。
|
|
cdcDeleteCounter
|
integer
(int32)
|
更改 Data Capture 删除计数器。
|
|
cdcInsertCounter
|
integer
(int32)
|
更改 Data Capture 插入计数器。
|
|
cdcUpdateCounter
|
integer
(int32)
|
更改 Data Capture 更新计数器。
|
|
databaseName
|
string
|
数据库的名称。
|
|
endedOn
|
string
(date-time)
|
迁移状态的结束时间。
|
|
fullLoadCompletedTables
|
integer
(int32)
|
数据库迁移期间加载的表数。
|
|
fullLoadErroredTables
|
integer
(int32)
|
在数据库迁移过程中遇到错误的表数。
|
|
fullLoadLoadingTables
|
integer
(int32)
|
数据库迁移期间加载的表数。
|
|
fullLoadQueuedTables
|
integer
(int32)
|
排队等待数据库迁移的表数。
|
|
incomingChanges
|
integer
(int32)
|
Change Data Capture 传入更改计数器。
|
|
latency
|
integer
(int32)
|
联机阶段源和目标之间的滞后(以秒为单位)。
|
|
message
|
string
|
迁移状态的错误消息(如果有)。
|
|
migrationOperation
|
string
|
数据库的迁移作。
|
|
migrationState
|
MigrationDatabaseState
|
数据库的迁移状态。
|
|
startedOn
|
string
(date-time)
|
迁移状态的开始时间。
|
DbLevelValidationStatus
对象
数据库的验证状态摘要。
| 名称 |
类型 |
说明 |
|
databaseName
|
string
|
数据库的名称。
|
|
endedOn
|
string
(date-time)
|
数据库级别验证的结束时间。
|
|
startedOn
|
string
(date-time)
|
数据库级别验证的开始时间。
|
|
summary
|
ValidationSummaryItem[]
|
数据库级别验证摘要。
|
对象
数据库服务器元数据。
| 名称 |
类型 |
说明 |
|
location
|
string
|
数据库服务器的位置。
|
|
sku
|
ServerSku
|
数据库服务器的计算层和大小。 This object is empty for a Azure Database for PostgreSQL single server.
|
|
storageMb
|
integer
(int32)
|
数据库服务器的存储大小(以 MB 为单位)。
|
|
version
|
string
|
PostgreSQL 数据库引擎的主要版本。
|
ErrorAdditionalInfo
对象
资源管理错误附加信息。
| 名称 |
类型 |
说明 |
|
info
|
object
|
附加信息。
|
|
type
|
string
|
附加信息类型。
|
ErrorDetail
对象
错误详细信息。
ErrorResponse
对象
错误响应
LogicalReplicationOnSourceServer
枚举
指示是否在源服务器上设置逻辑复制(如果需要)。
| 值 |
说明 |
|
True
|
将在源服务器上设置逻辑复制。
|
|
False
|
不会在源服务器上设置逻辑复制。
|
MigrateRolesAndPermissions
枚举
指示是否必须迁移角色和权限。
| 值 |
说明 |
|
True
|
角色和权限将迁移。
|
|
False
|
角色和权限不会迁移。
|
Migration
对象
迁移的属性。
| 名称 |
类型 |
说明 |
|
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如,“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
|
location
|
string
|
资源所在的地理位置
|
|
name
|
string
|
资源的名称
|
|
properties.cancel
|
Cancel
|
指示是否必须为整个迁移触发 cancel。
|
|
properties.currentStatus
|
MigrationStatus
|
迁移的当前状态。
|
|
properties.dbsToCancelMigrationOn
|
string[]
|
如果要为特定数据库触发 cancel,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
|
properties.dbsToMigrate
|
string[]
|
要迁移的数据库的名称。
|
|
properties.dbsToTriggerCutoverOn
|
string[]
|
如果要触发特定数据库的直接转换,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
|
properties.migrateRoles
|
MigrateRolesAndPermissions
|
指示是否必须迁移角色和权限。
|
|
properties.migrationId
|
string
|
迁移的标识符。
|
|
properties.migrationInstanceResourceId
|
string
(arm-id)
|
私有终端节点迁移实例的标识符。
|
|
properties.migrationMode
|
MigrationMode
|
用于执行迁移的模式:联机或脱机。
|
|
properties.migrationOption
|
MigrationOption
|
迁移的支持选项。
|
|
properties.migrationWindowEndTimeInUtc
|
string
(date-time)
|
迁移时段的结束时间 (UTC)。
|
|
properties.migrationWindowStartTimeInUtc
|
string
(date-time)
|
迁移时段的开始时间 (UTC)。
|
|
properties.overwriteDbsInTarget
|
OverwriteDatabasesOnTargetServer
|
指示目标服务器上的数据库在已存在时是否可以被覆盖。 如果设置为 'False',则当迁移工作流检测到目标服务器上已存在数据库时,它将等待确认。
|
|
properties.secretParameters
|
MigrationSecretParameters
|
迁移机密参数。
|
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
LogicalReplicationOnSourceServer
|
指示是否在源服务器上设置逻辑复制(如果需要)。
|
|
properties.sourceDbServerFullyQualifiedDomainName
|
string
|
源服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 如果提供,迁移服务将始终使用它来连接到源服务器。
|
|
properties.sourceDbServerMetadata
|
DbServerMetadata
|
源数据库服务器的元数据。
|
|
properties.sourceDbServerResourceId
|
string
|
当 'sourceType' 为 'PostgreSQLSingleServer' 时,源数据库服务器资源的标识符。 对于其他源类型,必须将其设置为 ipaddress:port@username 或 hostname:port@username。
|
|
properties.sourceType
|
SourceType
|
用于迁移的源服务器类型: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 或 Supabase_PostgreSQL
|
|
properties.sslMode
|
SslMode
|
迁移使用的 SSL 模式。 “PostgreSQLSingleServer”的默认 SSL 模式为“VerifyFull”。 其他源类型的默认 SSL 模式为 'Prefer'。
|
|
properties.startDataMigration
|
StartDataMigration
|
指示是否必须立即开始数据迁移。
|
|
properties.targetDbServerFullyQualifiedDomainName
|
string
|
目标服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 提供后,迁移服务将始终使用它来连接到目标服务器。
|
|
properties.targetDbServerMetadata
|
DbServerMetadata
|
目标数据库服务器的元数据。
|
|
properties.targetDbServerResourceId
|
string
|
目标数据库服务器资源的标识符。
|
|
properties.triggerCutover
|
TriggerCutover
|
指示是否必须为整个迁移触发直接转换。
|
|
systemData
|
systemData
|
Azure 资源管理器 包含 createdBy 和 modifiedBy 信息的元数据。
|
|
tags
|
object
|
资源标记。
|
|
type
|
string
|
资源类型。 例如,“Microsoft。计算/虚拟机“或”Microsoft“。存储/存储账户”
|
MigrationDatabaseState
枚举
数据库的迁移状态。
| 值 |
说明 |
|
InProgress
|
数据库的迁移正在进行中。
|
|
WaitingForCutoverTrigger
|
迁移正在等待数据库的直接转换触发器。
|
|
Failed
|
数据库的迁移失败。
|
|
Canceled
|
数据库的迁移已取消。
|
|
Succeeded
|
数据库的迁移成功。
|
|
Canceling
|
数据库迁移计划正在取消。
|
MigrationMode
枚举
用于迁移的模式。
| 值 |
说明 |
|
Offline
|
脱机迁移模式。
|
|
Online
|
在线迁移模式。
|
MigrationOption
枚举
迁移的支持选项。
| 值 |
说明 |
|
Validate
|
验证迁移而不执行迁移。
|
|
Migrate
|
执行迁移。
|
|
ValidateAndMigrate
|
验证并执行迁移。
|
MigrationSecretParameters
对象
迁移机密参数。
| 名称 |
类型 |
说明 |
|
adminCredentials
|
AdminCredentials
(password)
|
源服务器和目标服务器的管理员用户的凭据。
|
|
sourceServerUsername
|
string
|
获取或设置源服务器的用户名称。 此用户不需要是管理员。
|
|
targetServerUsername
|
string
|
获取或设置目标服务器的用户名称。 此用户不需要是管理员。
|
MigrationState
枚举
迁移状态。
| 值 |
说明 |
|
InProgress
|
迁移正在进行中。
|
|
WaitingForUserAction
|
迁移正在等待用户作。
|
|
Canceled
|
迁移已取消。
|
|
Failed
|
迁移失败。
|
|
Succeeded
|
迁移成功了。
|
|
ValidationFailed
|
迁移验证失败。
|
|
CleaningUp
|
迁移是清理资源。
|
MigrationStatus
对象
迁移状态。
MigrationSubstate
枚举
迁移的子状态。
| 值 |
说明 |
|
PerformingPreRequisiteSteps
|
执行迁移的先决条件步骤。
|
|
WaitingForLogicalReplicationSetupRequestOnSourceDB
|
正在等待源数据库上的逻辑复制设置请求。
|
|
WaitingForDBsToMigrateSpecification
|
等待数据库迁移规范。
|
|
WaitingForTargetDBOverwriteConfirmation
|
正在等待目标数据库覆盖确认。
|
|
WaitingForDataMigrationScheduling
|
正在等待数据迁移计划。
|
|
WaitingForDataMigrationWindow
|
正在等待数据迁移窗口。
|
|
MigratingData
|
迁移数据。
|
|
WaitingForCutoverTrigger
|
正在等待切换触发器。
|
|
CompletingMigration
|
完成迁移。
|
|
Completed
|
迁移完成。
|
|
CancelingRequestedDBMigrations
|
取消请求的数据库迁移。
|
|
ValidationInProgress
|
验证正在进行中。
|
MigrationSubstateDetails
对象
迁移子状态的详细信息。
OverwriteDatabasesOnTargetServer
枚举
指示目标服务器上的数据库在已存在时是否可以被覆盖。
| 值 |
说明 |
|
True
|
目标服务器上的数据库在已经存在时可以被覆盖。
|
|
False
|
目标服务器上的数据库(如果已经存在)则无法覆盖。 当迁移流程检测到数据库已存在于目标服务器时,会等待确认。
|
ServerSku
对象
计算服务器的信息。
| 名称 |
类型 |
说明 |
|
name
|
string
|
数据库服务器的计算层和大小。 This object is empty for a Azure Database for PostgreSQL single server.
|
|
tier
|
SkuTier
|
分配给服务器的计算层。
|
SkuTier
枚举
分配给服务器的计算层。
| 值 |
说明 |
|
Burstable
|
经济高效的层,适用于不频繁的 CPU 使用率,非常适合性能要求较低的开发和测试工作负载。
|
|
GeneralPurpose
|
为大多数工作负载平衡计算和内存,提供可缩放的性能和 I/O 吞吐量。
|
|
MemoryOptimized
|
高内存与核心比,适用于需要快速内存处理和高并发性的苛刻工作负载。
|
SourceType
枚举
迁移时使用的源服务器类型。
| 值 |
说明 |
|
OnPremises
|
本地 PostgreSQL 服务器。
|
|
AWS
|
亚马逊云科技 PostgreSQL 服务器。
|
|
GCP
|
Google Cloud Platform PostgreSQL 服务器。
|
|
AzureVM
|
Azure Virtual Machine PostgreSQL server.
|
|
PostgreSQLSingleServer
|
Azure Database for PostgreSQL single server.
|
|
AWS_RDS
|
Amazon RDS for PostgreSQL。
|
|
AWS_AURORA
|
适用于 PostgreSQL 的 Amazon Aurora。
|
|
AWS_EC2
|
适用于 PostgreSQL 的 Amazon EC2。
|
|
GCP_CloudSQL
|
适用于 PostgreSQL 的 Google Cloud SQL。
|
|
GCP_AlloyDB
|
适用于 PostgreSQL 的 Google Cloud AlloyDB。
|
|
GCP_Compute
|
适用于 PostgreSQL 的 Google Compute Engine。
|
|
EDB
|
EnterpriseDB PostgreSQL 服务器。
|
|
EDB_Oracle_Server
|
EnterpriseDB Oracle 服务器。
|
|
EDB_PostgreSQL
|
EnterpriseDB PostgreSQL 服务器。
|
|
PostgreSQLFlexibleServer
|
Azure Database for PostgreSQL flexible server.
|
|
PostgreSQLCosmosDB
|
.NET Cosmos 数据库 for PostgreSQL
|
|
Huawei_RDS
|
华为RDS PostgreSQL 版
|
|
Huawei_Compute
|
华为计算 PostgreSQL 版
|
|
Heroku_PostgreSQL
|
Heroku PostgreSQL
|
|
Crunchy_PostgreSQL
|
脆脆的PostgreSQL
|
|
ApsaraDB_RDS
|
云数据库RDS PostgreSQL版
|
|
Digital_Ocean_Droplets
|
PostgreSQL的数字海洋液滴
|
|
Digital_Ocean_PostgreSQL
|
数字海洋 PostgreSQL
|
|
Supabase_PostgreSQL
|
Supabase PostgreSQL
|
SslMode
枚举
迁移使用的 SSL 模式。 “PostgreSQLSingleServer”的默认 SSL 模式为“VerifyFull”。 其他源类型的默认 SSL 模式为 'Prefer'。
| 值 |
说明 |
|
Prefer
|
首选 SSL 连接。 如果服务器不支持 SSL,则无需 SSL 即可建立连接。
|
|
Require
|
需要 SSL 连接。 如果服务器不支持 SSL,则连接将失败。
|
|
VerifyCA
|
需要 SSL 连接,并根据 CA 证书验证服务器证书。
|
|
VerifyFull
|
需要 SSL 连接,根据 CA 证书验证服务器证书,并验证服务器主机名是否与证书匹配。
|
StartDataMigration
枚举
指示是否必须立即开始数据迁移。
| 值 |
说明 |
|
True
|
数据迁移必须立即开始。
|
|
False
|
数据迁移不得立即开始。
|
systemData
对象
与创建和上次修改资源相关的元数据。
| 名称 |
类型 |
说明 |
|
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
|
createdBy
|
string
|
创建资源的标识。
|
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
|
lastModifiedAt
|
string
(date-time)
|
资源上次修改的时间戳 (UTC)
|
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
TriggerCutover
枚举
指示是否必须为整个迁移触发直接转换。
| 值 |
说明 |
|
True
|
必须为整个迁移触发直接转换。
|
|
False
|
不得为整个迁移触发直接转换。
|
ValidationDetails
对象
迁移验证的详细信息。
ValidationMessage
对象
验证消息对象。
ValidationState
枚举
迁移验证状态。
| 值 |
说明 |
|
Failed
|
验证失败。
|
|
Succeeded
|
验证成功。
|
|
Warning
|
验证成功,但出现警告。
|
ValidationSummaryItem
对象
验证摘要对象。