mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
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]>
119 lines
4.6 KiB
TypeScript
119 lines
4.6 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 project.
|
|
*
|
|
* @summary creates or updates a project.
|
|
* x-ms-original-file: 2026-01-01-preview/Projects_Put.json
|
|
*/
|
|
async function projectsCreateOrUpdate(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
|
|
const client = new DevCenterClient(credential, subscriptionId);
|
|
const result = await client.projects.createOrUpdate("rg1", "DevProject", {
|
|
location: "centralus",
|
|
description: "This is my first project.",
|
|
devCenterId:
|
|
"/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso",
|
|
displayName: "Dev",
|
|
assignedGroups: [
|
|
{ objectId: "11111111-1111-1111-1111-111111111111", scope: "DevBox" },
|
|
{ objectId: "22222222-2222-2222-2222-222222222222", scope: "DevBox" },
|
|
],
|
|
tags: { CostCenter: "R&D" },
|
|
});
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates or updates a project.
|
|
*
|
|
* @summary creates or updates a project.
|
|
* x-ms-original-file: 2026-01-01-preview/Projects_PutWithCustomizationSettings.json
|
|
*/
|
|
async function projectsCreateOrUpdateWithCustomizationSettings(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
|
|
const client = new DevCenterClient(credential, subscriptionId);
|
|
const result = await client.projects.createOrUpdate("rg1", "DevProject", {
|
|
identity: {
|
|
type: "UserAssigned",
|
|
userAssignedIdentities: {
|
|
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1":
|
|
{},
|
|
},
|
|
},
|
|
location: "centralus",
|
|
description: "This is my first project.",
|
|
customizationSettings: {
|
|
identities: [
|
|
{
|
|
identityResourceId:
|
|
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1",
|
|
identityType: "userAssignedIdentity",
|
|
},
|
|
],
|
|
},
|
|
devCenterId:
|
|
"/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso",
|
|
tags: { CostCenter: "R&D" },
|
|
});
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates or updates a project.
|
|
*
|
|
* @summary creates or updates a project.
|
|
* x-ms-original-file: 2026-01-01-preview/Projects_PutWithCustomizationSettings_SystemIdentity.json
|
|
*/
|
|
async function projectsCreateOrUpdateWithCustomizationSettingsSystemIdentity(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
|
|
const client = new DevCenterClient(credential, subscriptionId);
|
|
const result = await client.projects.createOrUpdate("rg1", "DevProject", {
|
|
identity: { type: "SystemAssigned" },
|
|
location: "centralus",
|
|
description: "This is my first project.",
|
|
customizationSettings: { identities: [{ identityType: "systemAssignedIdentity" }] },
|
|
devCenterId:
|
|
"/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso",
|
|
tags: { CostCenter: "R&D" },
|
|
});
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to creates or updates a project.
|
|
*
|
|
* @summary creates or updates a project.
|
|
* x-ms-original-file: 2026-01-01-preview/Projects_PutWithMaxDevBoxPerUser.json
|
|
*/
|
|
async function projectsCreateOrUpdateWithLimitsPerDev(): Promise<void> {
|
|
const credential = new DefaultAzureCredential();
|
|
const subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58fffff";
|
|
const client = new DevCenterClient(credential, subscriptionId);
|
|
const result = await client.projects.createOrUpdate("rg1", "DevProject", {
|
|
location: "centralus",
|
|
description: "This is my first project.",
|
|
devCenterId:
|
|
"/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso",
|
|
maxDevBoxesPerUser: 3,
|
|
tags: { CostCenter: "R&D" },
|
|
});
|
|
console.log(result);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
await projectsCreateOrUpdate();
|
|
await projectsCreateOrUpdateWithCustomizationSettings();
|
|
await projectsCreateOrUpdateWithCustomizationSettingsSystemIdentity();
|
|
await projectsCreateOrUpdateWithLimitsPerDev();
|
|
}
|
|
|
|
main().catch(console.error);
|