Creates a new migration.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}?api-version=2024-08-01
URI Parameters
Name |
In |
Required |
Type |
Description |
migrationName
|
path |
True
|
string
pattern: ^[a-z][a-z0-9]*$
|
Name of migration.
|
resourceGroupName
|
path |
True
|
string
pattern: ^[-a-z0-9A-Z._()]+[^.]$
|
Name of resource group of target database server.
|
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}
|
Identifier of subscription of target database server.
|
targetDbServerName
|
path |
True
|
string
pattern: ([-a-z0-9]){3,63}
|
Name of target database server.
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
Name |
Required |
Type |
Description |
location
|
True
|
string
|
The geo-location where the resource lives
|
properties.cancel
|
|
CancelEnum
|
Indicates if cancel must be triggered for the entire migration.
|
properties.dbsToCancelMigrationOn
|
|
string[]
|
When you want to trigger cancel for specific databases set 'triggerCutover' to 'True' and the names of the specific databases in this array.
|
properties.dbsToMigrate
|
|
string[]
|
Names of databases to migrate.
|
properties.dbsToTriggerCutoverOn
|
|
string[]
|
When you want to trigger cutover for specific databases set 'triggerCutover' to 'True' and the names of the specific databases in this array.
|
properties.migrateRoles
|
|
MigrateRolesEnum
|
Indicates if roles and permissions must be migrated.
|
properties.migrationInstanceResourceId
|
|
string
(arm-id)
|
Identifier of the private endpoint migration instance.
|
properties.migrationMode
|
|
MigrationMode
|
Mode used to perform the migration: Online or Offline.
|
properties.migrationOption
|
|
MigrationOption
|
Supported option for a migration.
|
properties.migrationWindowEndTimeInUtc
|
|
string
(date-time)
|
End time (UTC) for migration window.
|
properties.migrationWindowStartTimeInUtc
|
|
string
(date-time)
|
Start time (UTC) for migration window.
|
properties.overwriteDbsInTarget
|
|
OverwriteDbsInTargetEnum
|
Indicates if databases on the target server can be overwritten when already present. If set to 'False', when the migration workflow detects that the database already exists on the target server, it will wait for a confirmation.
|
properties.secretParameters
|
|
MigrationSecretParameters
|
Migration secret parameters.
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
|
LogicalReplicationOnSourceDbEnum
|
Indicates whether to setup LogicalReplicationOnSourceDb, if needed.
|
properties.sourceDbServerFullyQualifiedDomainName
|
|
string
|
Fully qualified domain name (FQDN) or IP address of the source server. This property is optional. When provided, the migration service will always use it to connect to the source server.
|
properties.sourceDbServerResourceId
|
|
string
|
Identifier of the source database server resource, when 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to ipaddress:port@username or hostname:port@username.
|
properties.sourceType
|
|
SourceType
|
Source server type used for the migration: 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, or Supabase_PostgreSQL
|
properties.sslMode
|
|
SslMode
|
SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is 'VerifyFull'. Default SSL mode for other source types is 'Prefer'.
|
properties.startDataMigration
|
|
StartDataMigrationEnum
|
Indicates if data migration must start right away.
|
properties.targetDbServerFullyQualifiedDomainName
|
|
string
|
Fully qualified domain name (FQDN) or IP address of the target server. This property is optional. When provided, the migration service will always use it to connect to the target server.
|
properties.triggerCutover
|
|
TriggerCutoverEnum
|
Indicates if cutover must be triggered for the entire migration.
|
tags
|
|
object
|
Resource tags.
|
Responses
Security
azure_auth
Microsoft Entra OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Create a migration for validating only.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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"
}
Definitions
Name |
Description |
AdminCredentials
|
Credentials of administrator users for source and target servers.
|
CancelEnum
|
Indicates if cancel must be triggered for the entire migration.
|
createdByType
|
The type of identity that created the resource.
|
DbLevelValidationStatus
|
Validation status summary for a database.
|
DbMigrationStatus
|
Migration status of a database.
|
DbServerMetadata
|
Database server metadata.
|
ErrorAdditionalInfo
|
The resource management error additional info.
|
ErrorDetail
|
The error detail.
|
ErrorResponse
|
Error response
|
LogicalReplicationOnSourceDbEnum
|
Indicates whether to setup LogicalReplicationOnSourceDb, if needed.
|
MigrateRolesEnum
|
Indicates if roles and permissions must be migrated.
|
MigrationDbState
|
Migration state of a database.
|
MigrationMode
|
Mode used to perform the migration: Online or Offline.
|
MigrationOption
|
Supported option for a migration
|
MigrationResource
|
Migration.
|
MigrationSecretParameters
|
Migration secret parameters.
|
MigrationState
|
State of migration.
|
MigrationStatus
|
State of migration.
|
MigrationSubState
|
Substate of migration.
|
MigrationSubStateDetails
|
Details of migration substate.
|
OverwriteDbsInTargetEnum
|
Indicates if databases on the target server can be overwritten when already present. If set to 'False', when the migration workflow detects that the database already exists on the target server, it will wait for a confirmation.
|
ServerSku
|
Compute information of a flexible server.
|
SkuTier
|
This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
|
SourceType
|
Source server type used for the migration: 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, or Supabase_PostgreSQL
|
SslMode
|
SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is 'VerifyFull'. Default SSL mode for other source types is 'Prefer'.
|
StartDataMigrationEnum
|
Indicates if data migration must start right away.
|
systemData
|
Metadata pertaining to creation and last modification of the resource.
|
TriggerCutoverEnum
|
Indicates if cutover must be triggered for the entire migration.
|
ValidationDetails
|
Details for the validation for migration.
|
ValidationMessage
|
Validation message object.
|
ValidationState
|
Validation status for migration.
|
ValidationSummaryItem
|
Validation summary object.
|
AdminCredentials
Object
Credentials of administrator users for source and target servers.
Name |
Type |
Description |
sourceServerPassword
|
string
|
Password for the user of the source server.
|
targetServerPassword
|
string
|
Password for the user of the target server.
|
CancelEnum
Enumeration
Indicates if cancel must be triggered for the entire migration.
Value |
Description |
False
|
|
True
|
|
createdByType
Enumeration
The type of identity that created the resource.
Value |
Description |
Application
|
|
Key
|
|
ManagedIdentity
|
|
User
|
|
DbLevelValidationStatus
Object
Validation status summary for a database.
Name |
Type |
Description |
databaseName
|
string
|
Name of database.
|
endedOn
|
string
(date-time)
|
End time of a database level validation.
|
startedOn
|
string
(date-time)
|
Start time of a database level validation.
|
summary
|
ValidationSummaryItem[]
|
Summary of database level validations.
|
DbMigrationStatus
Object
Migration status of a database.
Name |
Type |
Description |
appliedChanges
|
integer
(int32)
|
Change Data Capture applied changes counter.
|
cdcDeleteCounter
|
integer
(int32)
|
Change Data Capture delete counter.
|
cdcInsertCounter
|
integer
(int32)
|
Change Data Capture insert counter.
|
cdcUpdateCounter
|
integer
(int32)
|
Change Data Capture update counter.
|
databaseName
|
string
|
Name of database.
|
endedOn
|
string
(date-time)
|
End time of a migration state.
|
fullLoadCompletedTables
|
integer
(int32)
|
Number of tables loaded during the migration of a database.
|
fullLoadErroredTables
|
integer
(int32)
|
Number of tables encountering errors during the migration of a database.
|
fullLoadLoadingTables
|
integer
(int32)
|
Number of tables loading during the migration of a database.
|
fullLoadQueuedTables
|
integer
(int32)
|
Number of tables queued for the migration of a database.
|
incomingChanges
|
integer
(int32)
|
Change Data Capture incoming changes counter.
|
latency
|
integer
(int32)
|
Lag in seconds between source and target during online phase.
|
message
|
string
|
Error message, if any, for the migration state.
|
migrationOperation
|
string
|
Migration operation of a database.
|
migrationState
|
MigrationDbState
|
Migration state of a database.
|
startedOn
|
string
(date-time)
|
Start time of a migration state.
|
Object
Database server metadata.
Name |
Type |
Description |
location
|
string
|
Location of database server.
|
sku
|
ServerSku
|
Compute tier and size of the database server. This object is empty for an Azure Database for PostgreSQL single server.
|
storageMb
|
integer
(int32)
|
Storage size (in MB) for database server.
|
version
|
string
|
Major version of PostgreSQL database engine.
|
ErrorAdditionalInfo
Object
The resource management error additional info.
Name |
Type |
Description |
info
|
object
|
The additional info.
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
code
|
string
|
The error code.
|
details
|
ErrorDetail[]
|
The error details.
|
message
|
string
|
The error message.
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
Name |
Type |
Description |
error
|
ErrorDetail
|
The error object.
|
LogicalReplicationOnSourceDbEnum
Enumeration
Indicates whether to setup LogicalReplicationOnSourceDb, if needed.
Value |
Description |
False
|
|
True
|
|
MigrateRolesEnum
Enumeration
Indicates if roles and permissions must be migrated.
Value |
Description |
False
|
|
True
|
|
MigrationDbState
Enumeration
Migration state of a database.
Value |
Description |
Canceled
|
|
Canceling
|
|
Failed
|
|
InProgress
|
|
Succeeded
|
|
WaitingForCutoverTrigger
|
|
MigrationMode
Enumeration
Mode used to perform the migration: Online or Offline.
Value |
Description |
Offline
|
|
Online
|
|
MigrationOption
Enumeration
Supported option for a migration
Value |
Description |
Migrate
|
|
Validate
|
|
ValidateAndMigrate
|
|
MigrationResource
Object
Migration.
Name |
Type |
Description |
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
location
|
string
|
The geo-location where the resource lives
|
name
|
string
|
The name of the resource
|
properties.cancel
|
CancelEnum
|
Indicates if cancel must be triggered for the entire migration.
|
properties.currentStatus
|
MigrationStatus
|
Current status of a migration.
|
properties.dbsToCancelMigrationOn
|
string[]
|
When you want to trigger cancel for specific databases set 'triggerCutover' to 'True' and the names of the specific databases in this array.
|
properties.dbsToMigrate
|
string[]
|
Names of databases to migrate.
|
properties.dbsToTriggerCutoverOn
|
string[]
|
When you want to trigger cutover for specific databases set 'triggerCutover' to 'True' and the names of the specific databases in this array.
|
properties.migrateRoles
|
MigrateRolesEnum
|
Indicates if roles and permissions must be migrated.
|
properties.migrationId
|
string
|
Identifier of a migration.
|
properties.migrationInstanceResourceId
|
string
(arm-id)
|
Identifier of the private endpoint migration instance.
|
properties.migrationMode
|
MigrationMode
|
Mode used to perform the migration: Online or Offline.
|
properties.migrationOption
|
MigrationOption
|
Supported option for a migration.
|
properties.migrationWindowEndTimeInUtc
|
string
(date-time)
|
End time (UTC) for migration window.
|
properties.migrationWindowStartTimeInUtc
|
string
(date-time)
|
Start time (UTC) for migration window.
|
properties.overwriteDbsInTarget
|
OverwriteDbsInTargetEnum
|
Indicates if databases on the target server can be overwritten when already present. If set to 'False', when the migration workflow detects that the database already exists on the target server, it will wait for a confirmation.
|
properties.secretParameters
|
MigrationSecretParameters
|
Migration secret parameters.
|
properties.setupLogicalReplicationOnSourceDbIfNeeded
|
LogicalReplicationOnSourceDbEnum
|
Indicates whether to setup LogicalReplicationOnSourceDb, if needed.
|
properties.sourceDbServerFullyQualifiedDomainName
|
string
|
Fully qualified domain name (FQDN) or IP address of the source server. This property is optional. When provided, the migration service will always use it to connect to the source server.
|
properties.sourceDbServerMetadata
|
DbServerMetadata
|
Metadata of source database server.
|
properties.sourceDbServerResourceId
|
string
|
Identifier of the source database server resource, when 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to ipaddress:port@username or hostname:port@username.
|
properties.sourceType
|
SourceType
|
Source server type used for the migration: 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, or Supabase_PostgreSQL
|
properties.sslMode
|
SslMode
|
SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is 'VerifyFull'. Default SSL mode for other source types is 'Prefer'.
|
properties.startDataMigration
|
StartDataMigrationEnum
|
Indicates if data migration must start right away.
|
properties.targetDbServerFullyQualifiedDomainName
|
string
|
Fully qualified domain name (FQDN) or IP address of the target server. This property is optional. When provided, the migration service will always use it to connect to the target server.
|
properties.targetDbServerMetadata
|
DbServerMetadata
|
Metadata of target database server.
|
properties.targetDbServerResourceId
|
string
|
Identifier of the target database server resource.
|
properties.triggerCutover
|
TriggerCutoverEnum
|
Indicates if cutover must be triggered for the entire migration.
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
tags
|
object
|
Resource tags.
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
MigrationSecretParameters
Object
Migration secret parameters.
Name |
Type |
Description |
adminCredentials
|
AdminCredentials
|
Credentials of administrator users for source and target servers.
|
sourceServerUsername
|
string
|
Gets or sets the name of the user for the source server. This user doesn't need to be an administrator.
|
targetServerUsername
|
string
|
Gets or sets the name of the user for the target server. This user doesn't need to be an administrator.
|
MigrationState
Enumeration
State of migration.
Value |
Description |
Canceled
|
|
CleaningUp
|
|
Failed
|
|
InProgress
|
|
Succeeded
|
|
ValidationFailed
|
|
WaitingForUserAction
|
|
MigrationStatus
Object
State of migration.
Name |
Type |
Description |
currentSubStateDetails
|
MigrationSubStateDetails
|
Current migration sub state details.
|
error
|
string
|
Error message, if any, for the migration state.
|
state
|
MigrationState
|
State of migration.
|
MigrationSubState
Enumeration
Substate of migration.
Value |
Description |
CancelingRequestedDBMigrations
|
|
Completed
|
|
CompletingMigration
|
|
MigratingData
|
|
PerformingPreRequisiteSteps
|
|
ValidationInProgress
|
|
WaitingForCutoverTrigger
|
|
WaitingForDBsToMigrateSpecification
|
|
WaitingForDataMigrationScheduling
|
|
WaitingForDataMigrationWindow
|
|
WaitingForLogicalReplicationSetupRequestOnSourceDB
|
|
WaitingForTargetDBOverwriteConfirmation
|
|
MigrationSubStateDetails
Object
Details of migration substate.
OverwriteDbsInTargetEnum
Enumeration
Indicates if databases on the target server can be overwritten when already present. If set to 'False', when the migration workflow detects that the database already exists on the target server, it will wait for a confirmation.
Value |
Description |
False
|
|
True
|
|
ServerSku
Object
Compute information of a flexible server.
Name |
Type |
Description |
name
|
string
|
Compute tier and size of the database server. This object is empty for an Azure Database for PostgreSQL single server.
|
tier
|
SkuTier
|
Tier of the compute assigned to a flexible server.
|
SkuTier
Enumeration
This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
Value |
Description |
Basic
|
|
Free
|
|
Premium
|
|
Standard
|
|
SourceType
Enumeration
Source server type used for the migration: 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, or Supabase_PostgreSQL
Value |
Description |
AWS
|
|
AWS_AURORA
|
|
AWS_EC2
|
|
AWS_RDS
|
|
AzureVM
|
|
EDB
|
|
GCP
|
|
GCP_AlloyDB
|
|
GCP_CloudSQL
|
|
GCP_Compute
|
|
OnPremises
|
|
PostgreSQLSingleServer
|
|
SslMode
Enumeration
SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is 'VerifyFull'. Default SSL mode for other source types is 'Prefer'.
Value |
Description |
Prefer
|
|
Require
|
|
VerifyCA
|
|
VerifyFull
|
|
StartDataMigrationEnum
Enumeration
Indicates if data migration must start right away.
Value |
Description |
False
|
|
True
|
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
Name |
Type |
Description |
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
createdBy
|
string
|
The identity that created the resource.
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
TriggerCutoverEnum
Enumeration
Indicates if cutover must be triggered for the entire migration.
Value |
Description |
False
|
|
True
|
|
ValidationDetails
Object
Details for the validation for migration.
Name |
Type |
Description |
dbLevelValidationDetails
|
DbLevelValidationStatus[]
|
Details of server level validations.
|
serverLevelValidationDetails
|
ValidationSummaryItem[]
|
Details of server level validations.
|
status
|
ValidationState
|
Validation status for migration.
|
validationEndTimeInUtc
|
string
(date-time)
|
End time (UTC) for validation.
|
validationStartTimeInUtc
|
string
(date-time)
|
Start time (UTC) for validation.
|
ValidationMessage
Object
Validation message object.
Name |
Type |
Description |
message
|
string
|
Validation message string.
|
state
|
ValidationState
|
Severity of validation message.
|
ValidationState
Enumeration
Validation status for migration.
Value |
Description |
Failed
|
|
Succeeded
|
|
Warning
|
|
ValidationSummaryItem
Object
Validation summary object.