Files
azure-sdk-for-js/sdk/sql/arm-sql/samples-dev/databaseAutomaticTuningOperationsUpdateSample.ts

58 lines
1.9 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { SqlManagementClient } from "@azure/arm-sql";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to update automatic tuning properties for target database.
*
* @summary update automatic tuning properties for target database.
* x-ms-original-file: 2025-01-01/DatabaseAutomaticTuningUpdateMax.json
*/
async function updatesDatabaseAutomaticTuningSettingsWithAllProperties(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseAutomaticTuningOperations.update(
"default-sql-onebox",
"testsvr11",
"db1",
{
desiredState: "Auto",
options: {
createIndex: { desiredState: "Off" },
dropIndex: { desiredState: "On" },
forceLastGoodPlan: { desiredState: "Default" },
},
},
);
console.log(result);
}
/**
* This sample demonstrates how to update automatic tuning properties for target database.
*
* @summary update automatic tuning properties for target database.
* x-ms-original-file: 2025-01-01/DatabaseAutomaticTuningUpdateMin.json
*/
async function updatesDatabaseAutomaticTuningSettingsWithMinimalProperties(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseAutomaticTuningOperations.update(
"default-sql-onebox",
"testsvr11",
"db1",
{ desiredState: "Auto" },
);
console.log(result);
}
async function main(): Promise<void> {
await updatesDatabaseAutomaticTuningSettingsWithAllProperties();
await updatesDatabaseAutomaticTuningSettingsWithMinimalProperties();
}
main().catch(console.error);