mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
Configurations: 'specification/postgresql/DBforPostgreSQL.Management/tspconfig.yaml', SDK Release Type: beta, and CommitSHA: 'd5ee6b87272dea7413a15e1403db07fe0450316a' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6405188 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. **Release plan link:** [https://azsdk-releaseplan-dashboard-hveph5aqhhcfhtgu.westus-01.azurewebsites.net/?releaseplan=2264](https://azsdk-releaseplan-dashboard-hveph5aqhhcfhtgu.westus-01.azurewebsites.net/?releaseplan=2264) **Submitted by**: [email protected] --------- Co-authored-by: kazrael2119 <[email protected]>
283 lines
9.6 KiB
TypeScript
283 lines
9.6 KiB
TypeScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible";
|
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreate.json
|
|
*/
|
|
async function createAMigration(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationMode: "Offline",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
},
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateOtherSourceTypesValidateMigrate.json
|
|
*/
|
|
async function createAMigrationWithOtherSourceTypeForValidatingAndMigrating(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationMode: "Offline",
|
|
migrationOption: "ValidateAndMigrate",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
},
|
|
sourceDbServerResourceId: "examplesource:5432@exampleuser",
|
|
sourceType: "OnPremises",
|
|
sslMode: "Prefer",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateValidateOnly.json
|
|
*/
|
|
async function createAMigrationForValidatingOnly(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationMode: "Offline",
|
|
migrationOption: "Validate",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
},
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateWithFullyQualifiedDomainName.json
|
|
*/
|
|
async function createAMigrationWithFullyQualifiedDomainNamesForSourceAndTargetServers(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationMode: "Offline",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: { sourceServerPassword: "xxxxxxxx", targetServerPassword: "xxxxxxxx" },
|
|
},
|
|
sourceDbServerFullyQualifiedDomainName: "examplesource.contoso.com",
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
targetDbServerFullyQualifiedDomainName: "exampletarget.contoso.com",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateWithOtherUsers.json
|
|
*/
|
|
async function createAMigrationSpecifyingUserNames(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationMode: "Offline",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
sourceServerUsername: "newadmin@examplesource",
|
|
targetServerUsername: "targetadmin",
|
|
},
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateWithPrivateEndpointServers.json
|
|
*/
|
|
async function createAMigrationWithPrivateEndpoint(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrationInstanceResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/flexibleServers/examplesourcemigration",
|
|
migrationMode: "Offline",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
},
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates a new migration.
|
|
*
|
|
* @summary creates a new migration.
|
|
* x-ms-original-file: 2026-04-01-preview/MigrationsCreateWithRoles.json
|
|
*/
|
|
async function createAMigrationWithRoles(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
|
|
const result = await client.migrations.create(
|
|
"exampleresourcegroup",
|
|
"exampleserver",
|
|
"examplemigration",
|
|
{
|
|
location: "eastus",
|
|
dbsToMigrate: [
|
|
"exampledatabase1",
|
|
"exampledatabase2",
|
|
"exampledatabase3",
|
|
"exampledatabase4",
|
|
],
|
|
migrateRoles: "True",
|
|
migrationMode: "Offline",
|
|
overwriteDbsInTarget: "True",
|
|
secretParameters: {
|
|
adminCredentials: {
|
|
sourceServerPassword: "examplesourcepassword",
|
|
targetServerPassword: "exampletargetpassword",
|
|
},
|
|
},
|
|
sourceDbServerResourceId:
|
|
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBForPostgreSql/servers/examplesource",
|
|
},
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
await createAMigration();
|
|
await createAMigrationWithOtherSourceTypeForValidatingAndMigrating();
|
|
await createAMigrationForValidatingOnly();
|
|
await createAMigrationWithFullyQualifiedDomainNamesForSourceAndTargetServers();
|
|
await createAMigrationSpecifyingUserNames();
|
|
await createAMigrationWithPrivateEndpoint();
|
|
await createAMigrationWithRoles();
|
|
}
|
|
|
|
main().catch(console.error);
|