mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
70 lines
2.8 KiB
TypeScript
70 lines
2.8 KiB
TypeScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample demonstrates how to Creates or updates a threat detection policy.
|
|
*
|
|
* @summary Creates or updates a threat detection policy.
|
|
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json
|
|
*/
|
|
|
|
import type { ServerSecurityAlertPolicy } from "@azure/arm-postgresql";
|
|
import { PostgreSQLManagementClient } from "@azure/arm-postgresql";
|
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
|
|
async function updateAServerThreatDetectionPolicyWithAllParameters(): Promise<void> {
|
|
const subscriptionId = "00000000-1111-2222-3333-444444444444";
|
|
const resourceGroupName = "securityalert-4799";
|
|
const serverName = "securityalert-6440";
|
|
const securityAlertPolicyName = "Default";
|
|
const parameters: ServerSecurityAlertPolicy = {
|
|
disabledAlerts: ["Access_Anomaly", "Usage_Anomaly"],
|
|
emailAccountAdmins: true,
|
|
emailAddresses: ["[email protected]"],
|
|
retentionDays: 5,
|
|
state: "Enabled",
|
|
storageAccountAccessKey:
|
|
"sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==",
|
|
storageEndpoint: "https://mystorage.blob.core.windows.net",
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new PostgreSQLManagementClient(credential, subscriptionId);
|
|
const result = await client.serverSecurityAlertPolicies.beginCreateOrUpdateAndWait(
|
|
resourceGroupName,
|
|
serverName,
|
|
securityAlertPolicyName,
|
|
parameters,
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
updateAServerThreatDetectionPolicyWithAllParameters().catch(console.error);
|
|
|
|
/**
|
|
* This sample demonstrates how to Creates or updates a threat detection policy.
|
|
*
|
|
* @summary Creates or updates a threat detection policy.
|
|
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json
|
|
*/
|
|
async function updateAServerThreatDetectionPolicyWithMinimalParameters(): Promise<void> {
|
|
const subscriptionId = "00000000-1111-2222-3333-444444444444";
|
|
const resourceGroupName = "securityalert-4799";
|
|
const serverName = "securityalert-6440";
|
|
const securityAlertPolicyName = "Default";
|
|
const parameters: ServerSecurityAlertPolicy = {
|
|
emailAccountAdmins: true,
|
|
state: "Disabled",
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new PostgreSQLManagementClient(credential, subscriptionId);
|
|
const result = await client.serverSecurityAlertPolicies.beginCreateOrUpdateAndWait(
|
|
resourceGroupName,
|
|
serverName,
|
|
securityAlertPolicyName,
|
|
parameters,
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
updateAServerThreatDetectionPolicyWithMinimalParameters().catch(console.error);
|