mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample demonstrates how to Create or replace an existing schedule.
|
|
*
|
|
* @summary Create or replace an existing schedule.
|
|
* x-ms-original-file: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_CreateOrUpdate.json
|
|
*/
|
|
|
|
import type { Schedule } from "@azure/arm-devtestlabs";
|
|
import { DevTestLabsClient } from "@azure/arm-devtestlabs";
|
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
|
|
async function schedulesCreateOrUpdate(): Promise<void> {
|
|
const subscriptionId = "{subscriptionId}";
|
|
const resourceGroupName = "resourceGroupName";
|
|
const labName = "{labName}";
|
|
const name = "{scheduleName}";
|
|
const schedule: Schedule = {
|
|
dailyRecurrence: { time: "{timeOfTheDayTheScheduleWillOccurEveryDay}" },
|
|
hourlyRecurrence: { minute: 30 },
|
|
location: "{location}",
|
|
notificationSettings: {
|
|
emailRecipient: "{email}",
|
|
notificationLocale: "EN",
|
|
status: "{Enabled|Disabled}",
|
|
timeInMinutes: 15,
|
|
webhookUrl: "{webhookUrl}",
|
|
},
|
|
status: "{Enabled|Disabled}",
|
|
tags: { tagName1: "tagValue1" },
|
|
targetResourceId:
|
|
"/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}",
|
|
taskType: "{myLabVmTaskType}",
|
|
timeZoneId: "Pacific Standard Time",
|
|
weeklyRecurrence: {
|
|
time: "{timeOfTheDayTheScheduleWillOccurOnThoseDays}",
|
|
weekdays: ["Monday", "Wednesday", "Friday"],
|
|
},
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new DevTestLabsClient(credential, subscriptionId);
|
|
const result = await client.schedules.createOrUpdate(resourceGroupName, labName, name, schedule);
|
|
console.log(result);
|
|
}
|
|
|
|
schedulesCreateOrUpdate().catch(console.error);
|