POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{vmName}/resize?api-version=2018-09-15
{
"size": "Standard_A4_v2"
}
import com.azure.resourcemanager.devtestlabs.models.ResizeLabVirtualMachineProperties;
public final class Main {
public static void virtualMachinesResize(com.azure.resourcemanager.devtestlabs.DevTestLabsManager manager) {
manager.virtualMachines().resize("resourceGroupName", "{labName}", "{vmName}",
new ResizeLabVirtualMachineProperties().withSize("Standard_A4_v2"), com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.devtestlabs import DevTestLabsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-devtestlabs
# USAGE
python virtual_machines_resize.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = DevTestLabsClient(
credential=DefaultAzureCredential(),
subscription_id="{subscriptionId}",
)
client.virtual_machines.begin_resize(
resource_group_name="resourceGroupName",
lab_name="{labName}",
name="{vmName}",
).result()
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armdevtestlabs_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devtestlabs/armdevtestlabs"
)
func ExampleVirtualMachinesClient_BeginResize() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdevtestlabs.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachinesClient().BeginResize(ctx, "resourceGroupName", "{labName}", "{vmName}", armdevtestlabs.ResizeLabVirtualMachineProperties{
Size: to.Ptr("Standard_A4_v2"),
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
_, err = poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { DevTestLabsClient } = require("@azure/arm-devtestlabs");
const { DefaultAzureCredential } = require("@azure/identity");
async function virtualMachinesResize() {
const subscriptionId = "{subscriptionId}";
const resourceGroupName = "resourceGroupName";
const labName = "{labName}";
const name = "{vmName}";
const resizeLabVirtualMachineProperties = {
size: "Standard_A4_v2",
};
const credential = new DefaultAzureCredential();
const client = new DevTestLabsClient(credential, subscriptionId);
const result = await client.virtualMachines.beginResizeAndWait(
resourceGroupName,
labName,
name,
resizeLabVirtualMachineProperties
);
console.log(result);
}
virtualMachinesResize().catch(console.error);
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.DevTestLabs.Models;
using Azure.ResourceManager.DevTestLabs;
TokenCredential cred = new DefaultAzureCredential();
ArmClient client = new ArmClient(cred);
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "resourceGroupName";
string labName = "{labName}";
string name = "{vmName}";
ResourceIdentifier devTestLabVmResourceId = DevTestLabVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, labName, name);
DevTestLabVmResource devTestLabVm = client.GetDevTestLabVmResource(devTestLabVmResourceId);
DevTestLabVmResizeContent content = new DevTestLabVmResizeContent
{
Size = "Standard_A4_v2",
};
await devTestLabVm.ResizeAsync(WaitUntil.Completed, content);
Console.WriteLine("Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue