创建新的迁移。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}?api-version=2024-08-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
migrationName
|
path |
True
|
string
pattern: ^[a-z][a-z0-9]*$
|
迁移名称。
|
resourceGroupName
|
path |
True
|
string
pattern: ^[-a-z0-9A-Z._()]+[^.]$
|
目标数据库服务器的资源组名称。
|
subscriptionId
|
path |
True
|
string
pattern: ([a-z0-9]){8,8}[-]([a-z0-9]){4,4}[-]([a-z0-9]){4,4}[-]([a-z0-9]){4,4}[-]([a-z0-9]){12,12}
|
目标数据库服务器的订阅标识符。
|
targetDbServerName
|
path |
True
|
string
pattern: ([-a-z0-9]){3,63}
|
目标数据库服务器的名称。
|
api-version
|
query |
True
|
string
minLength: 1
|
用于此操作的 API 版本。
|
请求正文
名称 |
必需 |
类型 |
说明 |
location
|
True
|
string
|
资源所在的地理位置
|
properties.cancel
|
|
CancelEnum
|
指示是否必须为整个迁移触发 cancel。
|
properties.dbsToCancelMigrationOn
|
|
string[]
|
如果要为特定数据库触发 cancel,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
properties.dbsToMigrate
|
|
string[]
|
要迁移的数据库的名称。
|
properties.dbsToTriggerCutoverOn
|
|
string[]
|
如果要触发特定数据库的直接转换,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
properties.migrateRoles
|
|
MigrateRolesEnum
|
指示是否必须迁移角色和权限。
|
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
|
|
OverwriteDbsInTargetEnum
|
指示目标服务器上的数据库在已存在时是否可以被覆盖。 如果设置为 'False',则当迁移工作流检测到目标服务器上已存在数据库时,它将等待确认。
|
properties.secretParameters
|
|
MigrationSecretParameters
|
迁移机密参数。
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
|
LogicalReplicationOnSourceDbEnum
|
指示是否根据需要设置 LogicalReplicationOnSourceDb。
|
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
|
|
StartDataMigrationEnum
|
指示是否必须立即开始数据迁移。
|
properties.targetDbServerFullyQualifiedDomainName
|
|
string
|
目标服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 提供后,迁移服务将始终使用它来连接到目标服务器。
|
properties.triggerCutover
|
|
TriggerCutoverEnum
|
指示是否必须为整个迁移触发直接转换。
|
tags
|
|
object
|
资源标记。
|
响应
安全性
azure_auth
Microsoft Entra OAuth2 流
类型:
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/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"migrationOption": "Validate"
},
"location": "westus"
}
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.OverwriteDbsInTargetEnum;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* Migrations_Create_Validate_Only.json
*/
/**
* Sample code: Create Pre-migration Validation.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
createPreMigrationValidation(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationMode(MigrationMode.OFFLINE).withMigrationOption(MigrationOption.VALIDATE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4"))
.withOverwriteDbsInTarget(OverwriteDbsInTargetEnum.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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrationMode": "Offline",
"migrationOption": "Validate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_Validate_Only.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_Validate_Only.json
func ExampleMigrationsClient_Create_createPreMigrationValidation() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidate),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
},
}, 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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStateValidationInProgress),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidate),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create_Validate_Only.json
*/
async function createPreMigrationValidation() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrationMode: "Offline",
migrationOption: "Validate",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create_Validate_Only.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
MigrationOption = MigrationOption.Validate,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate =
{
"db1","db2","db3","db4"
},
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False",
"migrationOption": "Validate"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
Create a migration specifying user names.
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
},
"sourceServerUsername": "newadmin@examplesource",
"targetServerUsername": "targetadmin"
},
"migrationMode": "Offline"
},
"location": "westus"
}
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/2024-08-01/examples/
* Migrations_Create_With_Other_Users.json
*/
/**
* Sample code: Migrations Create by passing user names.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void migrationsCreateByPassingUserNames(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource")
.withSecretParameters(new MigrationSecretParameters()
.withAdminCredentials(new AdminCredentials().withSourceServerPassword("fakeTokenPlaceholder")
.withTargetServerPassword("fakeTokenPlaceholder"))
.withSourceServerUsername("newadmin@testsource").withTargetServerUsername("targetadmin"))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4")).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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrationMode": "Offline",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"},
"sourceServerUsername": "newadmin@testsource",
"targetServerUsername": "targetadmin",
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_Other_Users.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_Other_Users.json
func ExampleMigrationsClient_Create_migrationsCreateByPassingUserNames() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
SourceServerUsername: to.Ptr("newadmin@testsource"),
TargetServerUsername: to.Ptr("targetadmin"),
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
},
}, 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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumFalse),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create_With_Other_Users.json
*/
async function migrationsCreateByPassingUserNames() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrationMode: "Offline",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
sourceServerUsername: "newadmin@testsource",
targetServerUsername: "targetadmin",
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create_With_Other_Users.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx"))
{
SourceServerUsername = "newadmin@testsource",
TargetServerUsername = "targetadmin",
},
DbsToMigrate =
{
"db1","db2","db3","db4"
},
};
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationMode": "Offline",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "False",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"migrationMode": "Offline",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "False",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
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/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"migrationOption": "ValidateAndMigrate",
"sslMode": "Prefer",
"sourceType": "OnPremises"
},
"location": "westus"
}
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.OverwriteDbsInTargetEnum;
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/2024-08-01/examples/
* Migrations_Create_Other_SourceTypes_Validate_Migrate.json
*/
/**
* Sample code: Create Migration with other source types for Validate and Migrate.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void createMigrationWithOtherSourceTypesForValidateAndMigrate(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationMode(MigrationMode.OFFLINE).withMigrationOption(MigrationOption.VALIDATE_AND_MIGRATE)
.withSourceType(SourceType.ON_PREMISES).withSslMode(SslMode.PREFER)
.withSourceDbServerResourceId("testsource:5432@pguser")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4"))
.withOverwriteDbsInTarget(OverwriteDbsInTargetEnum.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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrationMode": "Offline",
"migrationOption": "ValidateAndMigrate",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerResourceId": "testsource:5432@pguser",
"sourceType": "OnPremises",
"sslMode": "Prefer",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.json
func ExampleMigrationsClient_Create_createMigrationWithOtherSourceTypesForValidateAndMigrate() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidateAndMigrate),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerResourceID: to.Ptr("testsource:5432@pguser"),
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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStateValidationInProgress),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationOption: to.Ptr(armpostgresqlflexibleservers.MigrationOptionValidateAndMigrate),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("testsource:5432@pguser"),
// SourceType: to.Ptr(armpostgresqlflexibleservers.SourceTypeOnPremises),
// SSLMode: to.Ptr(armpostgresqlflexibleservers.SSLModePrefer),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.json
*/
async function createMigrationWithOtherSourceTypesForValidateAndMigrate() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrationMode: "Offline",
migrationOption: "ValidateAndMigrate",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerResourceId: "testsource:5432@pguser",
sourceType: "OnPremises",
sslMode: "Prefer",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
MigrationOption = MigrationOption.ValidateAndMigrate,
SourceType = PostgreSqlFlexibleServersSourceType.OnPremises,
SslMode = PostgreSqlFlexibleServersSslMode.Prefer,
SourceDbServerResourceId = new ResourceIdentifier("testsource:5432@pguser"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate =
{
"db1","db2","db3","db4"
},
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
}
},
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False",
"migrationOption": "ValidateAndMigrate",
"sslMode": "Prefer",
"sourceType": "OnPremises"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "ValidationInProgress"
}
},
"sourceDbServerResourceId": "examplesource:5432@exampleuser",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False",
"migrationOption": "ValidateAndMigrate",
"sslMode": "Prefer",
"sourceType": "OnPremises"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
Create a migration with private endpoint.
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"migrationMode": "Offline",
"overwriteDbsInTarget": "True"
},
"location": "westus"
}
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.OverwriteDbsInTargetEnum;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* Migrations_Create_With_PrivateEndpoint_Servers.json
*/
/**
* Sample code: Migrations Create with private endpoint.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void migrationsCreateWithPrivateEndpoint(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationInstanceResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4"))
.withOverwriteDbsInTarget(OverwriteDbsInTargetEnum.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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_PrivateEndpoint_Servers.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_PrivateEndpoint_Servers.json
func ExampleMigrationsClient_Create_migrationsCreateWithPrivateEndpoint() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
},
}, 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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create_With_PrivateEndpoint_Servers.json
*/
async function migrationsCreateWithPrivateEndpoint() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrationInstanceResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create_With_PrivateEndpoint_Servers.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationInstanceResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate =
{
"db1","db2","db3","db4"
},
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False",
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False",
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
Create a migration with roles.
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"migrationMode": "Offline",
"migrateRoles": "True",
"overwriteDbsInTarget": "True"
},
"location": "westus"
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AdminCredentials;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrateRolesEnum;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MigrationSecretParameters;
import com.azure.resourcemanager.postgresqlflexibleserver.models.OverwriteDbsInTargetEnum;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* Migrations_Create_With_Roles.json
*/
/**
* Sample code: Migrations Create with roles.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
migrationsCreateWithRoles(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4"))
.withOverwriteDbsInTarget(OverwriteDbsInTargetEnum.TRUE).withMigrateRoles(MigrateRolesEnum.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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrateRoles": "True",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_Roles.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create_With_Roles.json
func ExampleMigrationsClient_Create_migrationsCreateWithRoles() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumTrue),
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
},
}, 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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumTrue),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create_With_Roles.json
*/
async function migrationsCreateWithRoles() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrateRoles: "True",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create_With_Roles.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate =
{
"db1","db2","db3","db4"
},
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "True"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "True"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
Create a migration.
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampletarget/migrations/examplemigration?api-version=2024-08-01
{
"properties": {
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"secretParameters": {
"adminCredentials": {
"sourceServerPassword": "examplesourcepassword",
"targetServerPassword": "exampletargetpassword"
}
},
"migrationMode": "Offline",
"overwriteDbsInTarget": "True"
},
"location": "westus"
}
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.OverwriteDbsInTargetEnum;
import java.util.Arrays;
/**
* Samples for Migrations Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create.
* json
*/
/**
* Sample code: Migrations_Create.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void migrationsCreate(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.migrations().define("testmigration").withRegion("westus")
.withExistingFlexibleServer("ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget")
.withMigrationInstanceResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration")
.withMigrationMode(MigrationMode.OFFLINE)
.withSourceDbServerResourceId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource")
.withSecretParameters(new MigrationSecretParameters().withAdminCredentials(new AdminCredentials()
.withSourceServerPassword("fakeTokenPlaceholder").withTargetServerPassword("fakeTokenPlaceholder")))
.withDbsToMigrate(Arrays.asList("db1", "db2", "db3", "db4"))
.withOverwriteDbsInTarget(OverwriteDbsInTargetEnum.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(
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
resource_group_name="testrg",
target_db_server_name="testtarget",
migration_name="testmigration",
parameters={
"location": "westus",
"properties": {
"dbsToMigrate": ["db1", "db2", "db3", "db4"],
"migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration",
"migrationMode": "Offline",
"overwriteDbsInTarget": "True",
"secretParameters": {
"adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
},
},
)
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create.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/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Create.json
func ExampleMigrationsClient_Create_migrationsCreate() {
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, "ffffffff-ffff-ffff-ffff-ffffffffffff", "testrg", "testtarget", "testmigration", armpostgresqlflexibleservers.MigrationResource{
Location: to.Ptr("westus"),
Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
DbsToMigrate: []*string{
to.Ptr("db1"),
to.Ptr("db2"),
to.Ptr("db3"),
to.Ptr("db4")},
MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
MigrationMode: to.Ptr(armpostgresqlflexibleservers.MigrationModeOffline),
OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
SecretParameters: &armpostgresqlflexibleservers.MigrationSecretParameters{
AdminCredentials: &armpostgresqlflexibleservers.AdminCredentials{
SourceServerPassword: to.Ptr("xxxxxxxx"),
TargetServerPassword: to.Ptr("xxxxxxxx"),
},
},
SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
},
}, 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.MigrationResource = armpostgresqlflexibleservers.MigrationResource{
// Name: to.Ptr("testmigration"),
// Type: to.Ptr("Microsoft.DBForPostgreSql/flexibleServers/migrations"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget/migrations/testmigration"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key1624": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
// },
// Properties: &armpostgresqlflexibleservers.MigrationResourceProperties{
// CurrentStatus: &armpostgresqlflexibleservers.MigrationStatus{
// CurrentSubStateDetails: &armpostgresqlflexibleservers.MigrationSubStateDetails{
// CurrentSubState: to.Ptr(armpostgresqlflexibleservers.MigrationSubStatePerformingPreRequisiteSteps),
// },
// Error: to.Ptr(""),
// State: to.Ptr(armpostgresqlflexibleservers.MigrationStateInProgress),
// },
// DbsToMigrate: []*string{
// to.Ptr("db1"),
// to.Ptr("db2"),
// to.Ptr("db3"),
// to.Ptr("db4")},
// MigrateRoles: to.Ptr(armpostgresqlflexibleservers.MigrateRolesEnumFalse),
// MigrationID: to.Ptr("d3ceacbb-a5fd-43dc-a9db-6022b5154856"),
// MigrationInstanceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
// MigrationWindowStartTimeInUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-06T16:05:58.895Z"); return t}()),
// OverwriteDbsInTarget: to.Ptr(armpostgresqlflexibleservers.OverwriteDbsInTargetEnumTrue),
// SetupLogicalReplicationOnSourceDbIfNeeded: to.Ptr(armpostgresqlflexibleservers.LogicalReplicationOnSourceDbEnumFalse),
// SourceDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
// StartDataMigration: to.Ptr(armpostgresqlflexibleservers.StartDataMigrationEnumFalse),
// TargetDbServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testtarget"),
// TriggerCutover: to.Ptr(armpostgresqlflexibleservers.TriggerCutoverEnumFalse),
// },
// }
}
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/2024-08-01/examples/Migrations_Create.json
*/
async function migrationsCreate() {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const targetDbServerName = "testtarget";
const migrationName = "testmigration";
const parameters = {
dbsToMigrate: ["db1", "db2", "db3", "db4"],
location: "westus",
migrationInstanceResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration",
migrationMode: "Offline",
overwriteDbsInTarget: "True",
secretParameters: {
adminCredentials: {
sourceServerPassword: "xxxxxxxx",
targetServerPassword: "xxxxxxxx",
},
},
sourceDbServerResourceId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource",
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential);
const result = await client.migrations.create(
subscriptionId,
resourceGroupName,
targetDbServerName,
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/2024-08-01/examples/Migrations_Create.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://learn.microsoft.com/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 = "testrg";
string targetDbServerName = "testtarget";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// get the collection of this PostgreSqlMigrationResource
PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations();
// invoke the operation
string migrationName = "testmigration";
PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus"))
{
MigrationInstanceResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration"),
MigrationMode = PostgreSqlMigrationMode.Offline,
SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"),
SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")),
DbsToMigrate =
{
"db1","db2","db3","db4"
},
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
示例响应
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
{
"properties": {
"migrationId": "d3ceacbb-a5fd-43dc-a9db-6022b5154856",
"currentStatus": {
"state": "InProgress",
"error": "",
"currentSubStateDetails": {
"currentSubState": "PerformingPreRequisiteSteps"
}
},
"sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
"targetDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget",
"dbsToMigrate": [
"exampledatabase1",
"exampledatabase2",
"exampledatabase3",
"exampledatabase4"
],
"setupLogicalReplicationOnSourceDbIfNeeded": "False",
"overwriteDbsInTarget": "True",
"migrationWindowStartTimeInUtc": "2024-08-01T18:30:22.123456Z",
"startDataMigration": "False",
"triggerCutover": "False",
"migrateRoles": "False"
},
"tags": {
"key1624": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/exampletarget/migrations/examplemigration",
"name": "examplemigration",
"type": "Microsoft.DBForPostgreSql/flexibleServers/migrations"
}
定义
AdminCredentials
Object
源服务器和目标服务器的管理员用户的凭据。
名称 |
类型 |
说明 |
sourceServerPassword
|
string
|
源服务器用户的密码。
|
targetServerPassword
|
string
|
目标服务器用户的密码。
|
CancelEnum
枚举
指示是否必须为整个迁移触发 cancel。
createdByType
枚举
创建资源的标识的类型。
值 |
说明 |
Application
|
|
Key
|
|
ManagedIdentity
|
|
User
|
|
DbLevelValidationStatus
Object
数据库的验证状态摘要。
名称 |
类型 |
说明 |
databaseName
|
string
|
数据库的名称。
|
endedOn
|
string
(date-time)
|
数据库级别验证的结束时间。
|
startedOn
|
string
(date-time)
|
数据库级别验证的开始时间。
|
summary
|
ValidationSummaryItem[]
|
数据库级别验证摘要。
|
DbMigrationStatus
Object
数据库的迁移状态。
名称 |
类型 |
说明 |
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
|
MigrationDbState
|
数据库的迁移状态。
|
startedOn
|
string
(date-time)
|
迁移状态的开始时间。
|
Object
数据库服务器元数据。
名称 |
类型 |
说明 |
location
|
string
|
数据库服务器的位置。
|
sku
|
ServerSku
|
数据库服务器的计算层和大小。 对于 Azure Database for PostgreSQL 单一服务器,此对象为空。
|
storageMb
|
integer
(int32)
|
数据库服务器的存储大小(以 MB 为单位)。
|
version
|
string
|
PostgreSQL 数据库引擎的主要版本。
|
ErrorAdditionalInfo
Object
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
Object
错误详细信息。
ErrorResponse
Object
错误响应
LogicalReplicationOnSourceDbEnum
枚举
指示是否根据需要设置 LogicalReplicationOnSourceDb。
MigrateRolesEnum
枚举
指示是否必须迁移角色和权限。
MigrationDbState
枚举
数据库的迁移状态。
值 |
说明 |
Canceled
|
|
Canceling
|
|
Failed
|
|
InProgress
|
|
Succeeded
|
|
WaitingForCutoverTrigger
|
|
MigrationMode
枚举
用于执行迁移的模式:联机或脱机。
MigrationOption
枚举
迁移支持的选项
值 |
说明 |
Migrate
|
|
Validate
|
|
ValidateAndMigrate
|
|
MigrationResource
Object
迁移。
名称 |
类型 |
说明 |
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
location
|
string
|
资源所在的地理位置
|
name
|
string
|
资源的名称
|
properties.cancel
|
CancelEnum
|
指示是否必须为整个迁移触发 cancel。
|
properties.currentStatus
|
MigrationStatus
|
迁移的当前状态。
|
properties.dbsToCancelMigrationOn
|
string[]
|
如果要为特定数据库触发 cancel,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
properties.dbsToMigrate
|
string[]
|
要迁移的数据库的名称。
|
properties.dbsToTriggerCutoverOn
|
string[]
|
如果要触发特定数据库的直接转换,请将 'triggerCutover' 设置为 'True' 并设置此数组中特定数据库的名称。
|
properties.migrateRoles
|
MigrateRolesEnum
|
指示是否必须迁移角色和权限。
|
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
|
OverwriteDbsInTargetEnum
|
指示目标服务器上的数据库在已存在时是否可以被覆盖。 如果设置为 'False',则当迁移工作流检测到目标服务器上已存在数据库时,它将等待确认。
|
properties.secretParameters
|
MigrationSecretParameters
|
迁移机密参数。
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
LogicalReplicationOnSourceDbEnum
|
指示是否根据需要设置 LogicalReplicationOnSourceDb。
|
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
|
StartDataMigrationEnum
|
指示是否必须立即开始数据迁移。
|
properties.targetDbServerFullyQualifiedDomainName
|
string
|
目标服务器的完全限定域名 (FQDN) 或 IP 地址。 此属性是可选的。 提供后,迁移服务将始终使用它来连接到目标服务器。
|
properties.targetDbServerMetadata
|
DbServerMetadata
|
目标数据库服务器的元数据。
|
properties.targetDbServerResourceId
|
string
|
目标数据库服务器资源的标识符。
|
properties.triggerCutover
|
TriggerCutoverEnum
|
指示是否必须为整个迁移触发直接转换。
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
tags
|
object
|
资源标记。
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
MigrationSecretParameters
Object
迁移机密参数。
名称 |
类型 |
说明 |
adminCredentials
|
AdminCredentials
|
源服务器和目标服务器的管理员用户的凭据。
|
sourceServerUsername
|
string
|
获取或设置源服务器的用户名称。 此用户不需要是管理员。
|
targetServerUsername
|
string
|
获取或设置目标服务器的用户名称。 此用户不需要是管理员。
|
MigrationState
枚举
迁移状态。
值 |
说明 |
Canceled
|
|
CleaningUp
|
|
Failed
|
|
InProgress
|
|
Succeeded
|
|
ValidationFailed
|
|
WaitingForUserAction
|
|
MigrationStatus
Object
迁移状态。
MigrationSubState
枚举
迁移的子状态。
值 |
说明 |
CancelingRequestedDBMigrations
|
|
Completed
|
|
CompletingMigration
|
|
MigratingData
|
|
PerformingPreRequisiteSteps
|
|
ValidationInProgress
|
|
WaitingForCutoverTrigger
|
|
WaitingForDBsToMigrateSpecification
|
|
WaitingForDataMigrationScheduling
|
|
WaitingForDataMigrationWindow
|
|
WaitingForLogicalReplicationSetupRequestOnSourceDB
|
|
WaitingForTargetDBOverwriteConfirmation
|
|
MigrationSubStateDetails
Object
迁移子状态的详细信息。
OverwriteDbsInTargetEnum
枚举
指示目标服务器上的数据库在已存在时是否可以被覆盖。 如果设置为 'False',则当迁移工作流检测到目标服务器上已存在数据库时,它将等待确认。
ServerSku
Object
灵活服务器的计算信息。
名称 |
类型 |
说明 |
name
|
string
|
数据库服务器的计算层和大小。 对于 Azure Database for PostgreSQL 单一服务器,此对象为空。
|
tier
|
SkuTier
|
分配给灵活服务器的计算层。
|
SkuTier
枚举
如果服务具有多个层,但在 PUT 上不需要,则需要资源提供程序实现此字段。
值 |
说明 |
Basic
|
|
Free
|
|
Premium
|
|
Standard
|
|
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
值 |
说明 |
AWS
|
|
AWS_AURORA
|
|
AWS_EC2
|
|
AWS_RDS
|
|
AzureVM
|
|
EDB
|
|
GCP
|
|
GCP_AlloyDB
|
|
GCP_CloudSQL
|
|
GCP_Compute
|
|
OnPremises
|
|
PostgreSQLSingleServer
|
|
SslMode
枚举
迁移使用的 SSL 模式。 “PostgreSQLSingleServer”的默认 SSL 模式为“VerifyFull”。 其他源类型的默认 SSL 模式为 'Prefer'。
值 |
说明 |
Prefer
|
|
Require
|
|
VerifyCA
|
|
VerifyFull
|
|
StartDataMigrationEnum
枚举
指示是否必须立即开始数据迁移。
systemData
Object
与创建和上次修改资源相关的元数据。
名称 |
类型 |
说明 |
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
createdBy
|
string
|
创建资源的标识。
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
TriggerCutoverEnum
枚举
指示是否必须为整个迁移触发直接转换。
ValidationDetails
Object
迁移验证的详细信息。
ValidationMessage
Object
验证消息对象。
ValidationState
枚举
迁移的验证状态。
值 |
说明 |
Failed
|
|
Succeeded
|
|
Warning
|
|
ValidationSummaryItem
Object
验证摘要对象。