Files
5b42eac518 [AutoPR @azure-arm-networkcloud]-generated-from-SDK Generation - JS-6259530 (#38443)
Configurations:
'specification/networkcloud/NetworkCloud.Management/tspconfig.yaml', API
Version: 2026-05-01-preview, SDK Release Type: beta, and CommitSHA:
'13d51ee484703ea6845668fbf4b9de13f41bf5c2' in SpecRepo:
'https://github.com/Azure/azure-rest-api-specs' Pipeline run:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6259530
Refer to
https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites
to prepare for SDK release. **Release plan link:**
https://azsdk-releaseplan-dashboard-hveph5aqhhcfhtgu.westus-01.azurewebsites.net/?releasePlan=2218
**Submitted by**: [email protected]
## Release Plan Details
- Release Plan:
https://azsdk-releaseplan-dashboard-hveph5aqhhcfhtgu.westus-01.azurewebsites.net/?releasePlan=2218
Spec pull request:
https://github.com/Azure/azure-rest-api-specs/pull/42234
Spec API version:

---------

Co-authored-by: kazrael2119 <[email protected]>
Co-authored-by: nafizhaider32 <[email protected]>
2026-06-18 10:55:56 +08:00

94 lines
3.7 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { NetworkCloud } from "@azure/arm-networkcloud";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to create a new virtual machine or update the properties of the existing virtual machine.
*
* @summary create a new virtual machine or update the properties of the existing virtual machine.
* x-ms-original-file: 2026-05-01-preview/VirtualMachines_Create.json
*/
async function createOrUpdateVirtualMachine(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "123e4567-e89b-12d3-a456-426655440000";
const client = new NetworkCloud(credential, subscriptionId);
const result = await client.virtualMachines.createOrUpdate(
"resourceGroupName",
"virtualMachineName",
{
extendedLocation: {
name: "/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName",
type: "CustomLocation",
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1":
{},
},
},
location: "location",
adminUsername: "username",
bootMethod: "UEFI",
cloudServicesNetworkAttachment: {
attachedNetworkId:
"/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName",
ipAllocationMethod: "Dynamic",
},
cpuCores: 2,
memorySizeGB: 8,
networkAttachments: [
{
attachedNetworkId:
"/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName",
defaultGateway: "True",
ipAllocationMethod: "Dynamic",
ipv4Address: "198.51.100.1",
ipv6Address: "2001:0db8:0000:0000:0000:0000:0000:0000",
networkAttachmentName: "netAttachName01",
},
],
networkDataContent: "bmV0d29ya0RhdGVTYW1wbGU=",
placementHints: [
{
hintType: "Affinity",
resourceId:
"/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/racks/rackName",
schedulingExecution: "Hard",
scope: "",
},
],
sshPublicKeys: [
{
keyData:
"ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm",
},
],
storageProfile: {
osDisk: { createOption: "Ephemeral", deleteOption: "Delete", diskSizeGB: 120 },
volumeAttachments: [
"/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/volumes/volumeName",
],
},
userDataContent: "dXNlckRhdGVTYW1wbGU=",
vmDeviceModel: "T2",
vmImage: "myacr.azurecr.io/foobar:latest",
vmImageRepositoryCredentials: {
password: "{password}",
registryUrl: "myacr.azurecr.io",
username: "myuser",
},
tags: { key1: "myvalue1", key2: "myvalue2" },
},
);
console.log(result);
}
async function main(): Promise<void> {
await createOrUpdateVirtualMachine();
}
main().catch(console.error);