@azure/arm-mysql-flexible
Version:
A generated SDK for MySQLManagementFlexibleServerClient.
103 lines • 5.34 kB
JavaScript
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { __awaiter } from "tslib";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { MySQLManagementFlexibleServerClient } from "@azure/arm-mysql-flexible";
import { DefaultAzureCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
/**
* This sample demonstrates how to Creates a new server or updates an existing server. The update action will overwrite the existing server.
*
* @summary Creates a new server or updates an existing server. The update action will overwrite the existing server.
* x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreate.json
*/
function createANewServer() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = process.env["MYSQL_SUBSCRIPTION_ID"] ||
"ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["MYSQL_RESOURCE_GROUP"] || "testrg";
const serverName = "mysqltestserver";
const parameters = {
administratorLogin: "cloudsa",
administratorLoginPassword: "your_password",
availabilityZone: "1",
backup: { backupRetentionDays: 7, geoRedundantBackup: "Disabled" },
createMode: "Default",
highAvailability: { mode: "ZoneRedundant", standbyAvailabilityZone: "3" },
location: "southeastasia",
sku: { name: "Standard_D2ds_v4", tier: "GeneralPurpose" },
storage: { autoGrow: "Disabled", iops: 600, storageSizeGB: 100 },
tags: { num: "1" },
version: "5.7"
};
const credential = new DefaultAzureCredential();
const client = new MySQLManagementFlexibleServerClient(credential, subscriptionId);
const result = yield client.servers.beginCreateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
});
}
/**
* This sample demonstrates how to Creates a new server or updates an existing server. The update action will overwrite the existing server.
*
* @summary Creates a new server or updates an existing server. The update action will overwrite the existing server.
* x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateReplica.json
*/
function createAReplicaServer() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = process.env["MYSQL_SUBSCRIPTION_ID"] ||
"ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["MYSQL_RESOURCE_GROUP"] || "testgr";
const serverName = "replica-server";
const parameters = {
createMode: "Replica",
location: "SoutheastAsia",
sourceServerResourceId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"
};
const credential = new DefaultAzureCredential();
const client = new MySQLManagementFlexibleServerClient(credential, subscriptionId);
const result = yield client.servers.beginCreateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
});
}
/**
* This sample demonstrates how to Creates a new server or updates an existing server. The update action will overwrite the existing server.
*
* @summary Creates a new server or updates an existing server. The update action will overwrite the existing server.
* x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateWithPointInTimeRestore.json
*/
function createAServerAsAPointInTimeRestore() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = process.env["MYSQL_SUBSCRIPTION_ID"] ||
"ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["MYSQL_RESOURCE_GROUP"] || "TargetResourceGroup";
const serverName = "targetserver";
const parameters = {
createMode: "PointInTimeRestore",
location: "SoutheastAsia",
restorePointInTime: new Date("2021-06-24T00:00:37.467Z"),
sku: { name: "Standard_D14_v2", tier: "GeneralPurpose" },
sourceServerResourceId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/sourceserver",
tags: { num: "1" }
};
const credential = new DefaultAzureCredential();
const client = new MySQLManagementFlexibleServerClient(credential, subscriptionId);
const result = yield client.servers.beginCreateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
});
}
function main() {
return __awaiter(this, void 0, void 0, function* () {
createANewServer();
createAReplicaServer();
createAServerAsAPointInTimeRestore();
});
}
main().catch(console.error);
//# sourceMappingURL=serversCreateSample.js.map