Files
bf243569b1 [AutoPR @azure-arm-devcenter]-generated-from-SDK Generation - JS-6539157 (#39218)
Configurations:
'specification/devcenter/DevCenter.Management/tspconfig.yaml', SDK
Release Type: beta, and CommitSHA:
'473a3bcb1ab8ce3a94e032b59f26b0bf1609064f' in SpecRepo:
'https://github.com/Azure/azure-rest-api-specs' Pipeline run:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6539157
Refer to
https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites
to prepare for SDK release.

---------

Co-authored-by: azure-sdk <[email protected]>
Co-authored-by: ZiWei Chen <[email protected]>
2026-07-10 15:58:41 +08:00

106 lines
4.0 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { DevCenterClient } from "@azure/arm-devcenter";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to creates or updates a machine pool.
*
* @summary creates or updates a machine pool.
* x-ms-original-file: 2026-01-01-preview/Pools_Put.json
*/
async function poolsCreateOrUpdate(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
const client = new DevCenterClient(credential, subscriptionId);
const result = await client.pools.createOrUpdate("rg1", "DevProject", "DevPool", {
location: "centralus",
activeHoursConfiguration: {
autoStartEnableStatus: "Enabled",
daysOfWeekLimit: 5,
defaultDaysOfWeek: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
defaultEndTimeHour: 17,
defaultStartTimeHour: 9,
defaultTimeZone: "America/Los_Angeles",
keepAwakeEnableStatus: "Enabled",
},
devBoxDefinitionName: "WebDevBox",
displayName: "Developer Pool",
licenseType: "Windows_Client",
localAdministrator: "Enabled",
networkConnectionName: "Network1-westus2",
singleSignOnStatus: "Disabled",
stopOnDisconnect: { gracePeriodMinutes: 60, status: "Enabled" },
stopOnNoConnect: { gracePeriodMinutes: 120, status: "Enabled" },
virtualNetworkType: "Unmanaged",
});
console.log(result);
}
/**
* This sample demonstrates how to creates or updates a machine pool.
*
* @summary creates or updates a machine pool.
* x-ms-original-file: 2026-01-01-preview/Pools_PutWithManagedNetwork.json
*/
async function poolsCreateOrUpdateWithManagedNetwork(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
const client = new DevCenterClient(credential, subscriptionId);
const result = await client.pools.createOrUpdate("rg1", "DevProject", "DevPool", {
location: "centralus",
devBoxDefinitionName: "WebDevBox",
displayName: "Developer Pool",
licenseType: "Windows_Client",
localAdministrator: "Enabled",
managedVirtualNetworkRegions: ["centralus"],
networkConnectionName: "managedNetwork",
singleSignOnStatus: "Disabled",
stopOnDisconnect: { gracePeriodMinutes: 60, status: "Enabled" },
stopOnNoConnect: { gracePeriodMinutes: 120, status: "Enabled" },
virtualNetworkType: "Managed",
});
console.log(result);
}
/**
* This sample demonstrates how to creates or updates a machine pool.
*
* @summary creates or updates a machine pool.
* x-ms-original-file: 2026-01-01-preview/Pools_PutWithValueDevBoxDefinition.json
*/
async function poolsCreateOrUpdateWithValueDevBoxDefinition(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
const client = new DevCenterClient(credential, subscriptionId);
const result = await client.pools.createOrUpdate("rg1", "DevProject", "DevPool", {
location: "centralus",
devBoxDefinition: {
imageReference: {
id: "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/projects/DevProject/images/exampleImage/version/1.0.0",
},
sku: { name: "Preview" },
},
devBoxDefinitionName: "",
devBoxDefinitionType: "Value",
displayName: "Developer Pool",
licenseType: "Windows_Client",
localAdministrator: "Enabled",
networkConnectionName: "Network1-westus2",
singleSignOnStatus: "Disabled",
stopOnDisconnect: { gracePeriodMinutes: 60, status: "Enabled" },
stopOnNoConnect: { gracePeriodMinutes: 120, status: "Enabled" },
virtualNetworkType: "Unmanaged",
});
console.log(result);
}
async function main(): Promise<void> {
await poolsCreateOrUpdate();
await poolsCreateOrUpdateWithManagedNetwork();
await poolsCreateOrUpdateWithValueDevBoxDefinition();
}
main().catch(console.error);