Crie ou atualize um conjunto de escala de VM.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}?api-version=2024-07-01
Parâmetros do URI
Name |
Em |
Necessário |
Tipo |
Description |
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos.
|
subscriptionId
|
path |
True
|
string
|
Credenciais de assinatura que identificam exclusivamente a assinatura do Microsoft Azure. O ID da assinatura faz parte do URI de cada chamada de serviço.
|
vmScaleSetName
|
path |
True
|
string
|
O nome da escala da VM definida para criar ou atualizar.
|
api-version
|
query |
True
|
string
|
Versão da API do cliente.
|
Name |
Necessário |
Tipo |
Description |
If-Match
|
|
string
|
O ETag da transformação. Omita esse valor para sempre substituir o recurso atual. Especifique o valor ETag visto pela última vez para evitar a substituição acidental de alterações simultâneas.
|
If-None-Match
|
|
string
|
Defina como '*' para permitir que um novo conjunto de registros seja criado, mas para impedir a atualização de um conjunto de registros existente. Outros valores resultarão em erro do servidor, pois não são suportados.
|
Corpo do Pedido
Name |
Necessário |
Tipo |
Description |
location
|
True
|
string
|
Localização do recurso
|
extendedLocation
|
|
ExtendedLocation
|
O local estendido do Conjunto de Dimensionamento de Máquina Virtual.
|
identity
|
|
VirtualMachineScaleSetIdentity
|
A identidade do conjunto de dimensionamento da máquina virtual, se configurado.
|
plan
|
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Este elemento é usado apenas para imagens do mercado. Antes de poder usar uma imagem de mercado de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que pretende utilizar e, em seguida, clique em Pretende implementar programaticamente, Introdução ->. Introduza todas as informações necessárias e, em seguida, clique em Guardar.
|
properties.additionalCapabilities
|
|
AdditionalCapabilities
|
Especifica recursos adicionais habilitados ou desabilitados nas Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais. Por exemplo: se as Máquinas Virtuais têm a capacidade de suportar a anexação de discos de dados gerenciados com UltraSSD_LRS tipo de conta de armazenamento.
|
properties.automaticRepairsPolicy
|
|
AutomaticRepairsPolicy
|
Política para reparações automáticas.
|
properties.constrainedMaximumCapacity
|
|
boolean
|
Propriedade opcional que deve ser definida como True ou omitida.
|
properties.doNotRunExtensionsOnOverprovisionedVMs
|
|
boolean
|
Quando o Overprovision está habilitado, as extensões são iniciadas somente no número solicitado de VMs que são finalmente mantidas. Portanto, essa propriedade garantirá que as extensões não sejam executadas nas VMs extras superprovisionadas.
|
properties.hostGroup
|
|
SubResource
|
Especifica informações sobre o grupo de hosts dedicados no qual o conjunto de dimensionamento de máquina virtual reside. Versão api mínima: 2020-06-01.
|
properties.orchestrationMode
|
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de escala da máquina virtual.
|
properties.overprovision
|
|
boolean
|
Especifica se o Conjunto de Dimensionamento de Máquina Virtual deve ser provisionado em excesso.
|
properties.platformFaultDomainCount
|
|
integer
|
Contagem de domínio de falha para cada grupo de posicionamento.
|
properties.priorityMixPolicy
|
|
PriorityMixPolicy
|
Especifica os destinos desejados para misturar VMs de prioridade Spot e Regular na mesma instância do VMSS Flex.
|
properties.proximityPlacementGroup
|
|
SubResource
|
Especifica informações sobre o grupo de posicionamento de proximidade ao qual o conjunto de dimensionamento de máquina virtual deve ser atribuído. Versão api mínima: 2018-04-01.
|
properties.resiliencyPolicy
|
|
ResiliencyPolicy
|
Política de Resiliência
|
properties.scaleInPolicy
|
|
ScaleInPolicy
|
Especifica as políticas aplicadas ao dimensionar em Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais.
|
properties.scheduledEventsPolicy
|
|
ScheduledEventsPolicy
|
O ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
|
boolean
|
Quando verdadeiro, isso limita a escala definida a um único grupo de posicionamento, de tamanho máximo de 100 máquinas virtuais. Observação : se singlePlacementGroup for true, ele pode ser modificado para false. No entanto, se singlePlacementGroup for false, ele não pode ser modificado para true.
|
properties.skuProfile
|
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de escala de máquina virtual.
|
properties.spotRestorePolicy
|
|
SpotRestorePolicy
|
Especifica as propriedades de Restauração Local para o conjunto de escala da máquina virtual.
|
properties.upgradePolicy
|
|
UpgradePolicy
|
A política de atualização.
|
properties.virtualMachineProfile
|
|
VirtualMachineScaleSetVMProfile
|
O perfil da máquina virtual.
|
properties.zonalPlatformFaultDomainAlignMode
|
|
ZonalPlatformFaultDomainAlignMode
|
Especifica o modo de alinhamento entre a computação do Conjunto de Escala da Máquina Virtual e a contagem de Domínio de Falha de armazenamento.
|
properties.zoneBalance
|
|
boolean
|
Se deve forçar estritamente mesmo a distribuição da Máquina Virtual entre zonas x no caso de haver interrupção de zona. A propriedade zoneBalance só pode ser definida se a propriedade zones do conjunto de escala contiver mais de uma zona. Se não houver zonas ou apenas uma zona especificada, a propriedade zoneBalance não deverá ser definida.
|
sku
|
|
Sku
|
O sku do conjunto de escala da máquina virtual.
|
tags
|
|
object
|
Tags de recursos
|
zones
|
|
string[]
|
As zonas do conjunto de dimensionamento da máquina virtual.
|
Respostas
Segurança
azure_auth
Azure Ative Directory OAuth2 Flow
Tipo:
oauth2
Fluxo:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Âmbitos
Name |
Description |
user_impersonation
|
personificar a sua conta de utilizador
|
Exemplos
Create a custom-image scale set from an unmanaged generalized os image.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"caching": "ReadWrite",
"image": {
"uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"
},
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualHardDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
*/
/**
* Sample code: Create a custom-image scale set from an unmanaged generalized os image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createACustomImageScaleSetFromAnUnmanagedGeneralizedOsImage(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withImage(new VirtualHardDisk().withUri(
"http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_custom_image_from_an_unmanaged_generalized_os_image.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"
},
"name": "osDisk",
}
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createACustomImageScaleSetFromAnUnmanagedGeneralizedOsImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
Image: &armcompute.VirtualHardDisk{
URI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d6e9ab29-f8c9-4792-978c-ae2c07b98f17"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// Image: &armcompute.VirtualHardDisk{
// URI: to.Ptr("https://{existing-storage-account-name}.blob.core.windows.net/system/Microsoft.Compute/Images/vhds/{existing-generalized-os-image-blob-name}.vhd"),
// },
// OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
*/
async function createACustomImageScaleSetFromAnUnmanagedGeneralizedOSImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
image: {
uri: "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
ImageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"),
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d6e9ab29-f8c9-4792-978c-ae2c07b98f17",
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"osType": "Windows",
"caching": "ReadWrite",
"image": {
"uri": "https://{existing-storage-account-name}.blob.core.windows.net/system/Microsoft.Compute/Images/vhds/{existing-generalized-os-image-blob-name}.vhd"
},
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d6e9ab29-f8c9-4792-978c-ae2c07b98f17",
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"osType": "Windows",
"caching": "ReadWrite",
"image": {
"uri": "https://{existing-storage-account-name}.blob.core.windows.net/system/Microsoft.Compute/Images/vhds/{existing-generalized-os-image-blob-name}.vhd"
},
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk",
"vhdContainers": [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer"
]
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
*/
/**
* Sample code: Create a platform-image scale set with unmanaged os disks.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAPlatformImageScaleSetWithUnmanagedOsDisks(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withVhdContainers(Arrays.asList(
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer"))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_platform_image_with_unmanaged_os_disks.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk",
"vhdContainers": [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer",
],
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAPlatformImageScaleSetWithUnmanagedOsDisks() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
VhdContainers: []*string{
to.Ptr("http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer")},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("77b7df9a-32fe-45e3-8911-60ac9c9b9c64"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// VhdContainers: []*string{
// to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net/vhds")},
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
*/
async function createAPlatformImageScaleSetWithUnmanagedOSDisks() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
vhdContainers: [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer",
],
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
VhdContainers = { "http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer" },
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "77b7df9a-32fe-45e3-8911-60ac9c9b9c64",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"vhdContainers": [
"http://{existing-storage-account-name}.blob.core.windows.net/vhds"
],
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "77b7df9a-32fe-45e3-8911-60ac9c9b9c64",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"vhdContainers": [
"http://{existing-storage-account-name}.blob.core.windows.net/vhds"
],
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set from a custom image.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
*/
/**
* Sample code: Create a scale set from a custom image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetFromACustomImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_acustom_image.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromACustomImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
*/
async function createAScaleSetFromACustomImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set from a generalized shared image.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
*/
/**
* Sample code: Create a scale set from a generalized shared image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetFromAGeneralizedSharedImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_ageneralized_shared_image.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromAGeneralizedSharedImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
*/
async function createAScaleSetFromAGeneralizedSharedImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set from a specialized shared image.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
*/
/**
* Sample code: Create a scale set from a specialized shared image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetFromASpecializedSharedImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withStorageProfile(
new VirtualMachineScaleSetStorageProfile().withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_aspecialized_shared_image.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromASpecializedSharedImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
*/
async function createAScaleSetFromASpecializedSharedImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set where nic config has DisableTcpStateTracking property
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
*/
/**
* Sample code: Create a scale set where nic config has DisableTcpStateTracking property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig1-name}")
.withPrimary(true).withEnableAcceleratedNetworking(true).withDisableTcpStateTracking(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true),
new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig2-name}")
.withPrimary(false).withEnableAcceleratedNetworking(false)
.withDisableTcpStateTracking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{nicConfig2-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"))
.withPrimary(true).withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_disable_tcp_state_tracking_network_interface.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"disableTcpStateTracking": True,
"enableAcceleratedNetworking": True,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{nicConfig2-name}",
"properties": {
"disableTcpStateTracking": False,
"enableAcceleratedNetworking": False,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{nicConfig1-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(true),
EnableAcceleratedNetworking: to.Ptr(true),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(false),
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(true),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(true),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(false),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(false),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
*/
async function createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{nicConfig1-name}",
disableTcpStateTracking: true,
enableAcceleratedNetworking: true,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{nicConfig2-name}",
disableTcpStateTracking: false,
enableAcceleratedNetworking: false,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{nicConfig2-name}",
primary: true,
privateIPAddressVersion: "IPv4",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}")
{
Primary = true,
EnableAcceleratedNetworking = true,
IsTcpStateTrackingDisabled = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
IsTcpStateTrackingDisabled = false,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
Primary = true,
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"ipConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": true
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"ipConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": true
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with a marketplace image plan.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
*/
/**
* Sample code: Create a scale set with a marketplace image plan.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithAMarketplaceImagePlan(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_amarketplace_image_plan.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAMarketplaceImagePlan() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
*/
async function createAScaleSetWithAMarketplaceImagePlan() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with an azure application gateway.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
*/
/**
* Sample code: Create a scale set with an azure application gateway.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithAnAzureApplicationGateway(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile()
.withNetworkInterfaceConfigurations(Arrays.asList(
new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}").withPrimary(
true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}").withSubnet(
new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withApplicationGatewayBackendAddressPools(
Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}")))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_azure_application_gateway.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAnAzureApplicationGateway() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("a0134477-b9d9-484b-b0e3-205c1c089ffa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/nsgExistingAppGw/backendAddressPools/appGatewayBackendPool"),
// }},
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
*/
async function createAScaleSetWithAnAzureApplicationGateway() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
applicationGatewayBackendAddressPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}",
},
],
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
ApplicationGatewayBackendAddressPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "a0134477-b9d9-484b-b0e3-205c1c089ffa",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/nsgExistingAppGw/backendAddressPools/appGatewayBackendPool"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "a0134477-b9d9-484b-b0e3-205c1c089ffa",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/nsgExistingAppGw/backendAddressPools/appGatewayBackendPool"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with an azure load balancer.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"publicIPAddressVersion": "IPv4"
}
},
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"
}
],
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
]
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
*/
/**
* Sample code: Create a scale set with an azure load balancer.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithAnAzureLoadBalancer(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile()
.withNetworkInterfaceConfigurations(Arrays.asList(
new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}").withPrimary(
true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}").withSubnet(
new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration()
.withName("{vmss-name}").withPublicIpAddressVersion(IpVersion.IPV4))
.withLoadBalancerBackendAddressPools(Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}")))
.withLoadBalancerInboundNatPools(Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}")))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_azure_load_balancer.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"
}
],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {"publicIPAddressVersion": "IPv4"},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAnAzureLoadBalancer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
LoadBalancerBackendAddressPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
LoadBalancerInboundNatPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"),
}},
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
PublicIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ec0b21ca-51ec-414b-9323-f236ffc21479"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// LoadBalancerBackendAddressPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/backendAddressPools/lbBackendPool"),
// }},
// LoadBalancerInboundNatPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/inboundNatPools/lbNatPool"),
// }},
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
*/
async function createAScaleSetWithAnAzureLoadBalancer() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
loadBalancerBackendAddressPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}",
},
],
loadBalancerInboundNatPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}",
},
],
publicIPAddressConfiguration: {
name: "{vmss-name}",
publicIPAddressVersion: "IPv4",
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("{vmss-name}")
{
PublicIPAddressVersion = IPVersion.IPv4,
},
LoadBalancerBackendAddressPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
LoadBalancerInboundNatPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"),
}},
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ec0b21ca-51ec-414b-9323-f236ffc21479",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/inboundNatPools/lbNatPool"
}
],
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/backendAddressPools/lbBackendPool"
}
],
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ec0b21ca-51ec-414b-9323-f236ffc21479",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/inboundNatPools/lbNatPool"
}
],
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/backendAddressPools/lbBackendPool"
}
],
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Application Profile
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"applicationProfile": {
"galleryApplications": [
{
"tags": "myTag1",
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
"treatFailureAsDeploymentFailure": true,
"enableAutomaticUpgrade": false
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.ApplicationProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMGalleryApplication;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
*/
/**
* Sample code: Create a scale set with Application Profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithApplicationProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withApplicationProfile(new ApplicationProfile().withGalleryApplications(Arrays.asList(
new VMGalleryApplication().withTags("myTag1").withOrder(1).withPackageReferenceId(
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0")
.withConfigurationReference(
"https://mystorageaccount.blob.core.windows.net/configurations/settings.config")
.withTreatFailureAsDeploymentFailure(true).withEnableAutomaticUpgrade(false),
new VMGalleryApplication().withPackageReferenceId(
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_application_profile.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"applicationProfile": {
"galleryApplications": [
{
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
"enableAutomaticUpgrade": False,
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"tags": "myTag1",
"treatFailureAsDeploymentFailure": True,
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
},
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithApplicationProfile() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
ApplicationProfile: &armcompute.ApplicationProfile{
GalleryApplications: []*armcompute.VMGalleryApplication{
{
ConfigurationReference: to.Ptr("https://mystorageaccount.blob.core.windows.net/configurations/settings.config"),
EnableAutomaticUpgrade: to.Ptr(false),
Order: to.Ptr[int32](1),
PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0"),
Tags: to.Ptr("myTag1"),
TreatFailureAsDeploymentFailure: to.Ptr(true),
},
{
PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"),
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ffb27c5c-39a5-4d4e-b307-b32598689813"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// ApplicationProfile: &armcompute.ApplicationProfile{
// GalleryApplications: []*armcompute.VMGalleryApplication{
// {
// ConfigurationReference: to.Ptr("https://mystorageaccount.blob.core.windows.net/configurations/settings.config"),
// Order: to.Ptr[int32](1),
// PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0"),
// Tags: to.Ptr("myTag1"),
// },
// {
// PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"),
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
*/
async function createAScaleSetWithApplicationProfile() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
applicationProfile: {
galleryApplications: [
{
configurationReference:
"https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
enableAutomaticUpgrade: false,
order: 1,
packageReferenceId:
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
tags: "myTag1",
treatFailureAsDeploymentFailure: true,
},
{
packageReferenceId:
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
GalleryApplications = {new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0")
{
Tags = "myTag1",
Order = 1,
ConfigurationReference = "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
TreatFailureAsDeploymentFailure = true,
EnableAutomaticUpgrade = false,
}, new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ffb27c5c-39a5-4d4e-b307-b32598689813",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"applicationProfile": {
"galleryApplications": [
{
"tags": "myTag1",
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config"
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ffb27c5c-39a5-4d4e-b307-b32598689813",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"applicationProfile": {
"galleryApplications": [
{
"tags": "myTag1",
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config"
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with automatic repairs enabled
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"automaticRepairsPolicy": {
"enabled": true,
"gracePeriod": "PT10M"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticRepairsPolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
*/
/**
* Sample code: Create a scale set with automatic repairs enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithAutomaticRepairsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withAutomaticRepairsPolicy(new AutomaticRepairsPolicy().withEnabled(true).withGracePeriod("PT10M"))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_automatic_repairs.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"automaticRepairsPolicy": {"enabled": True, "gracePeriod": "PT10M"},
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAutomaticRepairsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
AutomaticRepairsPolicy: &armcompute.AutomaticRepairsPolicy{
Enabled: to.Ptr(true),
GracePeriod: to.Ptr("PT10M"),
},
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// AutomaticRepairsPolicy: &armcompute.AutomaticRepairsPolicy{
// Enabled: to.Ptr(true),
// GracePeriod: to.Ptr("PT10M"),
// },
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
*/
async function createAScaleSetWithAutomaticRepairsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
automaticRepairsPolicy: { enabled: true, gracePeriod: "PT10M" },
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
AutomaticRepairsPolicy = new AutomaticRepairsPolicy
{
Enabled = true,
GracePeriod = "PT10M",
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"automaticRepairsPolicy": {
"enabled": true,
"gracePeriod": "PT10M"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"automaticRepairsPolicy": {
"enabled": true,
"gracePeriod": "PT10M"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with boot diagnostics.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
*/
/**
* Sample code: Create a scale set with boot diagnostics.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithBootDiagnostics(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net"))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_boot_diagnostics.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithBootDiagnostics() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
*/
async function createAScaleSetWithBootDiagnostics() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Disk Controller Type
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
},
"diskControllerType": "NVMe"
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VMSizeProperties;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetHardwareProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
*/
/**
* Sample code: Create a scale set with Disk Controller Type.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithDiskControllerType(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDiskControllerType("NVMe"))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ==")
.withHardwareProfile(new VirtualMachineScaleSetHardwareProfile()
.withVmSizeProperties(new VMSizeProperties().withVCpusAvailable(1).withVCpusPerCore(1))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_disk_controller_type.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"hardwareProfile": {"vmSizeProperties": {"vCPUsAvailable": 1, "vCPUsPerCore": 1}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"diskControllerType": "NVMe",
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithDiskControllerType() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
VMSizeProperties: &armcompute.VMSizeProperties{
VCPUsAvailable: to.Ptr[int32](1),
VCPUsPerCore: to.Ptr[int32](1),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DiskControllerType: to.Ptr("NVMe"),
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
// VMSizeProperties: &armcompute.VMSizeProperties{
// VCPUsAvailable: to.Ptr[int32](1),
// VCPUsPerCore: to.Ptr[int32](1),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DiskControllerType: to.Ptr("NVMe"),
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
*/
async function createAScaleSetWithDiskControllerType() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
hardwareProfile: {
vmSizeProperties: { vCPUsAvailable: 1, vCPUsPerCore: 1 },
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
diskControllerType: "NVMe",
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DiskControllerType = "NVMe",
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
HardwareVmSizeProperties = new VirtualMachineSizeProperties
{
VCpusAvailable = 1,
VCpusPerCore = 1,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
},
"diskControllerType": "NVMe"
},
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
},
"diskControllerType": "SCSI"
},
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with DiskEncryptionSet resource in os disk and data disk.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"createOption": "FromImage"
},
"dataDisks": [
{
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.DiskEncryptionSetParameters;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
*/
/**
* Sample code: Create a scale set with DiskEncryptionSet resource in os disk and data disk.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithDiskEncryptionSetResourceInOsDiskAndDataDisk(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)
.withDiskEncryptionSet(new DiskEncryptionSetParameters().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"))))
.withDataDisks(Arrays.asList(new VirtualMachineScaleSetDataDisk().withLun(0)
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)
.withDiskEncryptionSet(new DiskEncryptionSetParameters().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"))))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_disk_encryption_set_resource.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{
"caching": "ReadWrite",
"createOption": "Empty",
"diskSizeGB": 1023,
"lun": 0,
"managedDisk": {
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
},
"storageAccountType": "Standard_LRS",
},
}
],
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
},
"storageAccountType": "Standard_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithDiskEncryptionSetResourceInOsDiskAndDataDisk() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
}},
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
*/
async function createAScaleSetWithDiskEncryptionSetResourceInOSDiskAndDataDisk() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{
caching: "ReadWrite",
createOption: "Empty",
diskSizeGB: 1023,
lun: 0,
managedDisk: {
diskEncryptionSet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
storageAccountType: "Standard_LRS",
},
},
],
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: {
diskEncryptionSet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
storageAccountType: "Standard_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 1023,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"createOption": "FromImage"
},
"dataDisks": [
{
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"createOption": "FromImage"
},
"dataDisks": [
{
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with empty data disks on each vm.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
},
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 1
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
*/
/**
* Sample code: Create a scale set with empty data disks on each vm.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEmptyDataDisksOnEachVm(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D2_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE).withDiskSizeGB(512)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDataDisks(Arrays.asList(
new VirtualMachineScaleSetDataDisk().withLun(0)
.withCreateOption(DiskCreateOptionTypes.EMPTY).withDiskSizeGB(1023),
new VirtualMachineScaleSetDataDisk().withLun(1)
.withCreateOption(DiskCreateOptionTypes.EMPTY).withDiskSizeGB(1023))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_empty_data_disks_on_each_vm.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 0},
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 1},
],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diskSizeGB": 512,
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEmptyDataDisksOnEachVm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
},
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](1),
}},
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiskSizeGB: to.Ptr[int32](512),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("8042c376-4690-4c47-9fa2-fbdad70e32fa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](1),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiskSizeGB: to.Ptr[int32](512),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
*/
async function createAScaleSetWithEmptyDataDisksOnEachVM() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{ createOption: "Empty", diskSizeGB: 1023, lun: 0 },
{ createOption: "Empty", diskSizeGB: 1023, lun: 1 },
],
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
diskSizeGB: 512,
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 512,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "8042c376-4690-4c47-9fa2-fbdad70e32fa",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 0,
"diskSizeGB": 1023
},
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 1,
"diskSizeGB": 1023
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Succeeded"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "8042c376-4690-4c47-9fa2-fbdad70e32fa",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 0,
"diskSizeGB": 1023
},
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 1,
"diskSizeGB": 1023
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with ephemeral os disk provisioning in Nvme disk using placement property.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "NvmeDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskPlacement;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
*/
/**
* Sample code: Create a scale set with ephemeral os disk provisioning in Nvme disk using placement property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDiskProvisioningInNvmeDiskUsingPlacementProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL)
.withPlacement(DiffDiskPlacement.NVME_DISK))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_a_with_diff_os_disk_using_diff_disk_placement_as_nvme_disk.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local", "placement": "NvmeDisk"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDiskProvisioningInNvmeDiskUsingPlacementProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
Placement: to.Ptr(armcompute.DiffDiskPlacementNvmeDisk),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// Placement: to.Ptr(armcompute.DiffDiskPlacementNvmeDisk),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
*/
async function createAScaleSetWithEphemeralOSDiskProvisioningInNvmeDiskUsingPlacementProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local", placement: "NvmeDisk" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
Placement = DiffDiskPlacement.NvmeDisk,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "NvmeDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "NvmeDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with ephemeral os disks using placement property.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "ResourceDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskPlacement;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
*/
/**
* Sample code: Create a scale set with ephemeral os disks using placement property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDisksUsingPlacementProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL)
.withPlacement(DiffDiskPlacement.RESOURCE_DISK))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_a_with_diff_os_disk_using_diff_disk_placement.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local", "placement": "ResourceDisk"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDisksUsingPlacementProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
Placement: to.Ptr(armcompute.DiffDiskPlacementResourceDisk),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// Placement: to.Ptr(armcompute.DiffDiskPlacementResourceDisk),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
*/
async function createAScaleSetWithEphemeralOSDisksUsingPlacementProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local", placement: "ResourceDisk" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
Placement = DiffDiskPlacement.ResourceDisk,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "ResourceDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "ResourceDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with ephemeral os disks.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
*/
/**
* Sample code: Create a scale set with ephemeral os disks.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDisks(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_diff_os_disk.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDisks() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
*/
async function createAScaleSetWithEphemeralOSDisks() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with extension time budget.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {}
}
}
],
"extensionsTimeBudget": "PT1H20M"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
*/
/**
* Sample code: Create a scale set with extension time budget.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithExtensionTimeBudget(com.azure.resourcemanager.AzureResourceManager azure)
throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile()
.withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter()
.deserialize("{}", Object.class, SerializerEncoding.JSON))))
.withExtensionsTimeBudget("PT1H20M")))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_extensions_time_budget.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"publisher": "{extension-Publisher}",
"settings": {},
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
],
"extensionsTimeBudget": "PT1H20M",
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithExtensionTimeBudget() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
ExtensionsTimeBudget: to.Ptr("PT1H20M"),
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// ExtensionsTimeBudget: to.Ptr("PT1H20M"),
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
*/
async function createAScaleSetWithExtensionTimeBudget() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensionsTimeBudget: "PT1H20M",
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
publisher: "{extension-Publisher}",
settings: {},
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
}},
ExtensionsTimeBudget = "PT1H20M",
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {}
}
}
],
"extensionsTimeBudget": "PT1H20M"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {}
}
}
],
"extensionsTimeBudget": "PT1H20M"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Fpga Network Interfaces.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"enableFpga": true,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
"privateIPAddressVersion": "IPv4"
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
*/
/**
* Sample code: Create a scale set with Fpga Network Interfaces.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithFpgaNetworkInterfaces(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true),
new VirtualMachineScaleSetNetworkConfiguration().withName("{fpgaNic-Name}")
.withPrimary(false).withEnableAcceleratedNetworking(false).withEnableFpga(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{fpgaNic-Name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"))
.withPrimary(true).withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_fpga_network_interface.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{fpgaNic-Name}",
"properties": {
"enableAcceleratedNetworking": False,
"enableFpga": True,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithFpgaNetworkInterfaces() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{fpgaNic-Name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableAcceleratedNetworking: to.Ptr(false),
EnableFpga: to.Ptr(true),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{fpgaNic-Name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{fpgaNic-Name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{fpgaNic-Name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
*/
async function createAScaleSetWithFpgaNetworkInterfaces() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{fpgaNic-Name}",
enableAcceleratedNetworking: false,
enableFpga: true,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{fpgaNic-Name}",
primary: true,
privateIPAddressVersion: "IPv4",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}, new VirtualMachineScaleSetNetworkConfiguration("{fpgaNic-Name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
EnableFpga = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{fpgaNic-Name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
Primary = true,
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
},
{
"name": "{fpgaNic-Name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": true,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
},
{
"name": "{fpgaNic-Name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": true,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Host Encryption using encryptionAtHost property.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"encryptionAtHost": true
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
*/
/**
* Sample code: Create a scale set with Host Encryption using encryptionAtHost property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile().withEncryptionAtHost(true)))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_encryption_at_host.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {"encryptionAtHost": True},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
EncryptionAtHost: to.Ptr(true),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// EncryptionAtHost: to.Ptr(true),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
*/
async function createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: { encryptionAtHost: true },
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
EncryptionAtHost = true,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"encryptionAtHost": true
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"plan": {
"publisher": "microsoft-ads",
"product": "standard-data-science-vm",
"name": "standard-data-science-vm"
},
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "standard-data-science-vm",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "standard-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"encryptionAtHost": true
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with managed boot diagnostics.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
*/
/**
* Sample code: Create a scale set with managed boot diagnostics.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithManagedBootDiagnostics(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_managed_boot_diagnostics.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {"bootDiagnostics": {"enabled": True}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithManagedBootDiagnostics() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
*/
async function createAScaleSetWithManagedBootDiagnostics() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: { bootDiagnostics: { enabled: true } },
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Network Interfaces with public ip address dns settings.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"enableAcceleratedNetworking": true,
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1",
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": {
"name": "publicip",
"properties": {
"idleTimeoutInMinutes": 10,
"dnsSettings": {
"domainNameLabel": "vmsstestlabel01",
"domainNameLabelScope": "NoReuse"
}
}
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.DomainNameLabelScopeTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.NetworkInterfaceAuxiliaryMode;
import com.azure.resourcemanager.compute.models.NetworkInterfaceAuxiliarySku;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfigurationDnsSettings;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
*/
/**
* Sample code: Create a scale set with Network Interfaces with public ip address dns settings.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithNetworkInterfacesWithPublicIpAddressDnsSettings(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig1-name}")
.withPrimary(true).withEnableAcceleratedNetworking(true).withDisableTcpStateTracking(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)
.withAuxiliaryMode(NetworkInterfaceAuxiliaryMode.ACCELERATED_CONNECTIONS)
.withAuxiliarySku(NetworkInterfaceAuxiliarySku.A1),
new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig2-name}")
.withPrimary(false).withEnableAcceleratedNetworking(false)
.withDisableTcpStateTracking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{nicConfig2-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"))
.withPrimary(true)
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration().withName("publicip")
.withIdleTimeoutInMinutes(10).withDnsSettings(
new VirtualMachineScaleSetPublicIpAddressConfigurationDnsSettings()
.withDomainNameLabel("vmsstestlabel01")
.withDomainNameLabelScope(DomainNameLabelScopeTypes.NO_REUSE)))
.withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_network_interface_with_dns_settings.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1",
"disableTcpStateTracking": True,
"enableAcceleratedNetworking": True,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{nicConfig2-name}",
"properties": {
"disableTcpStateTracking": False,
"enableAcceleratedNetworking": False,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": {
"name": "publicip",
"properties": {
"dnsSettings": {
"domainNameLabel": "vmsstestlabel01",
"domainNameLabelScope": "NoReuse",
},
"idleTimeoutInMinutes": 10,
},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithNetworkInterfacesWithPublicIpAddressDnsSettings() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{nicConfig1-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
AuxiliaryMode: to.Ptr(armcompute.NetworkInterfaceAuxiliaryModeAcceleratedConnections),
AuxiliarySKU: to.Ptr(armcompute.NetworkInterfaceAuxiliarySKUA1),
DisableTCPStateTracking: to.Ptr(true),
EnableAcceleratedNetworking: to.Ptr(true),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(false),
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("publicip"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
DNSSettings: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationDNSSettings{
DomainNameLabel: to.Ptr("vmsstestlabel01"),
DomainNameLabelScope: to.Ptr(armcompute.DomainNameLabelScopeTypesNoReuse),
},
IdleTimeoutInMinutes: to.Ptr[int32](10),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// AuxiliaryMode: to.Ptr(armcompute.NetworkInterfaceAuxiliaryModeAcceleratedConnections),
// AuxiliarySKU: to.Ptr(armcompute.NetworkInterfaceAuxiliarySKUA1),
// DisableTCPStateTracking: to.Ptr(true),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(true),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
// Name: to.Ptr("publicip"),
// Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationDNSSettings{
// DomainNameLabel: to.Ptr("vmsstestlabel01"),
// DomainNameLabelScope: to.Ptr(armcompute.DomainNameLabelScopeTypesTenantReuse),
// },
// IdleTimeoutInMinutes: to.Ptr[int32](10),
// },
// },
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(false),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(false),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
*/
async function createAScaleSetWithNetworkInterfacesWithPublicIPAddressDnsSettings() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{nicConfig1-name}",
auxiliaryMode: "AcceleratedConnections",
auxiliarySku: "A1",
disableTcpStateTracking: true,
enableAcceleratedNetworking: true,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{nicConfig2-name}",
disableTcpStateTracking: false,
enableAcceleratedNetworking: false,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{nicConfig2-name}",
primary: true,
privateIPAddressVersion: "IPv4",
publicIPAddressConfiguration: {
name: "publicip",
dnsSettings: {
domainNameLabel: "vmsstestlabel01",
domainNameLabelScope: "NoReuse",
},
idleTimeoutInMinutes: 10,
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}")
{
Primary = true,
EnableAcceleratedNetworking = true,
IsTcpStateTrackingDisabled = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
AuxiliaryMode = ComputeNetworkInterfaceAuxiliaryMode.AcceleratedConnections,
AuxiliarySku = ComputeNetworkInterfaceAuxiliarySku.A1,
}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
IsTcpStateTrackingDisabled = false,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
Primary = true,
PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("publicip")
{
IdleTimeoutInMinutes = 10,
DnsSettings = new VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings("vmsstestlabel01")
{
DomainNameLabelScope = DomainNameLabelScopeType.NoReuse,
},
},
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"ipConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": {
"name": "publicip",
"properties": {
"idleTimeoutInMinutes": 10,
"dnsSettings": {
"domainNameLabel": "vmsstestlabel01",
"domainNameLabelScope": "TenantReuse"
}
}
}
}
}
],
"enableAcceleratedNetworking": true,
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1"
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "afa2afa8-9e49-48fb-9d18-c86323b5d064",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"disablePasswordAuthentication": false
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"ipConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": true,
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1"
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": false,
"enableFpga": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with OS image scheduled events enabled.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT15M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.OSImageNotificationProfile;
import com.azure.resourcemanager.compute.models.ScheduledEventsProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
*/
/**
* Sample code: Create a scale set with OS image scheduled events enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithOSImageScheduledEventsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withScheduledEventsProfile(new ScheduledEventsProfile().withOsImageNotificationProfile(
new OSImageNotificationProfile().withNotBeforeTimeout("PT15M").withEnable(true))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_os_image_scheduled_event_enabled.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {"enable": True, "notBeforeTimeout": "PT15M"}
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithOsImageScheduledEventsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
OSImageNotificationProfile: &armcompute.OSImageNotificationProfile{
Enable: to.Ptr(true),
NotBeforeTimeout: to.Ptr("PT15M"),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
// OSImageNotificationProfile: &armcompute.OSImageNotificationProfile{
// Enable: to.Ptr(true),
// NotBeforeTimeout: to.Ptr("PT15M"),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
*/
async function createAScaleSetWithOSImageScheduledEventsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
scheduledEventsProfile: {
osImageNotificationProfile: { enable: true, notBeforeTimeout: "PT15M" },
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ScheduledEventsProfile = new ComputeScheduledEventsProfile
{
OSImageNotificationProfile = new OSImageNotificationProfile
{
NotBeforeTimeout = "PT15M",
Enable = true,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT15M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT15M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with password authentication.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
*/
/**
* Sample code: Create a scale set with password authentication.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPasswordAuthentication(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_password_authentication.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPasswordAuthentication() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ffb27c5c-39a5-4d4e-b307-b32598689813"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
*/
async function createAScaleSetWithPasswordAuthentication() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ffb27c5c-39a5-4d4e-b307-b32598689813",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "ffb27c5c-39a5-4d4e-b307-b32598689813",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with premium storage.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
*/
/**
* Sample code: Create a scale set with premium storage.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPremiumStorage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.PREMIUM_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_premium_storage.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Premium_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPremiumStorage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesPremiumLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("19fd38a2-f50a-42c6-9dc7-3f9cf3791225"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesPremiumLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
*/
async function createAScaleSetWithPremiumStorage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Premium_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.PremiumLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "19fd38a2-f50a-42c6-9dc7-3f9cf3791225",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "19fd38a2-f50a-42c6-9dc7-3f9cf3791225",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with priority mix policy
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {
"baseRegularPriorityCount": 10,
"regularPriorityPercentageAboveBase": 50
},
"virtualMachineProfile": {
"priority": "Spot",
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts-gen2",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"enableAcceleratedNetworking": false,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"primary": true,
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"idleTimeoutInMinutes": 15
}
}
}
}
]
}
}
],
"networkApiVersion": "2020-11-01"
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.NetworkApiVersion;
import com.azure.resourcemanager.compute.models.OrchestrationMode;
import com.azure.resourcemanager.compute.models.PriorityMixPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
*/
/**
* Sample code: Create a scale set with priority mix policy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPriorityMixPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_A8m_v2").withTier("Standard").withCapacity(2L))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("0001-com-ubuntu-server-focal").withSku("20_04-lts-gen2").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true).withEnableAcceleratedNetworking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withPrimary(true)
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration().withName("{vmss-name}")
.withIdleTimeoutInMinutes(15))
.withApplicationGatewayBackendAddressPools(Arrays.asList())
.withLoadBalancerBackendAddressPools(Arrays.asList())))
.withEnableIpForwarding(true)))
.withNetworkApiVersion(NetworkApiVersion.TWO_ZERO_TWO_ZERO_ONE_ONE_ZERO_ONE))
.withPriority(VirtualMachinePriorityTypes.SPOT))
.withPlatformFaultDomainCount(1).withOrchestrationMode(OrchestrationMode.FLEXIBLE)
.withPriorityMixPolicy(new PriorityMixPolicy().withBaseRegularPriorityCount(10)
.withRegularPriorityPercentageAboveBase(50)),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_priority_mix_policy.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {"baseRegularPriorityCount": 10, "regularPriorityPercentageAboveBase": 50},
"virtualMachineProfile": {
"networkProfile": {
"networkApiVersion": "2020-11-01",
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableAcceleratedNetworking": False,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"primary": True,
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {"idleTimeoutInMinutes": 15},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
],
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "0001-com-ubuntu-server-focal",
"publisher": "Canonical",
"sku": "20_04-lts-gen2",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A8m_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPriorityMixPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
PlatformFaultDomainCount: to.Ptr[int32](1),
PriorityMixPolicy: &armcompute.PriorityMixPolicy{
BaseRegularPriorityCount: to.Ptr[int32](10),
RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkAPIVersion: to.Ptr(armcompute.NetworkAPIVersionTwoThousandTwenty1101),
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{},
LoadBalancerBackendAddressPools: []*armcompute.SubResource{},
Primary: to.Ptr(true),
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
IdleTimeoutInMinutes: to.Ptr[int32](15),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("0001-com-ubuntu-server-focal"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("20_04-lts-gen2"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A8m_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
// PlatformFaultDomainCount: to.Ptr[int32](1),
// PriorityMixPolicy: &armcompute.PriorityMixPolicy{
// BaseRegularPriorityCount: to.Ptr[int32](10),
// RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkAPIVersion: to.Ptr(armcompute.NetworkAPIVersionTwoThousandTwenty1101),
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
// },
// LoadBalancerBackendAddressPools: []*armcompute.SubResource{
// },
// Primary: to.Ptr(true),
// PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
// IdleTimeoutInMinutes: to.Ptr[int32](15),
// },
// },
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminPassword: to.Ptr("{your-password}"),
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("0001-com-ubuntu-server-focal"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("20_04-lts-gen2"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A8m_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
*/
async function createAScaleSetWithPriorityMixPolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
orchestrationMode: "Flexible",
platformFaultDomainCount: 1,
priorityMixPolicy: {
baseRegularPriorityCount: 10,
regularPriorityPercentageAboveBase: 50,
},
sku: { name: "Standard_A8m_v2", capacity: 2, tier: "Standard" },
virtualMachineProfile: {
networkProfile: {
networkApiVersion: "2020-11-01",
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableAcceleratedNetworking: false,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
applicationGatewayBackendAddressPools: [],
loadBalancerBackendAddressPools: [],
primary: true,
publicIPAddressConfiguration: {
name: "{vmss-name}",
idleTimeoutInMinutes: 15,
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "0001-com-ubuntu-server-focal",
publisher: "Canonical",
sku: "20_04-lts-gen2",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_A8m_v2",
Tier = "Standard",
Capacity = 10L,
},
Properties = new VirtualMachineScaleSetProperties
{
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
SinglePlacementGroup = false,
OrchestrationMode = OrchestrationMode.Flexible,
PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy
{
BaseRegularPriorityCount = 4,
RegularPriorityPercentageAboveBase = 50,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"name": "{vmss-name}",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {
"baseRegularPriorityCount": 10,
"regularPriorityPercentageAboveBase": 50
},
"virtualMachineProfile": {
"priority": "Spot",
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts-gen2",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"enableAcceleratedNetworking": false,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"primary": true,
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"idleTimeoutInMinutes": 15
}
}
}
}
]
}
}
],
"networkApiVersion": "2020-11-01"
}
}
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"name": "{vmss-name}",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {
"baseRegularPriorityCount": 10,
"regularPriorityPercentageAboveBase": 50
},
"virtualMachineProfile": {
"priority": "Spot",
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts-gen2",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"enableAcceleratedNetworking": false,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"primary": true,
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"idleTimeoutInMinutes": 15
}
}
}
}
]
}
}
],
"networkApiVersion": "2020-11-01"
}
}
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with ProxyAgent Settings of enabled and mode.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"proxyAgentSettings": {
"enabled": true,
"mode": "Enforce"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Mode;
import com.azure.resourcemanager.compute.models.ProxyAgentSettings;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
*/
/**
* Sample code: Create a scale set with ProxyAgent Settings of enabled and mode.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithProxyAgentSettingsOfEnabledAndMode(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D2s_v3").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2019-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withProxyAgentSettings(new ProxyAgentSettings().withEnabled(true).withMode(Mode.ENFORCE))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_proxy_agent_settings.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {"proxyAgentSettings": {"enabled": True, "mode": "Enforce"}},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "StandardSSD_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2s_v3", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithProxyAgentSettingsOfEnabledAndMode() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
ProxyAgentSettings: &armcompute.ProxyAgentSettings{
Enabled: to.Ptr(true),
Mode: to.Ptr(armcompute.ModeEnforce),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2019-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2s_v3"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// ProxyAgentSettings: &armcompute.ProxyAgentSettings{
// Enabled: to.Ptr(true),
// Mode: to.Ptr(armcompute.ModeEnforce),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2019-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2s_v3"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
*/
async function createAScaleSetWithProxyAgentSettingsOfEnabledAndMode() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2s_v3", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
proxyAgentSettings: { enabled: true, mode: "Enforce" },
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2019-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "StandardSSD_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2s_v3",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2019-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
ProxyAgentSettings = new ProxyAgentSettings
{
Enabled = true,
Mode = Mode.Enforce,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"proxyAgentSettings": {
"enabled": true,
"mode": "Enforce"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"proxyAgentSettings": {
"enabled": true,
"mode": "Enforce"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with Resilient VM Creation enabled
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMCreationPolicy": {
"enabled": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ResiliencyPolicy;
import com.azure.resourcemanager.compute.models.ResilientVMCreationPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
*/
/**
* Sample code: Create a scale set with Resilient VM Creation enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithResilientVMCreationEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(false)
.withResiliencyPolicy(new ResiliencyPolicy()
.withResilientVMCreationPolicy(new ResilientVMCreationPolicy().withEnabled(true))),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_resilient_vm_creation_policy.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": False,
"resiliencyPolicy": {"resilientVMCreationPolicy": {"enabled": True}},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithResilientVmCreationEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(false),
ResiliencyPolicy: &armcompute.ResiliencyPolicy{
ResilientVMCreationPolicy: &armcompute.ResilientVMCreationPolicy{
Enabled: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(false),
// ProvisioningState: to.Ptr("Succeeded"),
// ResiliencyPolicy: &armcompute.ResiliencyPolicy{
// ResilientVMCreationPolicy: &armcompute.ResilientVMCreationPolicy{
// Enabled: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
*/
async function createAScaleSetWithResilientVMCreationEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: false,
resiliencyPolicy: { resilientVMCreationPolicy: { enabled: true } },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = false,
ResiliencyPolicy = new ResiliencyPolicy
{
ResilientVmCreationPolicyEnabled = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMCreationPolicy": {
"enabled": true
}
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMCreationPolicy": {
"enabled": true
}
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Resilient VM Deletion enabled
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMDeletionPolicy": {
"enabled": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ResiliencyPolicy;
import com.azure.resourcemanager.compute.models.ResilientVMDeletionPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
*/
/**
* Sample code: Create a scale set with Resilient VM Deletion enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithResilientVMDeletionEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(false)
.withResiliencyPolicy(new ResiliencyPolicy()
.withResilientVMDeletionPolicy(new ResilientVMDeletionPolicy().withEnabled(true))),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_resilient_vm_deletion_policy.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": False,
"resiliencyPolicy": {"resilientVMDeletionPolicy": {"enabled": True}},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithResilientVmDeletionEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(false),
ResiliencyPolicy: &armcompute.ResiliencyPolicy{
ResilientVMDeletionPolicy: &armcompute.ResilientVMDeletionPolicy{
Enabled: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(false),
// ProvisioningState: to.Ptr("Succeeded"),
// ResiliencyPolicy: &armcompute.ResiliencyPolicy{
// ResilientVMDeletionPolicy: &armcompute.ResilientVMDeletionPolicy{
// Enabled: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
*/
async function createAScaleSetWithResilientVMDeletionEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: false,
resiliencyPolicy: { resilientVMDeletionPolicy: { enabled: true } },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = false,
ResiliencyPolicy = new ResiliencyPolicy
{
ResilientVmDeletionPolicyEnabled = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMDeletionPolicy": {
"enabled": true
}
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMDeletionPolicy": {
"enabled": true
}
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with scaleInPolicy.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scaleInPolicy": {
"rules": [
"OldestVM"
],
"forceDeletion": true
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScaleInPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetScaleInRules;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
*/
/**
* Sample code: Create a scale set with scaleInPolicy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithScaleInPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true)
.withScaleInPolicy(new ScaleInPolicy()
.withRules(Arrays.asList(VirtualMachineScaleSetScaleInRules.OLDEST_VM)).withForceDeletion(true)),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_scale_in_policy.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scaleInPolicy": {"forceDeletion": True, "rules": ["OldestVM"]},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithScaleInPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScaleInPolicy: &armcompute.ScaleInPolicy{
ForceDeletion: to.Ptr(true),
Rules: []*armcompute.VirtualMachineScaleSetScaleInRules{
to.Ptr(armcompute.VirtualMachineScaleSetScaleInRulesOldestVM)},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScaleInPolicy: &armcompute.ScaleInPolicy{
// ForceDeletion: to.Ptr(true),
// Rules: []*armcompute.VirtualMachineScaleSetScaleInRules{
// to.Ptr(armcompute.VirtualMachineScaleSetScaleInRulesOldestVM)},
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
*/
async function createAScaleSetWithScaleInPolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scaleInPolicy: { forceDeletion: true, rules: ["OldestVM"] },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
ScaleInPolicy = new ScaleInPolicy
{
Rules = { VirtualMachineScaleSetScaleInRule.OldestVm },
ForceDeletion = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scaleInPolicy": {
"rules": [
"OldestVM"
],
"forceDeletion": true
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scaleInPolicy": {
"rules": [
"OldestVM"
],
"forceDeletion": true
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Security Posture Reference
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"location": "eastus2euap",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityPostureReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
*/
/**
* Sample code: Create a scale set with Security Posture Reference.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithSecurityPostureReference(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("eastus2euap")
.withSku(new Sku().withName("Standard_A1").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withEnableAutomaticOSUpgrade(true)))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2022-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityPostureReference(new SecurityPostureReference().withId(
"/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest")))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_posture_reference.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "eastus2euap",
"properties": {
"overprovision": True,
"upgradePolicy": {"automaticOSUpgradePolicy": {"enableAutomaticOSUpgrade": True}, "mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-Datacenter",
"version": "latest",
},
"osDisk": {"caching": "ReadWrite", "createOption": "FromImage", "name": "osDisk"},
},
},
},
"sku": {"capacity": 3, "name": "Standard_A1", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityPostureReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("eastus2euap"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
EnableAutomaticOSUpgrade: to.Ptr(true),
},
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityPostureReference: &armcompute.SecurityPostureReference{
ID: to.Ptr("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2022-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("eastus2euap"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d12ccb3d-ab15-4794-9836-c4196392e9f2"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
// EnableAutomaticOSUpgrade: to.Ptr(true),
// },
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityPostureReference: &armcompute.SecurityPostureReference{
// ID: to.Ptr("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2022-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
*/
async function createAScaleSetWithSecurityPostureReference() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "eastus2euap",
overprovision: true,
sku: { name: "Standard_A1", capacity: 3, tier: "Standard" },
upgradePolicy: {
automaticOSUpgradePolicy: { enableAutomaticOSUpgrade: true },
mode: "Automatic",
},
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityPostureReference: {
id: "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2022-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap"))
{
Sku = new ComputeSku
{
Name = "Standard_A1",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy
{
EnableAutomaticOSUpgrade = true,
},
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2022-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityPostureReference = new ComputeSecurityPostureReference(new ResourceIdentifier("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest")),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d12ccb3d-ab15-4794-9836-c4196392e9f2",
"virtualMachineProfile": {
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
},
"provisioningState": "Creating"
},
"location": "eastus2euap",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d12ccb3d-ab15-4794-9836-c4196392e9f2",
"virtualMachineProfile": {
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
},
"provisioningState": "Creating"
},
"location": "eastus2euap",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with SecurityType as ConfidentialVM
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2as_v5"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows-cvm",
"publisher": "MicrosoftWindowsServer",
"version": "17763.2183.2109130127",
"offer": "2019-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "VMGuestStateOnly"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityEncryptionTypes;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMDiskSecurityProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
*/
/**
* Sample code: Create a scale set with SecurityType as ConfidentialVM.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithSecurityTypeAsConfidentialVM(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DC2as_v5").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("2019-datacenter-cvm").withSku("windows-cvm")
.withVersion("17763.2183.2109130127"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS)
.withSecurityProfile(new VMDiskSecurityProfile()
.withSecurityEncryptionType(SecurityEncryptionTypes.VMGUEST_STATE_ONLY)))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(true).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.CONFIDENTIAL_VM)))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_type_confidential_vm.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "ConfidentialVM",
"uefiSettings": {"secureBootEnabled": True, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "2019-datacenter-cvm",
"publisher": "MicrosoftWindowsServer",
"sku": "windows-cvm",
"version": "17763.2183.2109130127",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {
"securityProfile": {"securityEncryptionType": "VMGuestStateOnly"},
"storageAccountType": "StandardSSD_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DC2as_v5", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityTypeAsConfidentialVm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(true),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("2019-datacenter-cvm"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("windows-cvm"),
Version: to.Ptr("17763.2183.2109130127"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
SecurityProfile: &armcompute.VMDiskSecurityProfile{
SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesVMGuestStateOnly),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DC2as_v5"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(true),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("2019-datacenter-cvm"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("windows-cvm"),
// Version: to.Ptr("17763.2183.2109130127"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// SecurityProfile: &armcompute.VMDiskSecurityProfile{
// SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesVMGuestStateOnly),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DC2as_v5"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
*/
async function createAScaleSetWithSecurityTypeAsConfidentialVM() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DC2as_v5", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "ConfidentialVM",
uefiSettings: { secureBootEnabled: true, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "2019-datacenter-cvm",
publisher: "MicrosoftWindowsServer",
sku: "windows-cvm",
version: "17763.2183.2109130127",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: {
securityProfile: { securityEncryptionType: "VMGuestStateOnly" },
storageAccountType: "StandardSSD_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DC2as_v5",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "2019-datacenter-cvm",
Sku = "windows-cvm",
Version = "17763.2183.2109130127",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
SecurityProfile = new VirtualMachineDiskSecurityProfile
{
SecurityEncryptionType = SecurityEncryptionType.VmGuestStateOnly,
},
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = true,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.ConfidentialVm,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2as_v5"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows-cvm",
"publisher": "MicrosoftWindowsServer",
"version": "17763.2183.2109130127",
"offer": "2019-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "VMGuestStateOnly"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2as_v5"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows-cvm",
"publisher": "MicrosoftWindowsServer",
"version": "17763.2183.2109130127",
"offer": "2019-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "VMGuestStateOnly"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with SecurityType as ConfidentialVM and NonPersistedTPM securityEncryptionType
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2es_v5"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "linux-cvm",
"publisher": "UbuntuServer",
"version": "17763.2183.2109130127",
"offer": "2022-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "NonPersistedTPM"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": false,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityEncryptionTypes;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMDiskSecurityProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.
* json
*/
/**
* Sample code: Create a scale set with SecurityType as ConfidentialVM and NonPersistedTPM securityEncryptionType.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSecurityTypeAsConfidentialVMAndNonPersistedTPMSecurityEncryptionType(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DC2es_v5").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("UbuntuServer")
.withOffer("2022-datacenter-cvm").withSku("linux-cvm").withVersion("17763.2183.2109130127"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS)
.withSecurityProfile(new VMDiskSecurityProfile()
.withSecurityEncryptionType(SecurityEncryptionTypes.NON_PERSISTED_TPM)))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(false).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.CONFIDENTIAL_VM)))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_type_confidential_vm_with_non_persisted_tpm.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "ConfidentialVM",
"uefiSettings": {"secureBootEnabled": False, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "2022-datacenter-cvm",
"publisher": "UbuntuServer",
"sku": "linux-cvm",
"version": "17763.2183.2109130127",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {
"securityProfile": {"securityEncryptionType": "NonPersistedTPM"},
"storageAccountType": "StandardSSD_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DC2es_v5", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityTypeAsConfidentialVmAndNonPersistedTpmSecurityEncryptionType() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(false),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("2022-datacenter-cvm"),
Publisher: to.Ptr("UbuntuServer"),
SKU: to.Ptr("linux-cvm"),
Version: to.Ptr("17763.2183.2109130127"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
SecurityProfile: &armcompute.VMDiskSecurityProfile{
SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesNonPersistedTPM),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DC2es_v5"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(false),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("2022-datacenter-cvm"),
// Publisher: to.Ptr("UbuntuServer"),
// SKU: to.Ptr("linux-cvm"),
// Version: to.Ptr("17763.2183.2109130127"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// SecurityProfile: &armcompute.VMDiskSecurityProfile{
// SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesNonPersistedTPM),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DC2es_v5"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
*/
async function createAScaleSetWithSecurityTypeAsConfidentialVMAndNonPersistedTpmSecurityEncryptionType() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DC2es_v5", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "ConfidentialVM",
uefiSettings: { secureBootEnabled: false, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "2022-datacenter-cvm",
publisher: "UbuntuServer",
sku: "linux-cvm",
version: "17763.2183.2109130127",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: {
securityProfile: { securityEncryptionType: "NonPersistedTPM" },
storageAccountType: "StandardSSD_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DC2es_v5",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "UbuntuServer",
Offer = "2022-datacenter-cvm",
Sku = "linux-cvm",
Version = "17763.2183.2109130127",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
SecurityProfile = new VirtualMachineDiskSecurityProfile
{
SecurityEncryptionType = SecurityEncryptionType.NonPersistedTPM,
},
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = false,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.ConfidentialVm,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2es_v5"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "linux-cvm",
"publisher": "UbuntuServer",
"version": "17763.2183.2109130127",
"offer": "2022-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "NonPersistedTPM"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": false,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2es_v5"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "linux-cvm",
"publisher": "UbuntuServer",
"version": "17763.2183.2109130127",
"offer": "2022-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "NonPersistedTPM"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": false,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with Service Artifact Reference
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"location": "eastus2euap",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ServiceArtifactReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
*/
/**
* Sample code: Create a scale set with Service Artifact Reference.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithServiceArtifactReference(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("eastus2euap")
.withSku(new Sku().withName("Standard_A1").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withEnableAutomaticOSUpgrade(true)))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2022-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withServiceArtifactReference(new ServiceArtifactReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName")))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_service_artifact_reference.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "eastus2euap",
"properties": {
"overprovision": True,
"upgradePolicy": {"automaticOSUpgradePolicy": {"enableAutomaticOSUpgrade": True}, "mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-Datacenter",
"version": "latest",
},
"osDisk": {"caching": "ReadWrite", "createOption": "FromImage", "name": "osDisk"},
},
},
},
"sku": {"capacity": 3, "name": "Standard_A1", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithServiceArtifactReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("eastus2euap"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
EnableAutomaticOSUpgrade: to.Ptr(true),
},
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ServiceArtifactReference: &armcompute.ServiceArtifactReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2022-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("eastus2euap"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("77b7df9a-32fe-45e3-8911-60ac9c9b9c64"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
// EnableAutomaticOSUpgrade: to.Ptr(true),
// },
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ServiceArtifactReference: &armcompute.ServiceArtifactReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2022-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
*/
async function createAScaleSetWithServiceArtifactReference() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "eastus2euap",
overprovision: true,
sku: { name: "Standard_A1", capacity: 3, tier: "Standard" },
upgradePolicy: {
automaticOSUpgradePolicy: { enableAutomaticOSUpgrade: true },
mode: "Automatic",
},
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
serviceArtifactReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2022-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap"))
{
Sku = new ComputeSku
{
Name = "Standard_A1",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy
{
EnableAutomaticOSUpgrade = true,
},
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2022-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "77b7df9a-32fe-45e3-8911-60ac9c9b9c64",
"virtualMachineProfile": {
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
},
"provisioningState": "Creating"
},
"location": "eastus2euap",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "77b7df9a-32fe-45e3-8911-60ac9c9b9c64",
"virtualMachineProfile": {
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"name": "osDisk",
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
},
"provisioningState": "Creating"
},
"location": "eastus2euap",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with sku profile
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"capacity": 10,
"name": "Mix"
},
"location": "westus",
"properties": {
"singlePlacementGroup": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"orchestrationMode": "Flexible",
"priorityMixPolicy": {
"baseRegularPriorityCount": 4,
"regularPriorityPercentageAboveBase": 50
},
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5"
},
{
"name": "Standard_E16s_v5"
},
{
"name": "Standard_D2s_v5"
}
],
"allocationStrategy": "CapacityOptimized"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.AllocationStrategy;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BillingProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.OrchestrationMode;
import com.azure.resourcemanager.compute.models.PriorityMixPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SkuProfile;
import com.azure.resourcemanager.compute.models.SkuProfileVMSize;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineEvictionPolicyTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
*/
/**
* Sample code: Create a scale set with sku profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSkuProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Mix").withCapacity(10L))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withPriority(VirtualMachinePriorityTypes.SPOT)
.withEvictionPolicy(VirtualMachineEvictionPolicyTypes.DEALLOCATE)
.withBillingProfile(new BillingProfile().withMaxPrice(-1.0D)))
.withSinglePlacementGroup(false).withOrchestrationMode(OrchestrationMode.FLEXIBLE)
.withPriorityMixPolicy(
new PriorityMixPolicy().withBaseRegularPriorityCount(4).withRegularPriorityPercentageAboveBase(50))
.withSkuProfile(new SkuProfile()
.withVmSizes(Arrays.asList(new SkuProfileVMSize().withName("Standard_D8s_v5"),
new SkuProfileVMSize().withName("Standard_E16s_v5"),
new SkuProfileVMSize().withName("Standard_D2s_v5")))
.withAllocationStrategy(AllocationStrategy.CAPACITY_OPTIMIZED)),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_sku_profile.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"priorityMixPolicy": {"baseRegularPriorityCount": 4, "regularPriorityPercentageAboveBase": 50},
"singlePlacementGroup": False,
"skuProfile": {
"allocationStrategy": "CapacityOptimized",
"vmSizes": [{"name": "Standard_D8s_v5"}, {"name": "Standard_E16s_v5"}, {"name": "Standard_D2s_v5"}],
},
"virtualMachineProfile": {
"billingProfile": {"maxPrice": -1},
"evictionPolicy": "Deallocate",
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 10, "name": "Mix"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSkuProfile() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
PriorityMixPolicy: &armcompute.PriorityMixPolicy{
BaseRegularPriorityCount: to.Ptr[int32](4),
RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
},
SinglePlacementGroup: to.Ptr(false),
SKUProfile: &armcompute.SKUProfile{
AllocationStrategy: to.Ptr(armcompute.AllocationStrategyCapacityOptimized),
VMSizes: []*armcompute.SKUProfileVMSize{
{
Name: to.Ptr("Standard_D8s_v5"),
},
{
Name: to.Ptr("Standard_E16s_v5"),
},
{
Name: to.Ptr("Standard_D2s_v5"),
}},
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
BillingProfile: &armcompute.BillingProfile{
MaxPrice: to.Ptr[float64](-1),
},
EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Mix"),
Capacity: to.Ptr[int64](10),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
// PriorityMixPolicy: &armcompute.PriorityMixPolicy{
// BaseRegularPriorityCount: to.Ptr[int32](4),
// RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
// },
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(false),
// SKUProfile: &armcompute.SKUProfile{
// AllocationStrategy: to.Ptr(armcompute.AllocationStrategyCapacityOptimized),
// VMSizes: []*armcompute.SKUProfileVMSize{
// {
// Name: to.Ptr("Standard_D8s_v5"),
// },
// {
// Name: to.Ptr("Standard_E16s_v5"),
// },
// {
// Name: to.Ptr("Standard_D2s_v5"),
// }},
// },
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// BillingProfile: &armcompute.BillingProfile{
// MaxPrice: to.Ptr[float64](-1),
// },
// EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Mix"),
// Capacity: to.Ptr[int64](10),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
*/
async function createAScaleSetWithSkuProfile() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
orchestrationMode: "Flexible",
priorityMixPolicy: {
baseRegularPriorityCount: 4,
regularPriorityPercentageAboveBase: 50,
},
singlePlacementGroup: false,
sku: { name: "Mix", capacity: 10 },
skuProfile: {
allocationStrategy: "CapacityOptimized",
vmSizes: [
{ name: "Standard_D8s_v5" },
{ name: "Standard_E16s_v5" },
{ name: "Standard_D2s_v5" },
],
},
virtualMachineProfile: {
billingProfile: { maxPrice: -1 },
evictionPolicy: "Deallocate",
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Mix",
Capacity = 10L,
},
Properties = new VirtualMachineScaleSetProperties
{
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
SinglePlacementGroup = false,
OrchestrationMode = OrchestrationMode.Flexible,
PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy
{
BaseRegularPriorityCount = 4,
RegularPriorityPercentageAboveBase = 50,
},
SkuProfile = new ComputeSkuProfile
{
VmSizes = {new ComputeSkuProfileVmSize
{
Name = "Standard_D8s_v5",
}, new ComputeSkuProfileVmSize
{
Name = "Standard_E16s_v5",
}, new ComputeSkuProfileVmSize
{
Name = "Standard_D2s_v5",
}},
AllocationStrategy = ComputeAllocationStrategy.CapacityOptimized,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"capacity": 10,
"name": "Mix"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"orchestrationMode": "Flexible",
"priorityMixPolicy": {
"baseRegularPriorityCount": 4,
"regularPriorityPercentageAboveBase": 50
},
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5"
},
{
"name": "Standard_E16s_v5"
},
{
"name": "Standard_D2s_v5"
}
],
"allocationStrategy": "CapacityOptimized"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"capacity": 10,
"name": "Mix"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": false,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"orchestrationMode": "Flexible",
"priorityMixPolicy": {
"baseRegularPriorityCount": 4,
"regularPriorityPercentageAboveBase": 50
},
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5"
},
{
"name": "Standard_E16s_v5"
},
{
"name": "Standard_D2s_v5"
}
],
"allocationStrategy": "CapacityOptimized"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with spot restore policy
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"upgradePolicy": {
"mode": "Manual"
},
"spotRestorePolicy": {
"enabled": true,
"restoreTimeout": "PT1H"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BillingProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SpotRestorePolicy;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineEvictionPolicyTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
*/
/**
* Sample code: Create a scale set with spot restore policy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSpotRestorePolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_A8m_v2").withTier("Standard").withCapacity(2L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withPriority(VirtualMachinePriorityTypes.SPOT)
.withEvictionPolicy(VirtualMachineEvictionPolicyTypes.DEALLOCATE)
.withBillingProfile(new BillingProfile().withMaxPrice(-1.0D)))
.withOverprovision(true)
.withSpotRestorePolicy(new SpotRestorePolicy().withEnabled(true).withRestoreTimeout("PT1H")), null,
null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_spot_restore_policy.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"spotRestorePolicy": {"enabled": True, "restoreTimeout": "PT1H"},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"billingProfile": {"maxPrice": -1},
"evictionPolicy": "Deallocate",
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A8m_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSpotRestorePolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
SpotRestorePolicy: &armcompute.SpotRestorePolicy{
Enabled: to.Ptr(true),
RestoreTimeout: to.Ptr("PT1H"),
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
BillingProfile: &armcompute.BillingProfile{
MaxPrice: to.Ptr[float64](-1),
},
EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A8m_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// SpotRestorePolicy: &armcompute.SpotRestorePolicy{
// Enabled: to.Ptr(true),
// RestoreTimeout: to.Ptr("PT1H"),
// },
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// BillingProfile: &armcompute.BillingProfile{
// MaxPrice: to.Ptr[float64](-1),
// },
// EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A8m_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
*/
async function createAScaleSetWithSpotRestorePolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_A8m_v2", capacity: 2, tier: "Standard" },
spotRestorePolicy: { enabled: true, restoreTimeout: "PT1H" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
billingProfile: { maxPrice: -1 },
evictionPolicy: "Deallocate",
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_A8m_v2",
Tier = "Standard",
Capacity = 2L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
Overprovision = true,
SpotRestorePolicy = new SpotRestorePolicy
{
Enabled = true,
RestoreTimeout = "PT1H",
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"upgradePolicy": {
"mode": "Manual"
},
"spotRestorePolicy": {
"enabled": true,
"restoreTimeout": "PT1H"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"upgradePolicy": {
"mode": "Manual"
},
"spotRestorePolicy": {
"enabled": true,
"restoreTimeout": "PT1H"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with ssh authentication.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"linuxConfiguration": {
"ssh": {
"publicKeys": [
{
"path": "/home/{your-username}/.ssh/authorized_keys",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"
}
]
},
"disablePasswordAuthentication": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.LinuxConfiguration;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SshConfiguration;
import com.azure.resourcemanager.compute.models.SshPublicKey;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
*/
/**
* Sample code: Create a scale set with ssh authentication.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSshAuthentication(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}")
.withLinuxConfiguration(new LinuxConfiguration().withDisablePasswordAuthentication(true)
.withSsh(new SshConfiguration().withPublicKeys(
Arrays.asList(new SshPublicKey().withPath("/home/{your-username}/.ssh/authorized_keys")
.withKeyData("fakeTokenPlaceholder"))))))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_ssh_authentication.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
"linuxConfiguration": {
"disablePasswordAuthentication": True,
"ssh": {
"publicKeys": [
{
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
"path": "/home/{your-username}/.ssh/authorized_keys",
}
]
},
},
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSshAuthentication() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
LinuxConfiguration: &armcompute.LinuxConfiguration{
DisablePasswordAuthentication: to.Ptr(true),
SSH: &armcompute.SSHConfiguration{
PublicKeys: []*armcompute.SSHPublicKey{
{
Path: to.Ptr("/home/{your-username}/.ssh/authorized_keys"),
KeyData: to.Ptr("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"),
}},
},
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("fb73af19-0090-467c-9ced-b00bceab1c45"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(true),
// SSH: &armcompute.SSHConfiguration{
// PublicKeys: []*armcompute.SSHPublicKey{
// {
// Path: to.Ptr("/home/{your-username}/.ssh/authorized_keys"),
// KeyData: to.Ptr("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"),
// }},
// },
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("16.04-LTS"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
*/
async function createAScaleSetWithSshAuthentication() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
linuxConfiguration: {
disablePasswordAuthentication: true,
ssh: {
publicKeys: [
{
path: "/home/{your-username}/.ssh/authorized_keys",
keyData:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
},
],
},
},
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
LinuxConfiguration = new LinuxConfiguration
{
IsPasswordAuthenticationDisabled = true,
SshPublicKeys = {new SshPublicKeyConfiguration
{
Path = "/home/{your-username}/.ssh/authorized_keys",
KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
}},
},
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "fb73af19-0090-467c-9ced-b00bceab1c45",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "16.04-LTS",
"publisher": "Canonical",
"version": "latest",
"offer": "UbuntuServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"ssh": {
"publicKeys": [
{
"path": "/home/{your-username}/.ssh/authorized_keys",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"
}
]
},
"disablePasswordAuthentication": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "fb73af19-0090-467c-9ced-b00bceab1c45",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "16.04-LTS",
"publisher": "Canonical",
"version": "latest",
"offer": "UbuntuServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"linuxConfiguration": {
"ssh": {
"publicKeys": [
{
"path": "/home/{your-username}/.ssh/authorized_keys",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"
}
]
},
"disablePasswordAuthentication": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with terminate scheduled events enabled.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT5M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.TerminateNotificationProfile;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
*/
/**
* Sample code: Create a scale set with terminate scheduled events enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithTerminateScheduledEventsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withScheduledEventsProfile(new ScheduledEventsProfile().withTerminateNotificationProfile(
new TerminateNotificationProfile().withNotBeforeTimeout("PT5M").withEnable(true))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_terminate_scheduled_event_enabled.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {"enable": True, "notBeforeTimeout": "PT5M"}
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithTerminateScheduledEventsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
TerminateNotificationProfile: &armcompute.TerminateNotificationProfile{
Enable: to.Ptr(true),
NotBeforeTimeout: to.Ptr("PT5M"),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
// TerminateNotificationProfile: &armcompute.TerminateNotificationProfile{
// Enable: to.Ptr(true),
// NotBeforeTimeout: to.Ptr("PT5M"),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
*/
async function createAScaleSetWithTerminateScheduledEventsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
scheduledEventsProfile: {
terminateNotificationProfile: {
enable: true,
notBeforeTimeout: "PT5M",
},
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ScheduledEventsProfile = new ComputeScheduledEventsProfile
{
TerminateNotificationProfile = new TerminateNotificationProfile
{
NotBeforeTimeout = "PT5M",
Enable = true,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT5M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT5M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with Uefi Settings of secureBoot and vTPM.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows10-tvm",
"publisher": "MicrosoftWindowsServer",
"version": "18363.592.2001092016",
"offer": "windowsserver-gen2preview-preview"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "TrustedLaunch"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
*/
/**
* Sample code: Create a scale set with Uefi Settings of secureBoot and vTPM.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithUefiSettingsOfSecureBootAndVTPM(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName(
"Standard_D2s_v3").withTier(
"Standard")
.withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(
new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("windowsserver-gen2preview-preview").withSku("windows10-tvm")
.withVersion("18363.592.2001092016"))
.withOsDisk(
new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration()
.withName("{vmss-name}").withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(true).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.TRUSTED_LAUNCH)))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_uefi_settings.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "TrustedLaunch",
"uefiSettings": {"secureBootEnabled": True, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "windowsserver-gen2preview-preview",
"publisher": "MicrosoftWindowsServer",
"sku": "windows10-tvm",
"version": "18363.592.2001092016",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "StandardSSD_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2s_v3", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithUefiSettingsOfSecureBootAndVTpm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesTrustedLaunch),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(true),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windowsserver-gen2preview-preview"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("windows10-tvm"),
Version: to.Ptr("18363.592.2001092016"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2s_v3"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesTrustedLaunch),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(true),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("windowsserver-gen2preview-preview"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("windows10-tvm"),
// Version: to.Ptr("18363.592.2001092016"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2s_v3"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
*/
async function createAScaleSetWithUefiSettingsOfSecureBootAndVTpm() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2s_v3", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "TrustedLaunch",
uefiSettings: { secureBootEnabled: true, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "windowsserver-gen2preview-preview",
publisher: "MicrosoftWindowsServer",
sku: "windows10-tvm",
version: "18363.592.2001092016",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "StandardSSD_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2s_v3",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "windowsserver-gen2preview-preview",
Sku = "windows10-tvm",
Version = "18363.592.2001092016",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = true,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.TrustedLaunch,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows10-tvm",
"publisher": "MicrosoftWindowsServer",
"version": "18363.592.2001092016",
"offer": "windowsserver-gen2preview-preview"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "TrustedLaunch"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"name": "{vmss-name}",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "b9e23088-6ffc-46e0-9e02-b0a6eeef47db",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows10-tvm",
"publisher": "MicrosoftWindowsServer",
"version": "18363.592.2001092016",
"offer": "windowsserver-gen2preview-preview"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "TrustedLaunch"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus"
}
Create a scale set with userData.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
*/
/**
* Sample code: Create a scale set with userData.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithUserData(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ=="))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_user_data.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithUserData() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
*/
async function createAScaleSetWithUserData() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with virtual machines in different zones.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A1_v2"
},
"location": "centralus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
},
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 1
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic"
}
},
"zones": [
"1",
"3"
]
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
*/
/**
* Sample code: Create a scale set with virtual machines in different zones.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithVirtualMachinesInDifferentZones(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("centralus")
.withSku(new Sku().withName("Standard_A1_v2").withTier("Standard").withCapacity(2L))
.withZones(
Arrays.asList("1", "3"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC))
.withVirtualMachineProfile(
new VirtualMachineScaleSetVMProfile()
.withOsProfile(
new VirtualMachineScaleSetOSProfile()
.withComputerNamePrefix("{vmss-name}").withAdminUsername("{your-username}")
.withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(
new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE).withDiskSizeGB(512)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDataDisks(
Arrays
.asList(
new VirtualMachineScaleSetDataDisk()
.withLun(0).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023),
new VirtualMachineScaleSetDataDisk().withLun(
1).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration()
.withName("{vmss-name}").withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_vms_in_different_zones.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "centralus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 0},
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 1},
],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diskSizeGB": 512,
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A1_v2", "tier": "Standard"},
"zones": ["1", "3"],
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithVirtualMachinesInDifferentZones() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("centralus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
},
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](1),
}},
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiskSizeGB: to.Ptr[int32](512),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
Zones: []*string{
to.Ptr("1"),
to.Ptr("3")},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("centralus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(false),
// UniqueID: to.Ptr("8042c376-4690-4c47-9fa2-fbdad70e32fa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](1),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiskSizeGB: to.Ptr[int32](512),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// ZoneBalance: to.Ptr(false),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// Zones: []*string{
// to.Ptr("1"),
// to.Ptr("3")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
*/
async function createAScaleSetWithVirtualMachinesInDifferentZones() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "centralus",
overprovision: true,
sku: { name: "Standard_A1_v2", capacity: 2, tier: "Standard" },
upgradePolicy: { mode: "Automatic" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{ createOption: "Empty", diskSizeGB: 1023, lun: 0 },
{ createOption: "Empty", diskSizeGB: 1023, lun: 1 },
],
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
diskSizeGB: 512,
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
zones: ["1", "3"],
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("centralus"))
{
Sku = new ComputeSku
{
Name = "Standard_A1_v2",
Tier = "Standard",
Capacity = 2L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 512,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
Zones = { "1", "3" },
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": false,
"overprovision": true,
"uniqueId": "8042c376-4690-4c47-9fa2-fbdad70e32fa",
"zoneBalance": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 0,
"diskSizeGB": 1023
},
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 1,
"diskSizeGB": 1023
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic"
},
"provisioningState": "Succeeded"
},
"zones": [
"1",
"3"
],
"location": "centralus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": false,
"overprovision": true,
"uniqueId": "8042c376-4690-4c47-9fa2-fbdad70e32fa",
"zoneBalance": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 0,
"diskSizeGB": 1023
},
{
"caching": "None",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "Empty",
"lun": 1,
"diskSizeGB": 1023
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic"
},
"provisioningState": "Creating"
},
"zones": [
"1",
"3"
],
"location": "centralus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with vm size properties
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMSizeProperties;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetHardwareProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
*/
/**
* Sample code: Create a scale set with vm size properties.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithVmSizeProperties(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ==")
.withHardwareProfile(new VirtualMachineScaleSetHardwareProfile()
.withVmSizeProperties(new VMSizeProperties().withVCpusAvailable(1).withVCpusPerCore(1))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_vm_size_properties.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"hardwareProfile": {"vmSizeProperties": {"vCPUsAvailable": 1, "vCPUsPerCore": 1}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithVmSizeProperties() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
VMSizeProperties: &armcompute.VMSizeProperties{
VCPUsAvailable: to.Ptr[int32](1),
VCPUsPerCore: to.Ptr[int32](1),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
// VMSizeProperties: &armcompute.VMSizeProperties{
// VCPUsAvailable: to.Ptr[int32](1),
// VCPUsPerCore: to.Ptr[int32](1),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
*/
async function createAScaleSetWithVMSizeProperties() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
hardwareProfile: {
vmSizeProperties: { vCPUsAvailable: 1, vCPUsPerCore: 1 },
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
HardwareVmSizeProperties = new VirtualMachineSizeProperties
{
VCpusAvailable = 1,
VCpusPerCore = 1,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a scale set with zonalPlatformFaultDomainAlignMode as Aligned
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"zonalPlatformFaultDomainAlignMode": "Aligned"
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import com.azure.resourcemanager.compute.models.ZonalPlatformFaultDomainAlignMode;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
*/
/**
* Sample code: Create a scale set with zonalPlatformFaultDomainAlignMode as Aligned.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true).withZonalPlatformFaultDomainAlignMode(
ZonalPlatformFaultDomainAlignMode.ALIGNED),
null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_zonal_platform_fault_domain_align_mode.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
"zonalPlatformFaultDomainAlignMode": "Aligned",
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
ZonalPlatformFaultDomainAlignMode: to.Ptr(armcompute.ZonalPlatformFaultDomainAlignModeAligned),
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// ZonalPlatformFaultDomainAlignMode: to.Ptr(armcompute.ZonalPlatformFaultDomainAlignModeAligned),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
*/
async function createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
zonalPlatformFaultDomainAlignMode: "Aligned",
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
ZonalPlatformFaultDomainAlignMode = ZonalPlatformFaultDomainAlignMode.Aligned,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"provisioningState": "Creating",
"zonalPlatformFaultDomainAlignMode": "Aligned"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"provisioningState": "Creating",
"zonalPlatformFaultDomainAlignMode": "Aligned"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a VMSS with an extension that has suppressFailures enabled
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"suppressFailures": true
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
*/
/**
* Sample code: Create a VMSS with an extension that has suppressFailures enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAVMSSWithAnExtensionThatHasSuppressFailuresEnabled(
com.azure.resourcemanager.AzureResourceManager azure) throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile().withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON))
.withSuppressFailures(true)))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_extensions_suppress_failures_enabled.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"publisher": "{extension-Publisher}",
"settings": {},
"suppressFailures": True,
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAVmssWithAnExtensionThatHasSuppressFailuresEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
SuppressFailures: to.Ptr(true),
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// SuppressFailures: to.Ptr(true),
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
*/
async function createAVmssWithAnExtensionThatHasSuppressFailuresEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
publisher: "{extension-Publisher}",
settings: {},
suppressFailures: true,
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
SuppressFailures = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"suppressFailures": true
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"suppressFailures": true
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create a VMSS with an extension with protectedSettingsFromKeyVault
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"protectedSettingsFromKeyVault": {
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"
}
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.KeyVaultSecretReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
*/
/**
* Sample code: Create a VMSS with an extension with protectedSettingsFromKeyVault.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAVMSSWithAnExtensionWithProtectedSettingsFromKeyVault(
com.azure.resourcemanager.AzureResourceManager azure) throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile().withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON))
.withProtectedSettingsFromKeyVault(new KeyVaultSecretReference()
.withSecretUrl("fakeTokenPlaceholder")
.withSourceVault(new SubResource().withId(
"/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName")))))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_protected_settings_from_key_vault.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"protectedSettingsFromKeyVault": {
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e",
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
},
"publisher": "{extension-Publisher}",
"settings": {},
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAVmssWithAnExtensionWithProtectedSettingsFromKeyVault() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
ProtectedSettingsFromKeyVault: &armcompute.KeyVaultSecretReference{
SecretURL: to.Ptr("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"),
SourceVault: &armcompute.SubResource{
ID: to.Ptr("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
},
},
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// ProtectedSettingsFromKeyVault: &armcompute.KeyVaultSecretReference{
// SecretURL: to.Ptr("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"),
// SourceVault: &armcompute.SubResource{
// ID: to.Ptr("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
// },
// },
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
*/
async function createAVmssWithAnExtensionWithProtectedSettingsFromKeyVault() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
protectedSettingsFromKeyVault: {
secretUrl:
"https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e",
sourceVault: {
id: "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName",
},
},
publisher: "{extension-Publisher}",
settings: {},
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"), new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
}),
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"protectedSettingsFromKeyVault": {
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"
}
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://nsgdiagnostic.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"protectedSettingsFromKeyVault": {
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"
}
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Create or update a scale set with capacity reservation.
Pedido de amostra
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.CapacityReservationProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
*/
/**
* Sample code: Create or update a scale set with capacity reservation.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAScaleSetWithCapacityReservation(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withCapacityReservation(
new CapacityReservationProfile().withCapacityReservationGroup(new SubResource().withId(
"subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"))))
.withOverprovision(true), null, null, 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.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_capacity_reservation.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 = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
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 armcompute_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/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createOrUpdateAScaleSetWithCapacityReservation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
CapacityReservation: &armcompute.CapacityReservationProfile{
CapacityReservationGroup: &armcompute.SubResource{
ID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// CapacityReservation: &armcompute.CapacityReservationProfile{
// CapacityReservationGroup: &armcompute.SubResource{
// ID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
*/
async function createOrUpdateAScaleSetWithCapacityReservation() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
capacityReservation: {
capacityReservationGroup: {
id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}",
},
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
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.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
CapacityReservationGroupId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"name": "{vmss-name}",
"properties": {
"singlePlacementGroup": true,
"overprovision": true,
"uniqueId": "d053ec5a-8da6-495f-ab13-38216503c6d7",
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"secrets": [],
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"enableAcceleratedNetworking": false
}
}
]
},
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
}
},
"upgradePolicy": {
"mode": "Manual"
},
"provisioningState": "Creating"
},
"location": "westus",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"
}
Definições
Name |
Description |
AdditionalCapabilities
|
Habilita ou desabilita um recurso na máquina virtual ou no conjunto de dimensionamento de máquina virtual.
|
AdditionalUnattendContent
|
Especifica informações adicionais formatadas em XML que podem ser incluídas no arquivo Unattend.xml, que é usado pela Instalação do Windows. O conteúdo é definido definindo o nome, o nome do componente e a passagem na qual o conteúdo é aplicado.
|
AllocationStrategy
|
Especifica a estratégia de alocação para o conjunto de escala de máquina virtual com base no qual as VMs serão alocadas.
|
ApiEntityReference
|
A referência da entidade da API.
|
ApiError
|
Erro de api.
|
ApiErrorBase
|
Base de erro da api.
|
ApplicationProfile
|
Contém a lista de aplicativos de galeria que devem ser disponibilizados para a VM/VMSS
|
AutomaticOSUpgradePolicy
|
Os parâmetros de configuração usados para executar a atualização automática do sistema operacional.
|
AutomaticRepairsPolicy
|
Especifica os parâmetros de configuração para reparos automáticos no conjunto de escala da máquina virtual.
|
BillingProfile
|
Especifica os detalhes relacionados à cobrança de uma VM ou VMSS spot do Azure. Versão api mínima: 2019-03-01.
|
BootDiagnostics
|
O Diagnóstico de Inicialização é um recurso de depuração que permite visualizar a saída do console e a captura de tela para diagnosticar o status da VM. Você pode visualizar facilmente a saída do log do console. O Azure também permite que você veja uma captura de tela da VM do hipervisor.
|
CachingTypes
|
Especifica os requisitos de cache. Os valores possíveis são: None,ReadOnlyReadWrite. Os valores padrão são: Nenhum para armazenamento padrão. ReadOnly para armazenamento Premium.
|
CapacityReservationProfile
|
Os parâmetros de um Perfil de reserva de capacidade.
|
CloudError
|
Uma resposta de erro do serviço de computação.
|
ComponentNames
|
O nome do componente. Atualmente, o único valor permitido é Microsoft-Windows-Shell-Setup.
|
DeleteOptions
|
Especificar o que acontece com o IP público quando a VM é excluída
|
DiagnosticsProfile
|
Especifica o estado das configurações de diagnóstico de inicialização. Versão mínima da api: 2015-06-15.
|
DiffDiskOptions
|
Especifica as configurações de disco efêmero para o disco do sistema operacional.
|
DiffDiskPlacement
|
Especifica o posicionamento efêmero do disco do sistema operacional. Esta propriedade pode ser usada pelo usuário na solicitação para escolher o local, ou seja, disco de cache, disco de recurso ou espaço em disco nvme para provisionamento de disco do sistema operacional efêmero. Para obter mais informações sobre os requisitos de tamanho de disco do sistema operacional efêmero, consulte Requisitos de tamanho de disco do sistema operacional efêmero para VM do Windows no https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e VM do Linux no https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. Versão mínima da api para NvmeDisk: 2024-03-01.
|
DiffDiskSettings
|
Descreve os parâmetros das configurações de disco efêmero que podem ser especificadas para o disco do sistema operacional.
Nota: As configurações de disco efêmero só podem ser especificadas para o disco gerenciado.
|
DiskControllerTypes
|
|
DiskCreateOptionTypes
|
Especifica como as máquinas virtuais no conjunto de escala devem ser criadas. O único valor permitido é: FromImage. Esse valor é usado quando você está usando uma imagem para criar a máquina virtual. Se você estiver usando uma imagem de plataforma, também usará o elemento imageReference descrito acima. Se você estiver usando uma imagem do marketplace, também usará o elemento de plano descrito anteriormente.
|
DiskDeleteOptionTypes
|
Especifica se o disco do sistema operacional deve ser excluído ou desanexado após a exclusão do VMSS Flex (esse recurso está disponível apenas para VMSS com Flexible OrchestrationMode).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando o VMSS Flex VM for excluído.
Desanexar Se esse valor for usado, o disco do sistema operacional será retido depois que o VMSS Flex VM for excluído.
O valor padrão é definido como Excluir. Para um disco de sistema operacional efêmero, o valor padrão é definido como Delete. O usuário não pode alterar a opção de exclusão para Ephemeral OS Disk.
|
DiskEncryptionSetParameters
|
Descreve o parâmetro de id de recurso do conjunto de criptografia de disco gerenciado pelo cliente que pode ser especificado para o disco.
Nota: O ID do recurso do conjunto de criptografia de disco só pode ser especificado para o disco gerenciado. Consulte https://aka.ms/mdssewithcmkoverview para obter mais detalhes.
|
DomainNameLabelScopeTypes
|
O escopo do rótulo de nome de domínio. A concatenação do rótulo de nome de domínio com hash gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice vm serão os rótulos de nome de domínio dos recursos de endereço PublicIPAddress que serão criados
|
EncryptionIdentity
|
Especifica a Identidade Gerenciada usada pelo ADE para obter o token de acesso para operações keyvault.
|
EventGridAndResourceGraph
|
Especifica as configurações relacionadas a eventos agendados relacionados a eventGridAndResourceGraph.
|
ExtendedLocation
|
O tipo complexo do local estendido.
|
ExtendedLocationTypes
|
O tipo de local estendido.
|
ImageReference
|
Especifica informações sobre a imagem a ser usada. Você pode especificar informações sobre imagens de plataforma, imagens de mercado ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, imagem de mercado ou imagem de máquina virtual, mas não é usado em outras operações de criação. NOTA: O editor e a oferta de referência de imagem só podem ser definidos quando cria o conjunto de escalas.
|
InnerError
|
Detalhes do erro interno.
|
IPVersion
|
Disponível a partir de Api-Version 2019-07-01, representa se a configuração ip específica é IPv4 ou IPv6. O padrão é considerado IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
|
KeyVaultSecretReference
|
Descreve uma referência ao segredo do Key Vault
|
LinuxConfiguration
|
Especifica as configurações do sistema operacional Linux na máquina virtual. Para obter uma lista de distribuições Linux suportadas, consulte Linux on Azure-Endorsed Distributions.
|
LinuxPatchAssessmentMode
|
Especifica o modo de Avaliação de Patch de Convidado de VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
|
LinuxPatchSettings
|
Especifica as configurações relacionadas ao Patch de convidado de VM no Linux.
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
|
LinuxVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais a serem aplicadas quando o modo de patch AutomaticByPlatform é selecionado nas configurações de patch do Linux.
|
LinuxVMGuestPatchMode
|
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
ImageDefault - A configuração de patch padrão da máquina virtual é usada.
AutomaticByPlatform - A máquina virtual será atualizada automaticamente pela plataforma. A provisão de propriedadeVMAgent deve ser true
|
Mode
|
Especifica o modo em que o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não a impor o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo de Auditoria, enquanto no modo Enforce ele imporá o controle de acesso. O valor padrão é Enforce mode.
|
NetworkApiVersion
|
especifica a versão da API Microsoft.Network usada ao criar recursos de rede nas Configurações de Interface de Rede para Conjunto de Dimensionamento de Máquina Virtual com modo de orquestração 'Flexível'
|
NetworkInterfaceAuxiliaryMode
|
Especifica se o modo Auxiliar está habilitado para o recurso Interface de Rede.
|
NetworkInterfaceAuxiliarySku
|
Especifica se a sku Auxiliar está habilitada para o recurso Interface de Rede.
|
OperatingSystemTypes
|
Essa propriedade permite que você especifique o tipo do sistema operacional que está incluído no disco se estiver criando uma VM a partir da imagem do usuário ou de um VHD especializado. Os valores possíveis são: Windows,Linux.
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de escala da máquina virtual.
|
OSImageNotificationProfile
|
|
PassNames
|
O nome do passe. Atualmente, o único valor permitido é OobeSystem.
|
PatchSettings
|
Especifica as configurações relacionadas ao patch de convidado de VM no Windows.
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Este elemento é usado apenas para imagens do mercado. Antes de poder usar uma imagem de mercado de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que pretende utilizar e, em seguida, clique em Pretende implementar programaticamente, Introdução ->. Introduza todas as informações necessárias e, em seguida, clique em Guardar.
|
PriorityMixPolicy
|
Especifica as divisões de destino para VMs de prioridade Spot e Regular dentro de um conjunto de escala com modo de orquestração flexível. Com essa propriedade, o cliente pode especificar o número base de VMs de prioridade regular criadas à medida que a instância flexível do VMSS se expande e a divisão entre VMs de prioridade Spot e Regular após esse destino base ter sido atingido.
|
ProtocolTypes
|
Especifica o protocolo do ouvinte do WinRM. Os valores possíveis são: httphttps.
|
ProxyAgentSettings
|
Especifica as configurações do ProxyAgent ao criar a máquina virtual. Versão mínima da api: 2023-09-01.
|
PublicIPAddressSku
|
Descreve o IP público Sku. Ele só pode ser definido com OrchestrationMode como flexível.
|
PublicIPAddressSkuName
|
Especificar nome de sku IP público
|
PublicIPAddressSkuTier
|
Especificar camada de sku IP público
|
RepairAction
|
Tipo de ação de reparo (substituir, reiniciar, recriar imagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de escala. O valor padrão é substituir.
|
ResiliencyPolicy
|
Descreve uma política de resiliência - resilientVMCreationPolicy e/ou resilientVMDeletionPolicy.
|
ResilientVMCreationPolicy
|
Os parâmetros de configuração usados durante a execução da criação de VM resiliente.
|
ResilientVMDeletionPolicy
|
Os parâmetros de configuração usados ao executar a exclusão de VM resiliente.
|
ResourceIdentityType
|
O tipo de identidade usado para o conjunto de dimensionamento de máquina virtual. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades do conjunto de escala da máquina virtual.
|
RollingUpgradePolicy
|
Os parâmetros de configuração usados durante a execução de uma atualização contínua.
|
ScaleInPolicy
|
Descreve uma política de dimensionamento para um conjunto de dimensionamento de máquina virtual.
|
ScheduledEventsAdditionalPublishingTargets
|
|
ScheduledEventsPolicy
|
Especifica as configurações relacionadas a Redeploy, Reboot e ScheduledEventsAdditionalPublishingTargets Scheduled Event.
|
ScheduledEventsProfile
|
|
securityEncryptionTypes
|
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado junto com o blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado do firmware no blob VMGuestState.
Nota: Ele pode ser definido apenas para VMs confidenciais.
|
SecurityPostureReference
|
Especifica a postura de segurança a ser usada no conjunto de escalas. Versão mínima da api: 2023-03-01
|
SecurityProfile
|
Especifica as configurações de perfil de segurança para a máquina virtual ou o conjunto de dimensionamento da máquina virtual.
|
SecurityTypes
|
Especifica o SecurityType da máquina virtual. Ele deve ser definido como qualquer valor especificado para habilitar UefiSettings. O comportamento padrão é: UefiSettings não será habilitado a menos que essa propriedade esteja definida.
|
ServiceArtifactReference
|
Especifica a ID de referência do artefato de serviço usada para definir a mesma versão de imagem para todas as máquinas virtuais no conjunto de escala ao usar a versão de imagem 'mais recente'. Versão mínima api: 2022-11-01
|
SettingNames
|
Especifica o nome da configuração à qual o conteúdo se aplica. Os valores possíveis são: FirstLogonCommands e AutoLogon.
|
Sku
|
Descreve um sku de conjunto de escala de máquina virtual. NOTA: Se a nova SKU de VM não for suportada no hardware em que o conjunto de escala está atualmente, você precisará desalocar as VMs no conjunto de escala antes de modificar o nome da SKU.
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de escala de máquina virtual. Com essa propriedade, o cliente pode especificar uma lista de tamanhos de VM e uma estratégia de alocação.
|
SkuProfileVMSize
|
Especifica o tamanho da VM.
|
SpotRestorePolicy
|
Especifica as propriedades Spot-Try-Restore para o conjunto de escala da máquina virtual. Com essa propriedade, o cliente pode habilitar ou desabilitar a restauração automática das instâncias de VM spot removidas oportunisticamente com base na disponibilidade de capacidade e na restrição de preços.
|
SshConfiguration
|
Configuração SSH para VMs baseadas em Linux em execução no Azure
|
SshPublicKey
|
Contém informações sobre a chave pública do certificado SSH e o caminho na VM Linux onde a chave pública é colocada.
|
StorageAccountTypes
|
Especifica o tipo de conta de armazenamento para o disco gerenciado. NOTA: UltraSSD_LRS só pode ser utilizado com discos de dados, não pode ser utilizado com o OS Disk.
|
SubResource
|
|
TerminateNotificationProfile
|
|
UefiSettings
|
Especifica as configurações de segurança, como inicialização segura e vTPM, usadas durante a criação da máquina virtual. Versão api mínima: 2020-12-01.
|
UpgradeMode
|
Especifica o modo de uma atualização para máquinas virtuais no conjunto de escala.
Os valores possíveis são:
Manual - Você controla a aplicação de atualizações para máquinas virtuais no conjunto de escala. Para fazer isso, use a ação manualUpgrade.
automático - Todas as máquinas virtuais no conjunto de escala são atualizadas automaticamente ao mesmo tempo.
|
UpgradePolicy
|
Descreve uma política de atualização - automática, manual ou rolante.
|
UserAssignedIdentities
|
A lista de identidades de usuário associadas à máquina virtual. As referências de chave do dicionário de identidade do usuário serão ids de recurso ARM no formato: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
UserInitiatedReboot
|
Especifica as configurações relacionadas a Eventos Agendados relacionados à Reinicialização.
|
UserInitiatedRedeploy
|
Especifica Reimplantar configurações relacionadas a Eventos Agendados relacionados.
|
VaultCertificate
|
Descreve uma única referência de certificado em um Cofre de Chaves e onde o certificado deve residir na VM.
|
VaultSecretGroup
|
Descreve um conjunto de certificados que estão todos no mesmo Cofre de Chaves.
|
VirtualHardDisk
|
Descreve o uri de um disco.
|
VirtualMachineEvictionPolicyTypes
|
Especifica a política de remoção para a máquina virtual do Azure Spot e o conjunto de escala do Azure Spot. Para máquinas virtuais do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2019-03-01. Para conjuntos de escala do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2017-10-30-preview.
|
VirtualMachinePriorityTypes
|
Especifica a prioridade para as máquinas virtuais no conjunto de escala. Versão mínima da api: 2017-10-30-preview.
|
VirtualMachineScaleSet
|
Descreve um conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetDataDisk
|
Descreve um disco de dados do conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetExtension
|
Descreve uma extensão de conjunto de escala de máquina virtual.
|
VirtualMachineScaleSetExtensionProfile
|
Descreve um perfil de extensão de conjunto de escala de máquina virtual.
|
VirtualMachineScaleSetHardwareProfile
|
Especifica as configurações de hardware para o conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetIdentity
|
Identidade para o conjunto de escala da máquina virtual.
|
VirtualMachineScaleSetIPConfiguration
|
Descreve a configuração IP do perfil de rede de um conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetIpTag
|
Contém a marca IP associada ao endereço IP público.
|
VirtualMachineScaleSetManagedDiskParameters
|
Descreve os parâmetros de um disco gerenciado ScaleSet.
|
VirtualMachineScaleSetNetworkConfiguration
|
Descreve as configurações de rede de um perfil de rede do conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
Descreve uma escala de máquinas virtuais que define as configurações de DNS da rede.
|
VirtualMachineScaleSetNetworkProfile
|
Descreve um perfil de rede de conjunto de escala de máquina virtual.
|
VirtualMachineScaleSetOSDisk
|
Descreve um disco do sistema operacional do conjunto de dimensionamento de máquina virtual.
|
VirtualMachineScaleSetOSProfile
|
Descreve um perfil de sistema operacional de conjunto de escala de máquina virtual.
|
VirtualMachineScaleSetPublicIPAddressConfiguration
|
Descreve um conjunto de dimensionamento de máquinas virtuais Configuração IP da configuração PublicIPAddress
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
|
Descreve uma escala de máquinas virtuais que define as configurações de DNS da rede.
|
VirtualMachineScaleSetScaleInRules
|
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquina virtual.
Os valores possíveis são:
padrão Quando um conjunto de escala de máquina virtual é dimensionado, o conjunto de escala será primeiro balanceado entre zonas se for um conjunto de escala zonal. Em seguida, ele será balanceado entre Domínios de Falha na medida do possível. Dentro de cada Domínio de Falha, as máquinas virtuais escolhidas para remoção serão as mais recentes que não estão protegidas contra scale-in.
OldestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais antigas que não estão protegidas serão escolhidas para remoção.
NewestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais recentes que não estão protegidas serão escolhidas para remoção.
|
VirtualMachineScaleSetStorageProfile
|
Descreve um perfil de armazenamento de conjunto de escala de máquina virtual.
|
VirtualMachineScaleSetVMProfile
|
Descreve um perfil de máquina virtual de conjunto de escala de máquina virtual.
|
VMDiskSecurityProfile
|
Especifica as configurações de perfil de segurança para o disco gerenciado.
Nota: Ele só pode ser definido para VMs confidenciais.
|
VMGalleryApplication
|
Especifica as informações necessárias para fazer referência a uma versão do aplicativo da galeria de computação
|
VMSizeProperties
|
Especifica as configurações da Propriedade de Tamanho da VM na máquina virtual.
|
WindowsConfiguration
|
Especifica as configurações do sistema operacional Windows na máquina virtual.
|
WindowsPatchAssessmentMode
|
Especifica o modo de avaliação de patch do convidado da VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
|
WindowsVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais a serem aplicadas quando o modo de patch AutomaticByPlatform é selecionado nas configurações de patch do Windows.
|
WindowsVMGuestPatchMode
|
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
Manual - Você controla a aplicação de patches em uma máquina virtual. Para fazer isso, aplique patches manualmente dentro da VM. Neste modo, as atualizações automáticas são desativadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser false
AutomaticByOS - A máquina virtual será atualizada automaticamente pelo SO. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser true.
AutomaticByPlatform - a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser true
|
WinRMConfiguration
|
Descreve a configuração do Gerenciamento Remoto do Windows da VM
|
WinRMListener
|
Descreve o protocolo e a impressão digital do ouvinte do Gerenciamento Remoto do Windows
|
ZonalPlatformFaultDomainAlignMode
|
Especifica o modo de alinhamento entre a computação do Conjunto de Escala da Máquina Virtual e a contagem de Domínio de Falha de armazenamento.
|
AdditionalCapabilities
Habilita ou desabilita um recurso na máquina virtual ou no conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
hibernationEnabled
|
boolean
|
O sinalizador que habilita ou desabilita a capacidade de hibernação na VM.
|
ultraSSDEnabled
|
boolean
|
O sinalizador que habilita ou desabilita um recurso para ter um ou mais discos de dados gerenciados com UltraSSD_LRS tipo de conta de armazenamento na VM ou VMSS. Os discos gerenciados com UltraSSD_LRS tipo de conta de armazenamento podem ser adicionados a uma máquina virtual ou a um conjunto de dimensionamento de máquina virtual somente se essa propriedade estiver habilitada.
|
AdditionalUnattendContent
Especifica informações adicionais formatadas em XML que podem ser incluídas no arquivo Unattend.xml, que é usado pela Instalação do Windows. O conteúdo é definido definindo o nome, o nome do componente e a passagem na qual o conteúdo é aplicado.
Name |
Tipo |
Description |
componentName
|
ComponentNames
|
O nome do componente. Atualmente, o único valor permitido é Microsoft-Windows-Shell-Setup.
|
content
|
string
|
Especifica o conteúdo formatado em XML que é adicionado ao arquivo de unattend.xml para o caminho e o componente especificados. O XML deve ter menos de 4KB e deve incluir o elemento raiz para a configuração ou recurso que está sendo inserido.
|
passName
|
PassNames
|
O nome do passe. Atualmente, o único valor permitido é OobeSystem.
|
settingName
|
SettingNames
|
Especifica o nome da configuração à qual o conteúdo se aplica. Os valores possíveis são: FirstLogonCommands e AutoLogon.
|
AllocationStrategy
Especifica a estratégia de alocação para o conjunto de escala de máquina virtual com base no qual as VMs serão alocadas.
Name |
Tipo |
Description |
CapacityOptimized
|
string
|
|
LowestPrice
|
string
|
|
ApiEntityReference
A referência da entidade da API.
Name |
Tipo |
Description |
id
|
string
|
A ID do recurso ARM na forma de /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
|
ApiError
Erro de api.
Name |
Tipo |
Description |
code
|
string
|
O código de erro.
|
details
|
ApiErrorBase[]
|
Os detalhes do erro Api
|
innererror
|
InnerError
|
O erro interno da Api
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O alvo do erro específico.
|
ApiErrorBase
Base de erro da api.
Name |
Tipo |
Description |
code
|
string
|
O código de erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O alvo do erro específico.
|
ApplicationProfile
Contém a lista de aplicativos de galeria que devem ser disponibilizados para a VM/VMSS
Name |
Tipo |
Description |
galleryApplications
|
VMGalleryApplication[]
|
Especifica os aplicativos de galeria que devem ser disponibilizados para a VM/VMSS
|
AutomaticOSUpgradePolicy
Os parâmetros de configuração usados para executar a atualização automática do sistema operacional.
Name |
Tipo |
Description |
disableAutomaticRollback
|
boolean
|
Se o recurso de reversão de imagem do sistema operacional deve ser desativado. O valor padrão é false.
|
enableAutomaticOSUpgrade
|
boolean
|
Indica se as atualizações do sistema operacional devem ser aplicadas automaticamente para dimensionar instâncias do conjunto de forma contínua quando uma versão mais recente da imagem do sistema operacional estiver disponível. O valor padrão é false. Se isso for definido como true para conjuntos de escala baseados no Windows, enableAutomaticUpdates será automaticamente definido como false e não poderá ser definido como true.
|
osRollingUpgradeDeferral
|
boolean
|
Indica se a Atualização Automática do SO deve sofrer adiamento. As atualizações adiadas do sistema operacional enviarão notificações avançadas por VM de que uma atualização do sistema operacional de atualizações contínuas está chegando, por meio da tag IMDS 'Platform.PendingOSUpgrade'. Em seguida, a atualização é adiada até que seja aprovada por meio de uma chamada ApproveRollingUpgrade.
|
useRollingUpgradePolicy
|
boolean
|
Indica se a política de atualização contínua deve ser usada durante a Atualização Automática do SO. O valor padrão é false. A Atualização Automática do SO retornará à política padrão se nenhuma política for definida no VMSS.
|
AutomaticRepairsPolicy
Especifica os parâmetros de configuração para reparos automáticos no conjunto de escala da máquina virtual.
Name |
Tipo |
Description |
enabled
|
boolean
|
Especifica se os reparos automáticos devem ser habilitados no conjunto de dimensionamento da máquina virtual. O valor padrão é false.
|
gracePeriod
|
string
|
A quantidade de tempo durante a qual os reparos automáticos são suspensos devido a uma alteração de estado na VM. O tempo de carência começa após a conclusão da mudança de estado. Isto ajuda a evitar reparações prematuras ou acidentais. A duração do tempo deve ser especificada no formato ISO 8601. O período de carência mínimo permitido é de 10 minutos (PT10M), que também é o valor padrão. O período de carência máximo permitido é de 90 minutos (PT90M).
|
repairAction
|
RepairAction
|
Tipo de ação de reparo (substituir, reiniciar, recriar imagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de escala. O valor padrão é substituir.
|
BillingProfile
Especifica os detalhes relacionados à cobrança de uma VM ou VMSS spot do Azure. Versão api mínima: 2019-03-01.
Name |
Tipo |
Description |
maxPrice
|
number
|
Especifica o preço máximo que você está disposto a pagar por uma VM/VMSS spot do Azure. Este preço é em dólares americanos.
Esse preço será comparado com o preço spot atual do Azure para o tamanho da VM. Além disso, os preços são comparados no momento da criação/atualização do Azure Spot VM/VMSS e a operação só terá êxito se o maxPrice for maior do que o preço atual do Azure Spot.
O maxPrice também será usado para remover uma VM/VMSS spot do Azure se o preço atual do Azure Spot for além do maxPrice após a criação da VM/VMSS.
Os valores possíveis são:
- Qualquer valor decimal superior a zero. Exemplo: 0,01538
-1 – indica o preço padrão a ser up-to sob demanda.
Você pode definir maxPrice como -1 para indicar que a VM/VMSS spot do Azure não deve ser removida por motivos de preço. Além disso, o preço máximo padrão é -1 se não for fornecido por você.
Versão api mínima: 2019-03-01.
|
BootDiagnostics
O Diagnóstico de Inicialização é um recurso de depuração que permite visualizar a saída do console e a captura de tela para diagnosticar o status da VM. Você pode visualizar facilmente a saída do log do console. O Azure também permite que você veja uma captura de tela da VM do hipervisor.
Name |
Tipo |
Description |
enabled
|
boolean
|
Se o diagnóstico de inicialização deve ser habilitado na máquina virtual.
|
storageUri
|
string
|
Uri da conta de armazenamento a ser usada para colocar a saída do console e a captura de tela. Se storageUri não for especificado ao habilitar o diagnóstico de inicialização, o armazenamento gerenciado será usado.
|
CachingTypes
Especifica os requisitos de cache. Os valores possíveis são: None,ReadOnlyReadWrite. Os valores padrão são: Nenhum para armazenamento padrão. ReadOnly para armazenamento Premium.
Name |
Tipo |
Description |
None
|
string
|
|
ReadOnly
|
string
|
|
ReadWrite
|
string
|
|
CapacityReservationProfile
Os parâmetros de um Perfil de reserva de capacidade.
Name |
Tipo |
Description |
capacityReservationGroup
|
SubResource
|
Especifica a id de recurso do grupo de reserva de capacidade que deve ser usada para alocar a máquina virtual ou as instâncias vm do conjunto de escalas, desde que a capacidade suficiente tenha sido reservada. Consulte https://aka.ms/CapacityReservation para obter mais detalhes.
|
CloudError
Uma resposta de erro do serviço de computação.
Name |
Tipo |
Description |
error
|
ApiError
|
Erro de api.
|
ComponentNames
O nome do componente. Atualmente, o único valor permitido é Microsoft-Windows-Shell-Setup.
Name |
Tipo |
Description |
Microsoft-Windows-Shell-Setup
|
string
|
|
DeleteOptions
Especificar o que acontece com o IP público quando a VM é excluída
Name |
Tipo |
Description |
Delete
|
string
|
|
Detach
|
string
|
|
DiagnosticsProfile
Especifica o estado das configurações de diagnóstico de inicialização. Versão mínima da api: 2015-06-15.
Name |
Tipo |
Description |
bootDiagnostics
|
BootDiagnostics
|
O Diagnóstico de Inicialização é um recurso de depuração que permite visualizar a saída do console e a captura de tela para diagnosticar o status da VM.
NOTA: Se storageUri estiver sendo especificado, verifique se a conta de armazenamento está na mesma região e assinatura que a VM. Você pode visualizar facilmente a saída do log do console. O Azure também permite que você veja uma captura de tela da VM do hipervisor.
|
DiffDiskOptions
Especifica as configurações de disco efêmero para o disco do sistema operacional.
Name |
Tipo |
Description |
Local
|
string
|
|
DiffDiskPlacement
Especifica o posicionamento efêmero do disco do sistema operacional. Esta propriedade pode ser usada pelo usuário na solicitação para escolher o local, ou seja, disco de cache, disco de recurso ou espaço em disco nvme para provisionamento de disco do sistema operacional efêmero. Para obter mais informações sobre os requisitos de tamanho de disco do sistema operacional efêmero, consulte Requisitos de tamanho de disco do sistema operacional efêmero para VM do Windows no https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e VM do Linux no https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. Versão mínima da api para NvmeDisk: 2024-03-01.
Name |
Tipo |
Description |
CacheDisk
|
string
|
|
NvmeDisk
|
string
|
|
ResourceDisk
|
string
|
|
DiffDiskSettings
Descreve os parâmetros das configurações de disco efêmero que podem ser especificadas para o disco do sistema operacional.
Nota: As configurações de disco efêmero só podem ser especificadas para o disco gerenciado.
DiskControllerTypes
Name |
Tipo |
Description |
NVMe
|
string
|
|
SCSI
|
string
|
|
DiskCreateOptionTypes
Especifica como as máquinas virtuais no conjunto de escala devem ser criadas. O único valor permitido é: FromImage. Esse valor é usado quando você está usando uma imagem para criar a máquina virtual. Se você estiver usando uma imagem de plataforma, também usará o elemento imageReference descrito acima. Se você estiver usando uma imagem do marketplace, também usará o elemento de plano descrito anteriormente.
Name |
Tipo |
Description |
Attach
|
string
|
|
Copy
|
string
|
|
Empty
|
string
|
|
FromImage
|
string
|
|
Restore
|
string
|
|
DiskDeleteOptionTypes
Especifica se o disco do sistema operacional deve ser excluído ou desanexado após a exclusão do VMSS Flex (esse recurso está disponível apenas para VMSS com Flexible OrchestrationMode).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando o VMSS Flex VM for excluído.
Desanexar Se esse valor for usado, o disco do sistema operacional será retido depois que o VMSS Flex VM for excluído.
O valor padrão é definido como Excluir. Para um disco de sistema operacional efêmero, o valor padrão é definido como Delete. O usuário não pode alterar a opção de exclusão para Ephemeral OS Disk.
Name |
Tipo |
Description |
Delete
|
string
|
|
Detach
|
string
|
|
DiskEncryptionSetParameters
Descreve o parâmetro de id de recurso do conjunto de criptografia de disco gerenciado pelo cliente que pode ser especificado para o disco.
Nota: O ID do recurso do conjunto de criptografia de disco só pode ser especificado para o disco gerenciado. Consulte https://aka.ms/mdssewithcmkoverview para obter mais detalhes.
Name |
Tipo |
Description |
id
|
string
|
ID do recurso
|
DomainNameLabelScopeTypes
O escopo do rótulo de nome de domínio. A concatenação do rótulo de nome de domínio com hash gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice vm serão os rótulos de nome de domínio dos recursos de endereço PublicIPAddress que serão criados
Name |
Tipo |
Description |
NoReuse
|
string
|
|
ResourceGroupReuse
|
string
|
|
SubscriptionReuse
|
string
|
|
TenantReuse
|
string
|
|
EncryptionIdentity
Especifica a Identidade Gerenciada usada pelo ADE para obter o token de acesso para operações keyvault.
Name |
Tipo |
Description |
userAssignedIdentityResourceId
|
string
|
Especifica a ID de recurso ARM de uma das identidades de usuário associadas à VM.
|
EventGridAndResourceGraph
Especifica as configurações relacionadas a eventos agendados relacionados a eventGridAndResourceGraph.
Name |
Tipo |
Description |
enable
|
boolean
|
Especifica se a grade de eventos e o gráfico de recursos estão habilitados para configurações relacionadas a eventos agendados.
|
ExtendedLocation
O tipo complexo do local estendido.
Name |
Tipo |
Description |
name
|
string
|
O nome do local estendido.
|
type
|
ExtendedLocationTypes
|
O tipo de local estendido.
|
ExtendedLocationTypes
O tipo de local estendido.
Name |
Tipo |
Description |
EdgeZone
|
string
|
|
ImageReference
Especifica informações sobre a imagem a ser usada. Você pode especificar informações sobre imagens de plataforma, imagens de mercado ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, imagem de mercado ou imagem de máquina virtual, mas não é usado em outras operações de criação. NOTA: O editor e a oferta de referência de imagem só podem ser definidos quando cria o conjunto de escalas.
Name |
Tipo |
Description |
communityGalleryImageId
|
string
|
Especificada a id exclusiva da imagem da galeria da comunidade para implantação de vm. Isso pode ser obtido na chamada GET da galeria da galeria da comunidade.
|
exactVersion
|
string
|
Especifica em números decimais, a versão da imagem da plataforma ou da imagem do mercado usada para criar a máquina virtual. Este campo só de leitura difere de «versão», apenas se o valor especificado no campo «versão» for «mais recente».
|
id
|
string
|
ID do recurso
|
offer
|
string
|
Especifica a oferta da imagem da plataforma ou imagem do mercado usada para criar a máquina virtual.
|
publisher
|
string
|
A editora de imagens.
|
sharedGalleryImageId
|
string
|
Especificada a id exclusiva da imagem da galeria compartilhada para implantação de vm. Isso pode ser obtido na chamada GET da imagem compartilhada da galeria.
|
sku
|
string
|
A imagem SKU.
|
version
|
string
|
Especifica a versão da imagem da plataforma ou da imagem do marketplace usada para criar a máquina virtual. Os formatos permitidos são Major.Minor.Build ou 'mais recente'. Major, Minor e Build são números decimais. Especifique 'mais recente' para usar a versão mais recente de uma imagem disponível no momento da implantação. Mesmo se você usar 'mais recente', a imagem da VM não será atualizada automaticamente após o tempo de implantação, mesmo que uma nova versão fique disponível. Por favor, não use o campo 'versão' para a implantação da imagem da galeria, a imagem da galeria deve sempre usar o campo 'id' para implantação, para usar a versão 'mais recente' da imagem da galeria, basta definir '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' no campo 'id' sem entrada de versão.
|
InnerError
Detalhes do erro interno.
Name |
Tipo |
Description |
errordetail
|
string
|
A mensagem de erro interna ou despejo de exceção.
|
exceptiontype
|
string
|
O tipo de exceção.
|
IPVersion
Disponível a partir de Api-Version 2019-07-01, representa se a configuração ip específica é IPv4 ou IPv6. O padrão é considerado IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
Name |
Tipo |
Description |
IPv4
|
string
|
|
IPv6
|
string
|
|
KeyVaultSecretReference
Descreve uma referência ao segredo do Key Vault
Name |
Tipo |
Description |
secretUrl
|
string
|
O URL que faz referência a um segredo em um Cofre de Chaves.
|
sourceVault
|
SubResource
|
O URL relativo do Cofre da Chave que contém o segredo.
|
LinuxConfiguration
Especifica as configurações do sistema operacional Linux na máquina virtual. Para obter uma lista de distribuições Linux suportadas, consulte Linux on Azure-Endorsed Distributions.
Name |
Tipo |
Description |
disablePasswordAuthentication
|
boolean
|
Especifica se a autenticação de senha deve ser desabilitada.
|
enableVMAgentPlatformUpdates
|
boolean
|
Indica se as Atualizações da Plataforma VMAgent estão habilitadas para a máquina virtual Linux. O valor padrão é false.
|
patchSettings
|
LinuxPatchSettings
|
[Funcionalidade de pré-visualização] Especifica as configurações relacionadas ao Patch de convidado de VM no Linux.
|
provisionVMAgent
|
boolean
|
Indica se o agente de máquina virtual deve ser provisionado na máquina virtual. Quando essa propriedade não é especificada no corpo da solicitação, o comportamento padrão é defini-la como true. Isso garantirá que o Agente de VM seja instalado na VM para que as extensões possam ser adicionadas à VM posteriormente.
|
ssh
|
SshConfiguration
|
Especifica a configuração da chave ssh para um sistema operacional Linux.
|
LinuxPatchAssessmentMode
Especifica o modo de Avaliação de Patch de Convidado de VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
Name |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
LinuxPatchSettings
Especifica as configurações relacionadas ao Patch de convidado de VM no Linux.
Name |
Tipo |
Description |
assessmentMode
|
LinuxPatchAssessmentMode
|
Especifica o modo de Avaliação de Patch de Convidado de VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
|
automaticByPlatformSettings
|
LinuxVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais para o modo de patch AutomaticByPlatform no VM Guest Patching no Linux.
|
patchMode
|
LinuxVMGuestPatchMode
|
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
ImageDefault - A configuração de patch padrão da máquina virtual é usada.
AutomaticByPlatform - A máquina virtual será atualizada automaticamente pela plataforma. A provisão de propriedadeVMAgent deve ser true
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
Name |
Tipo |
Description |
Always
|
string
|
|
IfRequired
|
string
|
|
Never
|
string
|
|
Unknown
|
string
|
|
Especifica configurações adicionais a serem aplicadas quando o modo de patch AutomaticByPlatform é selecionado nas configurações de patch do Linux.
Name |
Tipo |
Description |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Permite que o cliente agende patches sem atualizações acidentais
|
rebootSetting
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
|
LinuxVMGuestPatchMode
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
ImageDefault - A configuração de patch padrão da máquina virtual é usada.
AutomaticByPlatform - A máquina virtual será atualizada automaticamente pela plataforma. A provisão de propriedadeVMAgent deve ser true
Name |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Mode
Especifica o modo em que o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não a impor o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo de Auditoria, enquanto no modo Enforce ele imporá o controle de acesso. O valor padrão é Enforce mode.
Name |
Tipo |
Description |
Audit
|
string
|
|
Enforce
|
string
|
|
NetworkApiVersion
especifica a versão da API Microsoft.Network usada ao criar recursos de rede nas Configurações de Interface de Rede para Conjunto de Dimensionamento de Máquina Virtual com modo de orquestração 'Flexível'
Name |
Tipo |
Description |
2020-11-01
|
string
|
|
NetworkInterfaceAuxiliaryMode
Especifica se o modo Auxiliar está habilitado para o recurso Interface de Rede.
Name |
Tipo |
Description |
AcceleratedConnections
|
string
|
|
Floating
|
string
|
|
None
|
string
|
|
NetworkInterfaceAuxiliarySku
Especifica se a sku Auxiliar está habilitada para o recurso Interface de Rede.
Name |
Tipo |
Description |
A1
|
string
|
|
A2
|
string
|
|
A4
|
string
|
|
A8
|
string
|
|
None
|
string
|
|
OperatingSystemTypes
Essa propriedade permite que você especifique o tipo do sistema operacional que está incluído no disco se estiver criando uma VM a partir da imagem do usuário ou de um VHD especializado. Os valores possíveis são: Windows,Linux.
Name |
Tipo |
Description |
Linux
|
string
|
|
Windows
|
string
|
|
OrchestrationMode
Especifica o modo de orquestração para o conjunto de escala da máquina virtual.
Name |
Tipo |
Description |
Flexible
|
string
|
|
Uniform
|
string
|
|
OSImageNotificationProfile
Name |
Tipo |
Description |
enable
|
boolean
|
Especifica se o evento Imagem do SO Agendada está ativado ou desativado.
|
notBeforeTimeout
|
string
|
Período de tempo em que uma máquina virtual que está sendo recriada ou que tem seu sistema operacional atualizado terá que aprovar potencialmente o evento agendado de imagem do sistema operacional antes que o evento seja aprovado automaticamente (tempo limite). A configuração é especificada no formato ISO 8601 e o valor deve ser de 15 minutos (PT15M)
|
PassNames
O nome do passe. Atualmente, o único valor permitido é OobeSystem.
Name |
Tipo |
Description |
OobeSystem
|
string
|
|
PatchSettings
Especifica as configurações relacionadas ao patch de convidado de VM no Windows.
Name |
Tipo |
Description |
assessmentMode
|
WindowsPatchAssessmentMode
|
Especifica o modo de avaliação de patch do convidado da VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
|
automaticByPlatformSettings
|
WindowsVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais para o modo de patch AutomaticByPlatform no VM Guest Patching no Windows.
|
enableHotpatching
|
boolean
|
Permite que os clientes corrijam suas VMs do Azure sem exigir uma reinicialização. Para enableHotpatching, o 'provisionVMAgent' deve ser definido como true e 'patchMode' deve ser definido como 'AutomaticByPlatform'.
|
patchMode
|
WindowsVMGuestPatchMode
|
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
Manual - Você controla a aplicação de patches em uma máquina virtual. Para fazer isso, aplique patches manualmente dentro da VM. Neste modo, as atualizações automáticas são desativadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser false
AutomaticByOS - A máquina virtual será atualizada automaticamente pelo SO. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser true.
AutomaticByPlatform - a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser true
|
Plan
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Este elemento é usado apenas para imagens do mercado. Antes de poder usar uma imagem de mercado de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que pretende utilizar e, em seguida, clique em Pretende implementar programaticamente, Introdução ->. Introduza todas as informações necessárias e, em seguida, clique em Guardar.
Name |
Tipo |
Description |
name
|
string
|
O ID do plano.
|
product
|
string
|
Especifica o produto da imagem do mercado. Este é o mesmo valor que Offer sob o elemento imageReference.
|
promotionCode
|
string
|
O código promocional.
|
publisher
|
string
|
O ID do editor.
|
PriorityMixPolicy
Especifica as divisões de destino para VMs de prioridade Spot e Regular dentro de um conjunto de escala com modo de orquestração flexível. Com essa propriedade, o cliente pode especificar o número base de VMs de prioridade regular criadas à medida que a instância flexível do VMSS se expande e a divisão entre VMs de prioridade Spot e Regular após esse destino base ter sido atingido.
Name |
Tipo |
Description |
baseRegularPriorityCount
|
integer
|
O número base de VMs de prioridade regular que serão criadas nessa escala definida à medida que ela se expande.
|
regularPriorityPercentageAboveBase
|
integer
|
A porcentagem de instâncias de VM, após a contagem de prioridade regular de base ter sido atingida, que devem usar prioridade regular.
|
ProtocolTypes
Especifica o protocolo do ouvinte do WinRM. Os valores possíveis são: httphttps.
Name |
Tipo |
Description |
Http
|
string
|
|
Https
|
string
|
|
ProxyAgentSettings
Especifica as configurações do ProxyAgent ao criar a máquina virtual. Versão mínima da api: 2023-09-01.
Name |
Tipo |
Description |
enabled
|
boolean
|
Especifica se o recurso ProxyAgent deve ser habilitado na máquina virtual ou no conjunto de dimensionamento da máquina virtual.
|
keyIncarnationId
|
integer
|
Aumentar o valor dessa propriedade permite que o usuário redefina a chave usada para proteger o canal de comunicação entre convidado e host.
|
mode
|
Mode
|
Especifica o modo em que o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não a impor o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo de Auditoria, enquanto no modo Enforce ele imporá o controle de acesso. O valor padrão é Enforce mode.
|
PublicIPAddressSku
Descreve o IP público Sku. Ele só pode ser definido com OrchestrationMode como flexível.
PublicIPAddressSkuName
Especificar nome de sku IP público
Name |
Tipo |
Description |
Basic
|
string
|
|
Standard
|
string
|
|
PublicIPAddressSkuTier
Especificar camada de sku IP público
Name |
Tipo |
Description |
Global
|
string
|
|
Regional
|
string
|
|
RepairAction
Tipo de ação de reparo (substituir, reiniciar, recriar imagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de escala. O valor padrão é substituir.
Name |
Tipo |
Description |
Reimage
|
string
|
|
Replace
|
string
|
|
Restart
|
string
|
|
ResiliencyPolicy
Descreve uma política de resiliência - resilientVMCreationPolicy e/ou resilientVMDeletionPolicy.
Name |
Tipo |
Description |
resilientVMCreationPolicy
|
ResilientVMCreationPolicy
|
Os parâmetros de configuração usados durante a execução da criação de VM resiliente.
|
resilientVMDeletionPolicy
|
ResilientVMDeletionPolicy
|
Os parâmetros de configuração usados ao executar a exclusão de VM resiliente.
|
ResilientVMCreationPolicy
Os parâmetros de configuração usados durante a execução da criação de VM resiliente.
Name |
Tipo |
Description |
enabled
|
boolean
|
Especifica se a criação de VM resiliente deve ser habilitada no conjunto de escala da máquina virtual. O valor padrão é false.
|
ResilientVMDeletionPolicy
Os parâmetros de configuração usados ao executar a exclusão de VM resiliente.
Name |
Tipo |
Description |
enabled
|
boolean
|
Especifica se a exclusão de VM resiliente deve ser habilitada no conjunto de dimensionamento da máquina virtual. O valor padrão é false.
|
ResourceIdentityType
O tipo de identidade usado para o conjunto de dimensionamento de máquina virtual. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades do conjunto de escala da máquina virtual.
Name |
Tipo |
Description |
None
|
string
|
|
SystemAssigned
|
string
|
|
SystemAssigned, UserAssigned
|
string
|
|
UserAssigned
|
string
|
|
RollingUpgradePolicy
Os parâmetros de configuração usados durante a execução de uma atualização contínua.
Name |
Tipo |
Description |
enableCrossZoneUpgrade
|
boolean
|
Permita que o VMSS ignore os limites AZ ao construir lotes de atualização. Leve em consideração o Domínio de Atualização e maxBatchInstancePercent para determinar o tamanho do lote.
|
maxBatchInstancePercent
|
integer
|
A porcentagem máxima do total de instâncias de máquina virtual que serão atualizadas simultaneamente pela atualização sem interrupção em um lote. Como isso é máximo, instâncias não íntegras em lotes anteriores ou futuros podem fazer com que a porcentagem de instâncias em um lote diminua para garantir maior confiabilidade. O valor padrão para esse parâmetro é 20%.
|
maxSurge
|
boolean
|
Crie novas máquinas virtuais para atualizar o conjunto de escala, em vez de atualizar as máquinas virtuais existentes. As máquinas virtuais existentes serão excluídas assim que as novas máquinas virtuais forem criadas para cada lote.
|
maxUnhealthyInstancePercent
|
integer
|
A porcentagem máxima do total de instâncias de máquina virtual no conjunto de escala que pode estar simultaneamente não íntegra, seja como resultado de ser atualizada ou por ser encontrada em um estado não íntegro pelas verificações de integridade da máquina virtual antes que a atualização contínua seja abortada. Esta restrição será verificada antes de iniciar qualquer lote. O valor padrão para esse parâmetro é 20%.
|
maxUnhealthyUpgradedInstancePercent
|
integer
|
A porcentagem máxima de instâncias de máquina virtual atualizadas que podem ser encontradas em um estado não íntegro. Essa verificação acontecerá depois que cada lote for atualizado. Se essa porcentagem for excedida, a atualização contínua será anulada. O valor padrão para esse parâmetro é 20%.
|
pauseTimeBetweenBatches
|
string
|
O tempo de espera entre a conclusão da atualização para todas as máquinas virtuais em um lote e o início do próximo lote. A duração do tempo deve ser especificada no formato ISO 8601. O valor padrão é 0 segundos (PT0S).
|
prioritizeUnhealthyInstances
|
boolean
|
Atualize todas as instâncias não íntegras em um conjunto de escala antes de quaisquer instâncias íntegras.
|
rollbackFailedInstancesOnPolicyBreach
|
boolean
|
Reversão de instâncias com falha para o modelo anterior se a política de Atualização Contínua for violada.
|
ScaleInPolicy
Descreve uma política de dimensionamento para um conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
forceDeletion
|
boolean
|
Essa propriedade permite especificar se as máquinas virtuais escolhidas para remoção precisam ser excluídas à força quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado. (Recurso na Pré-visualização)
|
rules
|
VirtualMachineScaleSetScaleInRules[]
|
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquina virtual.
Os valores possíveis são:
padrão Quando um conjunto de escala de máquina virtual é dimensionado, o conjunto de escala será primeiro balanceado entre zonas se for um conjunto de escala zonal. Em seguida, ele será balanceado entre Domínios de Falha na medida do possível. Dentro de cada Domínio de Falha, as máquinas virtuais escolhidas para remoção serão as mais recentes que não estão protegidas contra scale-in.
OldestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais antigas que não estão protegidas serão escolhidas para remoção.
NewestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais recentes que não estão protegidas serão escolhidas para remoção.
|
ScheduledEventsAdditionalPublishingTargets
Name |
Tipo |
Description |
eventGridAndResourceGraph
|
EventGridAndResourceGraph
|
Os parâmetros de configuração usados durante a criação da configuração de evento agendado eventGridAndResourceGraph.
|
ScheduledEventsPolicy
Especifica as configurações relacionadas a Redeploy, Reboot e ScheduledEventsAdditionalPublishingTargets Scheduled Event.
Name |
Tipo |
Description |
scheduledEventsAdditionalPublishingTargets
|
ScheduledEventsAdditionalPublishingTargets
|
Os parâmetros de configuração usados durante a publicação scheduledEventsAdditionalPublishingTargets.
|
userInitiatedReboot
|
UserInitiatedReboot
|
Os parâmetros de configuração usados durante a criação da configuração de evento agendado userInitiatedReboot.
|
userInitiatedRedeploy
|
UserInitiatedRedeploy
|
Os parâmetros de configuração usados durante a criação da configuração de evento agendado userInitiatedRedeploy.
|
ScheduledEventsProfile
Name |
Tipo |
Description |
osImageNotificationProfile
|
OSImageNotificationProfile
|
Especifica as configurações relacionadas ao Evento Agendado de Imagem do SO.
|
terminateNotificationProfile
|
TerminateNotificationProfile
|
Especifica as configurações relacionadas a Encerrar Evento Agendado.
|
securityEncryptionTypes
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado junto com o blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado do firmware no blob VMGuestState.
Nota: Ele pode ser definido apenas para VMs confidenciais.
Name |
Tipo |
Description |
DiskWithVMGuestState
|
string
|
|
NonPersistedTPM
|
string
|
|
VMGuestStateOnly
|
string
|
|
SecurityPostureReference
Especifica a postura de segurança a ser usada no conjunto de escalas. Versão mínima da api: 2023-03-01
Name |
Tipo |
Description |
excludeExtensions
|
string[]
|
A lista de nomes de extensão de máquina virtual a serem excluídos ao aplicar a postura de segurança.
|
id
|
string
|
O id de referência da postura de segurança na forma de /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest
|
isOverridable
|
boolean
|
Se a postura de segurança pode ser substituída pelo usuário.
|
SecurityProfile
Especifica as configurações de perfil de segurança para a máquina virtual ou o conjunto de dimensionamento da máquina virtual.
Name |
Tipo |
Description |
encryptionAtHost
|
boolean
|
Essa propriedade pode ser usada pelo usuário na solicitação para habilitar ou desabilitar a Criptografia de Host para a máquina virtual ou o conjunto de dimensionamento de máquina virtual. Isso habilitará a criptografia para todos os discos, incluindo o disco Resource/Temp no próprio host. O comportamento padrão é: A criptografia no host será desabilitada, a menos que essa propriedade seja definida como true para o recurso.
|
encryptionIdentity
|
EncryptionIdentity
|
Especifica a Identidade Gerenciada usada pelo ADE para obter o token de acesso para operações keyvault.
|
proxyAgentSettings
|
ProxyAgentSettings
|
Especifica as configurações do ProxyAgent ao criar a máquina virtual. Versão mínima da api: 2023-09-01.
|
securityType
|
SecurityTypes
|
Especifica o SecurityType da máquina virtual. Ele deve ser definido como qualquer valor especificado para habilitar UefiSettings. O comportamento padrão é: UefiSettings não será habilitado a menos que essa propriedade esteja definida.
|
uefiSettings
|
UefiSettings
|
Especifica as configurações de segurança, como inicialização segura e vTPM, usadas durante a criação da máquina virtual. Versão api mínima: 2020-12-01.
|
SecurityTypes
Especifica o SecurityType da máquina virtual. Ele deve ser definido como qualquer valor especificado para habilitar UefiSettings. O comportamento padrão é: UefiSettings não será habilitado a menos que essa propriedade esteja definida.
Name |
Tipo |
Description |
ConfidentialVM
|
string
|
|
TrustedLaunch
|
string
|
|
ServiceArtifactReference
Especifica a ID de referência do artefato de serviço usada para definir a mesma versão de imagem para todas as máquinas virtuais no conjunto de escala ao usar a versão de imagem 'mais recente'. Versão mínima api: 2022-11-01
Name |
Tipo |
Description |
id
|
string
|
A ID de referência do artefato de serviço na forma de /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}
|
SettingNames
Especifica o nome da configuração à qual o conteúdo se aplica. Os valores possíveis são: FirstLogonCommands e AutoLogon.
Name |
Tipo |
Description |
AutoLogon
|
string
|
|
FirstLogonCommands
|
string
|
|
Sku
Descreve um sku de conjunto de escala de máquina virtual. NOTA: Se a nova SKU de VM não for suportada no hardware em que o conjunto de escala está atualmente, você precisará desalocar as VMs no conjunto de escala antes de modificar o nome da SKU.
Name |
Tipo |
Description |
capacity
|
integer
|
Especifica o número de máquinas virtuais no conjunto de escala.
|
name
|
string
|
O nome do sku.
|
tier
|
string
|
Especifica a camada de máquinas virtuais em um conjunto de escala.
Valores possíveis:
Standard
Básico
|
SkuProfile
Especifica o perfil de sku para o conjunto de escala de máquina virtual. Com essa propriedade, o cliente pode especificar uma lista de tamanhos de VM e uma estratégia de alocação.
Name |
Tipo |
Description |
allocationStrategy
|
AllocationStrategy
|
Especifica a estratégia de alocação para o conjunto de escala de máquina virtual com base no qual as VMs serão alocadas.
|
vmSizes
|
SkuProfileVMSize[]
|
Especifica os tamanhos de VM para o conjunto de escala de máquina virtual.
|
SkuProfileVMSize
Especifica o tamanho da VM.
Name |
Tipo |
Description |
name
|
string
|
Especifica o nome do Tamanho da VM.
|
SpotRestorePolicy
Especifica as propriedades Spot-Try-Restore para o conjunto de escala da máquina virtual. Com essa propriedade, o cliente pode habilitar ou desabilitar a restauração automática das instâncias de VM spot removidas oportunisticamente com base na disponibilidade de capacidade e na restrição de preços.
Name |
Tipo |
Description |
enabled
|
boolean
|
Habilita o recurso Spot-Try-Restore em que instâncias VMSS SPOT removidas serão tentadas para serem restauradas oportunisticamente com base na disponibilidade de capacidade e restrições de preços
|
restoreTimeout
|
string
|
Valor de tempo limite expresso como uma duração de tempo ISO 8601 após o qual a plataforma não tentará restaurar as instâncias SPOT do VMSS
|
SshConfiguration
Configuração SSH para VMs baseadas em Linux em execução no Azure
Name |
Tipo |
Description |
publicKeys
|
SshPublicKey[]
|
A lista de chaves públicas SSH usadas para autenticar com VMs baseadas em linux.
|
SshPublicKey
Contém informações sobre a chave pública do certificado SSH e o caminho na VM Linux onde a chave pública é colocada.
Name |
Tipo |
Description |
keyData
|
string
|
Certificado de chave pública SSH usado para autenticar com a VM através do ssh. A chave precisa ser de pelo menos 2048 bits e no formato ssh-rsa. Para criar chaves ssh, consulte [Criar chaves SSH no Linux e Mac para VMs Linux no Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed).
|
path
|
string
|
Especifica o caminho completo na VM criada onde a chave pública ssh é armazenada. Se o arquivo já existir, a chave especificada será anexada ao arquivo. Exemplo: /home/user/.ssh/authorized_keys
|
StorageAccountTypes
Especifica o tipo de conta de armazenamento para o disco gerenciado. NOTA: UltraSSD_LRS só pode ser utilizado com discos de dados, não pode ser utilizado com o OS Disk.
Name |
Tipo |
Description |
PremiumV2_LRS
|
string
|
|
Premium_LRS
|
string
|
|
Premium_ZRS
|
string
|
|
StandardSSD_LRS
|
string
|
|
StandardSSD_ZRS
|
string
|
|
Standard_LRS
|
string
|
|
UltraSSD_LRS
|
string
|
|
SubResource
Name |
Tipo |
Description |
id
|
string
|
ID do recurso
|
TerminateNotificationProfile
Name |
Tipo |
Description |
enable
|
boolean
|
Especifica se o evento Encerrar agendado está habilitado ou desabilitado.
|
notBeforeTimeout
|
string
|
O período de tempo configurável que uma Máquina Virtual que está sendo excluída terá que aprovar potencialmente o Evento Agendado de Término antes que o evento seja aprovado automaticamente (tempo limite). A configuração deve ser especificada no formato ISO 8601, o valor padrão é 5 minutos (PT5M)
|
UefiSettings
Especifica as configurações de segurança, como inicialização segura e vTPM, usadas durante a criação da máquina virtual. Versão api mínima: 2020-12-01.
Name |
Tipo |
Description |
secureBootEnabled
|
boolean
|
Especifica se a inicialização segura deve ser habilitada na máquina virtual. Versão api mínima: 2020-12-01.
|
vTpmEnabled
|
boolean
|
Especifica se o vTPM deve ser habilitado na máquina virtual. Versão api mínima: 2020-12-01.
|
UpgradeMode
Especifica o modo de uma atualização para máquinas virtuais no conjunto de escala.
Os valores possíveis são:
Manual - Você controla a aplicação de atualizações para máquinas virtuais no conjunto de escala. Para fazer isso, use a ação manualUpgrade.
automático - Todas as máquinas virtuais no conjunto de escala são atualizadas automaticamente ao mesmo tempo.
Name |
Tipo |
Description |
Automatic
|
string
|
|
Manual
|
string
|
|
Rolling
|
string
|
|
UpgradePolicy
Descreve uma política de atualização - automática, manual ou rolante.
Name |
Tipo |
Description |
automaticOSUpgradePolicy
|
AutomaticOSUpgradePolicy
|
Parâmetros de configuração usados para executar a atualização automática do sistema operacional.
|
mode
|
UpgradeMode
|
Especifica o modo de uma atualização para máquinas virtuais no conjunto de escala.
Os valores possíveis são:
Manual - Você controla a aplicação de atualizações para máquinas virtuais no conjunto de escala. Para fazer isso, use a ação manualUpgrade.
automático - Todas as máquinas virtuais no conjunto de escala são atualizadas automaticamente ao mesmo tempo.
|
rollingUpgradePolicy
|
RollingUpgradePolicy
|
Os parâmetros de configuração usados durante a execução de uma atualização contínua.
|
UserAssignedIdentities
A lista de identidades de usuário associadas à máquina virtual. As referências de chave do dicionário de identidade do usuário serão ids de recurso ARM no formato: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
UserInitiatedReboot
Especifica as configurações relacionadas a Eventos Agendados relacionados à Reinicialização.
Name |
Tipo |
Description |
automaticallyApprove
|
boolean
|
Especifica as configurações relacionadas ao Evento Agendado de Reinicialização.
|
UserInitiatedRedeploy
Especifica Reimplantar configurações relacionadas a Eventos Agendados relacionados.
Name |
Tipo |
Description |
automaticallyApprove
|
boolean
|
Especifica as configurações relacionadas a Reimplantar Evento Agendado.
|
VaultCertificate
Descreve uma única referência de certificado em um Cofre de Chaves e onde o certificado deve residir na VM.
Name |
Tipo |
Description |
certificateStore
|
string
|
Para VMs do Windows, especifica o armazenamento de certificados na Máquina Virtual ao qual o certificado deve ser adicionado. O armazenamento de certificados especificado está implicitamente na conta LocalMachine. Para VMs Linux, o arquivo de certificado é colocado no diretório /var/lib/waagent, com o nome do arquivo <UppercaseThumbprint>.crt para o arquivo de certificado X509 e <UppercaseThumbprint>.prv para chave privada. Ambos os arquivos são .pem formatado.
|
certificateUrl
|
string
|
Este é o URL de um certificado que foi carregado para o Cofre da Chave como um segredo. Para adicionar um segredo ao Cofre de Chaves, consulte Adicionar uma chave ou segredo ao Cofre de Chaves. Nesse caso, seu certificado precisa ser É a codificação Base64 do seguinte objeto JSON que é codificado em UTF-8:
{ "dados":"", "dataType":"pfx", "senha":"" } Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual do Azure Key Vault para Linux ou a extensão de máquina virtual do Azure Key Vault para Windows.
|
VaultSecretGroup
Descreve um conjunto de certificados que estão todos no mesmo Cofre de Chaves.
Name |
Tipo |
Description |
sourceVault
|
SubResource
|
A URL relativa do Cofre da Chave que contém todos os certificados em VaultCertificates.
|
vaultCertificates
|
VaultCertificate[]
|
A lista de referências do cofre de chaves no SourceVault que contêm certificados.
|
VirtualHardDisk
Descreve o uri de um disco.
Name |
Tipo |
Description |
uri
|
string
|
Especifica o uri do disco rígido virtual.
|
VirtualMachineEvictionPolicyTypes
Especifica a política de remoção para a máquina virtual do Azure Spot e o conjunto de escala do Azure Spot. Para máquinas virtuais do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2019-03-01. Para conjuntos de escala do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2017-10-30-preview.
Name |
Tipo |
Description |
Deallocate
|
string
|
|
Delete
|
string
|
|
VirtualMachinePriorityTypes
Especifica a prioridade para as máquinas virtuais no conjunto de escala. Versão mínima da api: 2017-10-30-preview.
Name |
Tipo |
Description |
Low
|
string
|
|
Regular
|
string
|
|
Spot
|
string
|
|
VirtualMachineScaleSet
Descreve um conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
etag
|
string
|
Etag é a propriedade retornada em Create/Update/Get response do VMSS, para que o cliente possa fornecê-la no cabeçalho para garantir atualizações otimistas
|
extendedLocation
|
ExtendedLocation
|
O local estendido do Conjunto de Dimensionamento de Máquina Virtual.
|
id
|
string
|
ID do recurso
|
identity
|
VirtualMachineScaleSetIdentity
|
A identidade do conjunto de dimensionamento da máquina virtual, se configurado.
|
location
|
string
|
Localização do recurso
|
name
|
string
|
Nome do recurso
|
plan
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Este elemento é usado apenas para imagens do mercado. Antes de poder usar uma imagem de mercado de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que pretende utilizar e, em seguida, clique em Pretende implementar programaticamente, Introdução ->. Introduza todas as informações necessárias e, em seguida, clique em Guardar.
|
properties.additionalCapabilities
|
AdditionalCapabilities
|
Especifica recursos adicionais habilitados ou desabilitados nas Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais. Por exemplo: se as Máquinas Virtuais têm a capacidade de suportar a anexação de discos de dados gerenciados com UltraSSD_LRS tipo de conta de armazenamento.
|
properties.automaticRepairsPolicy
|
AutomaticRepairsPolicy
|
Política para reparações automáticas.
|
properties.constrainedMaximumCapacity
|
boolean
|
Propriedade opcional que deve ser definida como True ou omitida.
|
properties.doNotRunExtensionsOnOverprovisionedVMs
|
boolean
|
Quando o Overprovision está habilitado, as extensões são iniciadas somente no número solicitado de VMs que são finalmente mantidas. Portanto, essa propriedade garantirá que as extensões não sejam executadas nas VMs extras superprovisionadas.
|
properties.hostGroup
|
SubResource
|
Especifica informações sobre o grupo de hosts dedicados no qual o conjunto de dimensionamento de máquina virtual reside. Versão api mínima: 2020-06-01.
|
properties.orchestrationMode
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de escala da máquina virtual.
|
properties.overprovision
|
boolean
|
Especifica se o Conjunto de Dimensionamento de Máquina Virtual deve ser provisionado em excesso.
|
properties.platformFaultDomainCount
|
integer
|
Contagem de domínio de falha para cada grupo de posicionamento.
|
properties.priorityMixPolicy
|
PriorityMixPolicy
|
Especifica os destinos desejados para misturar VMs de prioridade Spot e Regular na mesma instância do VMSS Flex.
|
properties.provisioningState
|
string
|
O estado de provisionamento, que só aparece na resposta.
|
properties.proximityPlacementGroup
|
SubResource
|
Especifica informações sobre o grupo de posicionamento de proximidade ao qual o conjunto de dimensionamento de máquina virtual deve ser atribuído. Versão api mínima: 2018-04-01.
|
properties.resiliencyPolicy
|
ResiliencyPolicy
|
Política de Resiliência
|
properties.scaleInPolicy
|
ScaleInPolicy
|
Especifica as políticas aplicadas ao dimensionar em Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais.
|
properties.scheduledEventsPolicy
|
ScheduledEventsPolicy
|
O ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
boolean
|
Quando verdadeiro, isso limita a escala definida a um único grupo de posicionamento, de tamanho máximo de 100 máquinas virtuais. Observação : se singlePlacementGroup for true, ele pode ser modificado para false. No entanto, se singlePlacementGroup for false, ele não pode ser modificado para true.
|
properties.skuProfile
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de escala de máquina virtual.
|
properties.spotRestorePolicy
|
SpotRestorePolicy
|
Especifica as propriedades de Restauração Local para o conjunto de escala da máquina virtual.
|
properties.timeCreated
|
string
|
Especifica a hora em que o recurso Conjunto de Escala de Máquina Virtual foi criado. Versão mínima api: 2021-11-01.
|
properties.uniqueId
|
string
|
Especifica a ID que identifica exclusivamente um Conjunto de Escala de Máquina Virtual.
|
properties.upgradePolicy
|
UpgradePolicy
|
A política de atualização.
|
properties.virtualMachineProfile
|
VirtualMachineScaleSetVMProfile
|
O perfil da máquina virtual.
|
properties.zonalPlatformFaultDomainAlignMode
|
ZonalPlatformFaultDomainAlignMode
|
Especifica o modo de alinhamento entre a computação do Conjunto de Escala da Máquina Virtual e a contagem de Domínio de Falha de armazenamento.
|
properties.zoneBalance
|
boolean
|
Se deve forçar estritamente mesmo a distribuição da Máquina Virtual entre zonas x no caso de haver interrupção de zona. A propriedade zoneBalance só pode ser definida se a propriedade zones do conjunto de escala contiver mais de uma zona. Se não houver zonas ou apenas uma zona especificada, a propriedade zoneBalance não deverá ser definida.
|
sku
|
Sku
|
O sku do conjunto de escala da máquina virtual.
|
tags
|
object
|
Tags de recursos
|
type
|
string
|
Tipo de recurso
|
zones
|
string[]
|
As zonas do conjunto de dimensionamento da máquina virtual.
|
VirtualMachineScaleSetDataDisk
Descreve um disco de dados do conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
caching
|
CachingTypes
|
Especifica os requisitos de cache. Os valores possíveis são: None,ReadOnlyReadWrite. Os valores padrão são: Nenhum para armazenamento padrão. ReadOnly para armazenamento Premium.
|
createOption
|
DiskCreateOptionTypes
|
A opção criar.
|
deleteOption
|
DiskDeleteOptionTypes
|
Especifica se o disco de dados deve ser excluído ou desanexado após a exclusão do VMSS Flex (esse recurso está disponível apenas para VMSS com Flexible OrchestrationMode).
Valores possíveis:
Excluir Se esse valor for usado, o disco de dados será excluído quando a VM VMSS Flex for excluída.
Desanexar Se esse valor for usado, o disco de dados será retido depois que o VMSS Flex VM for excluído.
O valor padrão é definido como Excluir.
|
diskIOPSReadWrite
|
integer
|
Especifica o IOPS Read-Write para o disco gerenciado. Deve ser usado somente quando StorageAccountType é UltraSSD_LRS. Se não for especificado, um valor padrão será atribuído com base em diskSizeGB.
|
diskMBpsReadWrite
|
integer
|
Especifica a largura de banda em MB por segundo para o disco gerenciado. Deve ser usado somente quando StorageAccountType é UltraSSD_LRS. Se não for especificado, um valor padrão será atribuído com base em diskSizeGB.
|
diskSizeGB
|
integer
|
Especifica o tamanho de um disco de dados vazio em gigabytes. Esse elemento pode ser usado para substituir o tamanho do disco em uma imagem de máquina virtual. A propriedade diskSizeGB é o número de bytes x 1024^3 para o disco e o valor não pode ser maior que 1023.
|
lun
|
integer
|
Especifica o número da unidade lógica do disco de dados. Esse valor é usado para identificar discos de dados dentro da VM e, portanto, deve ser exclusivo para cada disco de dados conectado a uma VM.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Os parâmetros do disco gerenciado.
|
name
|
string
|
O nome do disco.
|
writeAcceleratorEnabled
|
boolean
|
Especifica se writeAccelerator deve ser habilitado ou desabilitado no disco.
|
VirtualMachineScaleSetExtension
Descreve uma extensão de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
id
|
string
|
ID do recurso
|
name
|
string
|
O nome da extensão.
|
properties.autoUpgradeMinorVersion
|
boolean
|
Indica se a extensão deve usar uma versão secundária mais recente, se uma estiver disponível no momento da implantação. Uma vez implantada, no entanto, a extensão não atualizará versões secundárias, a menos que seja reimplantada, mesmo com essa propriedade definida como true.
|
properties.enableAutomaticUpgrade
|
boolean
|
Indica se a extensão deve ser atualizada automaticamente pela plataforma se houver uma versão mais recente da extensão disponível.
|
properties.forceUpdateTag
|
string
|
Se um valor for fornecido e for diferente do valor anterior, o manipulador de extensão será forçado a atualizar mesmo que a configuração da extensão não tenha sido alterada.
|
properties.protectedSettings
|
object
|
A extensão pode conter protectedSettings ou protectedSettingsFromKeyVault ou nenhuma configuração protegida.
|
properties.protectedSettingsFromKeyVault
|
KeyVaultSecretReference
|
As extensões protegem as configurações que são passadas por referência e consumidas do cofre de chaves
|
properties.provisionAfterExtensions
|
string[]
|
Coleção de nomes de extensão após a qual essa extensão precisa ser provisionada.
|
properties.provisioningState
|
string
|
O estado de provisionamento, que só aparece na resposta.
|
properties.publisher
|
string
|
O nome do editor do manipulador de extensão.
|
properties.settings
|
object
|
Json formatou configurações públicas para a extensão.
|
properties.suppressFailures
|
boolean
|
Indica se as falhas decorrentes da extensão serão suprimidas (Falhas operacionais, como não se conectar à VM, não serão suprimidas, independentemente desse valor). O padrão é false.
|
properties.type
|
string
|
Especifica o tipo da extensão; um exemplo é "CustomScriptExtension".
|
properties.typeHandlerVersion
|
string
|
Especifica a versão do manipulador de script.
|
type
|
string
|
Tipo de recurso
|
VirtualMachineScaleSetExtensionProfile
Descreve um perfil de extensão de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
extensions
|
VirtualMachineScaleSetExtension[]
|
A escala da máquina virtual define recursos de extensão filho.
|
extensionsTimeBudget
|
string
|
Especifica o tempo alocado para o início de todas as extensões. A duração do tempo deve ser entre 15 minutos e 120 minutos (inclusive) e deve ser especificada no formato ISO 8601. O valor padrão é 90 minutos (PT1H30M). Versão api mínima: 2020-06-01.
|
VirtualMachineScaleSetHardwareProfile
Especifica as configurações de hardware para o conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
vmSizeProperties
|
VMSizeProperties
|
Especifica as propriedades para personalizar o tamanho da máquina virtual. Versão mínima api: 2021-11-01. Siga as instruções em de personalização de VM para obter mais detalhes.
|
VirtualMachineScaleSetIdentity
Identidade para o conjunto de escala da máquina virtual.
Name |
Tipo |
Description |
principalId
|
string
|
A id principal da identidade do conjunto de escala da máquina virtual. Esta propriedade só será fornecida para uma identidade atribuída ao sistema.
|
tenantId
|
string
|
A id do locatário associada ao conjunto de dimensionamento da máquina virtual. Esta propriedade só será fornecida para uma identidade atribuída ao sistema.
|
type
|
ResourceIdentityType
|
O tipo de identidade usado para o conjunto de dimensionamento de máquina virtual. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'Nenhum' removerá todas as identidades do conjunto de escala da máquina virtual.
|
userAssignedIdentities
|
UserAssignedIdentities
|
A lista de identidades de usuário associadas ao conjunto de dimensionamento de máquina virtual. As referências de chave do dicionário de identidade do usuário serão ids de recurso ARM no formato: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
VirtualMachineScaleSetIPConfiguration
Descreve a configuração IP do perfil de rede de um conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
name
|
string
|
O nome da configuração IP.
|
properties.applicationGatewayBackendAddressPools
|
SubResource[]
|
Especifica uma matriz de referências a pools de endereços de back-end de gateways de aplicativos. Um conjunto de dimensionamento pode fazer referência a pools de endereços de back-end de vários gateways de aplicativos. Vários conjuntos de escala não podem usar o mesmo gateway de aplicativo.
|
properties.applicationSecurityGroups
|
SubResource[]
|
Especifica uma matriz de referências ao grupo de segurança do aplicativo.
|
properties.loadBalancerBackendAddressPools
|
SubResource[]
|
Especifica uma matriz de referências a pools de endereços de back-end de balanceadores de carga. Um conjunto de dimensionamento pode fazer referência a pools de endereços de back-end de um balanceador de carga público e interno. Vários conjuntos de escala não podem usar o mesmo balanceador de carga de sku básico.
|
properties.loadBalancerInboundNatPools
|
SubResource[]
|
Especifica uma matriz de referências a pools Nat de entrada dos balanceadores de carga. Um conjunto de escalas pode fazer referência a pools de nat de entrada de um balanceador de carga público e interno. Vários conjuntos de escala não podem usar o mesmo balanceador de carga de sku básico.
|
properties.primary
|
boolean
|
Especifica a interface de rede primária caso a máquina virtual tenha mais de 1 interface de rede.
|
properties.privateIPAddressVersion
|
IPVersion
|
Disponível a partir de 30-03-Api-Version 2017, representa se a configuração ip específica é IPv4 ou IPv6. O padrão é considerado IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
|
properties.publicIPAddressConfiguration
|
VirtualMachineScaleSetPublicIPAddressConfiguration
|
O publicIPAddressConfiguration.
|
properties.subnet
|
ApiEntityReference
|
Especifica o identificador da sub-rede.
|
VirtualMachineScaleSetIpTag
Contém a marca IP associada ao endereço IP público.
Name |
Tipo |
Description |
ipTagType
|
string
|
Tipo de tag IP. Exemplo: FirstPartyUsage.
|
tag
|
string
|
IP associada ao IP público. Exemplo: SQL, Storage etc.
|
VirtualMachineScaleSetManagedDiskParameters
Descreve os parâmetros de um disco gerenciado ScaleSet.
Name |
Tipo |
Description |
diskEncryptionSet
|
DiskEncryptionSetParameters
|
Especifica a id do recurso do conjunto de criptografia de disco gerenciado pelo cliente para o disco gerenciado.
|
securityProfile
|
VMDiskSecurityProfile
|
Especifica o perfil de segurança para o disco gerenciado.
|
storageAccountType
|
StorageAccountTypes
|
Especifica o tipo de conta de armazenamento para o disco gerenciado. NOTA: UltraSSD_LRS só pode ser utilizado com discos de dados, não pode ser utilizado com o OS Disk.
|
VirtualMachineScaleSetNetworkConfiguration
Descreve as configurações de rede de um perfil de rede do conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
name
|
string
|
O nome da configuração de rede.
|
properties.auxiliaryMode
|
NetworkInterfaceAuxiliaryMode
|
Especifica se o modo Auxiliar está habilitado para o recurso Interface de Rede.
|
properties.auxiliarySku
|
NetworkInterfaceAuxiliarySku
|
Especifica se a sku Auxiliar está habilitada para o recurso Interface de Rede.
|
properties.deleteOption
|
DeleteOptions
|
Especificar o que acontece com a interface de rede quando a VM é excluída
|
properties.disableTcpStateTracking
|
boolean
|
Especifica se a interface de rede está desabilitada para rastreamento de estado tcp.
|
properties.dnsSettings
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
As configurações de dns a serem aplicadas nas interfaces de rede.
|
properties.enableAcceleratedNetworking
|
boolean
|
Especifica se a interface de rede é habilitada para rede acelerada.
|
properties.enableFpga
|
boolean
|
Especifica se a interface de rede é habilitada para rede FPGA.
|
properties.enableIPForwarding
|
boolean
|
Se o encaminhamento IP está habilitado nesta NIC.
|
properties.ipConfigurations
|
VirtualMachineScaleSetIPConfiguration[]
|
Especifica as configurações IP da interface de rede.
|
properties.networkSecurityGroup
|
SubResource
|
O grupo de segurança de rede.
|
properties.primary
|
boolean
|
Especifica a interface de rede primária caso a máquina virtual tenha mais de 1 interface de rede.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
Descreve uma escala de máquinas virtuais que define as configurações de DNS da rede.
Name |
Tipo |
Description |
dnsServers
|
string[]
|
Lista de endereços IP de servidores DNS
|
VirtualMachineScaleSetNetworkProfile
Descreve um perfil de rede de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
healthProbe
|
ApiEntityReference
|
Uma referência a uma sonda de balanceador de carga usada para determinar a integridade de uma instância no conjunto de escala de máquina virtual. A referência será no formato: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'.
|
networkApiVersion
|
NetworkApiVersion
|
especifica a versão da API Microsoft.Network usada ao criar recursos de rede nas Configurações de Interface de Rede para Conjunto de Dimensionamento de Máquina Virtual com modo de orquestração 'Flexível'
|
networkInterfaceConfigurations
|
VirtualMachineScaleSetNetworkConfiguration[]
|
A lista de configurações de rede.
|
VirtualMachineScaleSetOSDisk
Descreve um disco do sistema operacional do conjunto de dimensionamento de máquina virtual.
Name |
Tipo |
Description |
caching
|
CachingTypes
|
Especifica os requisitos de cache. Os valores possíveis são: None,ReadOnlyReadWrite. Os valores padrão são: Nenhum para armazenamento padrão. ReadOnly para armazenamento Premium.
|
createOption
|
DiskCreateOptionTypes
|
Especifica como as máquinas virtuais no conjunto de escala devem ser criadas. O único valor permitido é: FromImage. Esse valor é usado quando você está usando uma imagem para criar a máquina virtual. Se você estiver usando uma imagem de plataforma, também usará o elemento imageReference descrito acima. Se você estiver usando uma imagem do marketplace, também usará o elemento de plano descrito anteriormente.
|
deleteOption
|
DiskDeleteOptionTypes
|
Especifica se o disco do sistema operacional deve ser excluído ou desanexado após a exclusão do VMSS Flex (esse recurso está disponível apenas para VMSS com Flexible OrchestrationMode).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando o VMSS Flex VM for excluído.
Desanexar Se esse valor for usado, o disco do sistema operacional será retido depois que o VMSS Flex VM for excluído.
O valor padrão é definido como Excluir. Para um disco de sistema operacional efêmero, o valor padrão é definido como Delete. O usuário não pode alterar a opção de exclusão para Ephemeral OS Disk.
|
diffDiskSettings
|
DiffDiskSettings
|
Especifica as configurações de disco efêmero para o disco do sistema operacional usado pelo conjunto de escala da máquina virtual.
|
diskSizeGB
|
integer
|
Especifica o tamanho de um disco de dados vazio em gigabytes. Esse elemento pode ser usado para substituir o tamanho do disco em uma imagem de máquina virtual. A propriedade 'diskSizeGB' é o número de bytes x 1024^3 para o disco e o valor não pode ser maior que 1023.
|
image
|
VirtualHardDisk
|
Especifica informações sobre a imagem do usuário não gerenciado para basear a escala definida.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Os parâmetros do disco gerenciado.
|
name
|
string
|
O nome do disco.
|
osType
|
OperatingSystemTypes
|
Essa propriedade permite que você especifique o tipo do sistema operacional que está incluído no disco se estiver criando uma VM a partir da imagem do usuário ou de um VHD especializado. Os valores possíveis são: Windows,Linux.
|
vhdContainers
|
string[]
|
Especifica as urls de contêiner que são usadas para armazenar discos do sistema operacional para o conjunto de escala.
|
writeAcceleratorEnabled
|
boolean
|
Especifica se writeAccelerator deve ser habilitado ou desabilitado no disco.
|
VirtualMachineScaleSetOSProfile
Descreve um perfil de sistema operacional de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
adminPassword
|
string
|
Especifica a senha da conta de administrador.
Comprimento mínimo (Windows): 8 caracteres
Comprimento mínimo (Linux): 6 caracteres
Max-length (Windows): 123 caracteres
Max-length (Linux): 72 caracteres
Requisitos de complexidade: 3 das 4 condições abaixo precisam ser cumpridas Tem caracteres mais baixos Tem caracteres superiores Tem um dígito Tem um caractere especial (Regex match [\W_])
Valores não permitidos: "abc@123", "P@$$w 0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
Para redefinir a senha, consulte Como redefinir o serviço de Área de Trabalho Remota ou sua senha de login em uma VM do Windows
Para redefinir a senha de root, consulte Gerenciar usuários, SSH e verificar ou reparar discos em VMs Linux do Azure usando a Extensão VMAccess
|
adminUsername
|
string
|
Especifica o nome da conta de administrador.
Restrição somente para Windows: Não pode terminar em "."
Valores não permitidos: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5".
Comprimento mínimo (Linux): 1 caractere
Max-length (Linux): 64 caracteres
Max-length (Windows): 20 caracteres
|
allowExtensionOperations
|
boolean
|
Especifica se as operações de extensão devem ser permitidas no conjunto de escala da máquina virtual. Isso só pode ser definido como Falso quando nenhuma extensão estiver presente no conjunto de escala da máquina virtual.
|
computerNamePrefix
|
string
|
Especifica o prefixo do nome do computador para todas as máquinas virtuais no conjunto de escala. Os prefixos de nome de computador devem ter de 1 a 15 caracteres.
|
customData
|
string
|
Especifica uma cadeia de caracteres codificada em base 64 de dados personalizados. A cadeia de caracteres codificada em base 64 é decodificada para uma matriz binária que é salva como um arquivo na máquina virtual. O comprimento máximo da matriz binária é de 65535 bytes. Para usar o cloud-init para sua VM, consulte Usando cloud-init para personalizar uma VM Linux durante a criação
|
linuxConfiguration
|
LinuxConfiguration
|
Especifica as configurações do sistema operacional Linux na máquina virtual. Para obter uma lista de distribuições Linux suportadas, consulte Linux on Azure-Endorsed Distributions.
|
requireGuestProvisionSignal
|
boolean
|
Propriedade opcional que deve ser definida como True ou omitida.
|
secrets
|
VaultSecretGroup[]
|
Especifica o conjunto de certificados que devem ser instalados nas máquinas virtuais no conjunto de escala. Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual do Azure Key Vault para Linux ou a extensão de máquina virtual do Azure Key Vault para Windows.
|
windowsConfiguration
|
WindowsConfiguration
|
Especifica as configurações do sistema operacional Windows na máquina virtual.
|
VirtualMachineScaleSetPublicIPAddressConfiguration
Descreve um conjunto de dimensionamento de máquinas virtuais Configuração IP da configuração PublicIPAddress
Name |
Tipo |
Description |
name
|
string
|
O nome de configuração do endereço IP público.
|
properties.deleteOption
|
DeleteOptions
|
Especificar o que acontece com o IP público quando a VM é excluída
|
properties.dnsSettings
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
|
As configurações de dns a serem aplicadas nos endereços IP públicos.
|
properties.idleTimeoutInMinutes
|
integer
|
O tempo limite ocioso do endereço IP público.
|
properties.ipTags
|
VirtualMachineScaleSetIpTag[]
|
A lista de tags IP associadas ao endereço IP público.
|
properties.publicIPAddressVersion
|
IPVersion
|
Disponível a partir de Api-Version 2019-07-01, representa se a configuração ip específica é IPv4 ou IPv6. O padrão é considerado IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
|
properties.publicIPPrefix
|
SubResource
|
O PublicIPPrefix a partir do qual alocar endereços IP públicos.
|
sku
|
PublicIPAddressSku
|
Descreve o IP público Sku. Ele só pode ser definido com OrchestrationMode como flexível.
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
Descreve uma escala de máquinas virtuais que define as configurações de DNS da rede.
Name |
Tipo |
Description |
domainNameLabel
|
string
|
O rótulo do nome de domínio. A concatenação do rótulo de nome de domínio e do índice vm serão os rótulos de nome de domínio dos recursos PublicIPAddress que serão criados
|
domainNameLabelScope
|
DomainNameLabelScopeTypes
|
O escopo do rótulo de nome de domínio. A concatenação do rótulo de nome de domínio com hash gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice vm serão os rótulos de nome de domínio dos recursos de endereço PublicIPAddress que serão criados
|
VirtualMachineScaleSetScaleInRules
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquina virtual.
Os valores possíveis são:
padrão Quando um conjunto de escala de máquina virtual é dimensionado, o conjunto de escala será primeiro balanceado entre zonas se for um conjunto de escala zonal. Em seguida, ele será balanceado entre Domínios de Falha na medida do possível. Dentro de cada Domínio de Falha, as máquinas virtuais escolhidas para remoção serão as mais recentes que não estão protegidas contra scale-in.
OldestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais antigas que não estão protegidas serão escolhidas para remoção.
NewestVM Quando um conjunto de dimensionamento de máquina virtual está sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra expansão serão escolhidas para remoção. Para conjuntos de escala de máquina virtual zonal, o conjunto de escala será primeiro balanceado entre zonas. Dentro de cada zona, as máquinas virtuais mais recentes que não estão protegidas serão escolhidas para remoção.
Name |
Tipo |
Description |
Default
|
string
|
|
NewestVM
|
string
|
|
OldestVM
|
string
|
|
VirtualMachineScaleSetStorageProfile
Descreve um perfil de armazenamento de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
dataDisks
|
VirtualMachineScaleSetDataDisk[]
|
Especifica os parâmetros que são usados para adicionar discos de dados às máquinas virtuais no conjunto de escala. Para obter mais informações sobre discos, consulte Sobre discos e VHDs para máquinas virtuais do Azure.
|
diskControllerType
|
DiskControllerTypes[]
|
Especifica o tipo de controlador de disco configurado para as máquinas virtuais no conjunto de escala. Versão mínima da api: 2022-08-01
|
imageReference
|
ImageReference
|
Especifica informações sobre a imagem a ser usada. Você pode especificar informações sobre imagens de plataforma, imagens de mercado ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, imagem de mercado ou imagem de máquina virtual, mas não é usado em outras operações de criação.
|
osDisk
|
VirtualMachineScaleSetOSDisk
|
Especifica informações sobre o disco do sistema operacional usado pelas máquinas virtuais no conjunto de escala. Para obter mais informações sobre discos, consulte Sobre discos e VHDs para máquinas virtuais do Azure.
|
VirtualMachineScaleSetVMProfile
Descreve um perfil de máquina virtual de conjunto de escala de máquina virtual.
Name |
Tipo |
Description |
applicationProfile
|
ApplicationProfile
|
Especifica os aplicativos de galeria que devem ser disponibilizados para a VM/VMSS
|
billingProfile
|
BillingProfile
|
Especifica os detalhes relacionados à cobrança de um VMSS spot do Azure. Versão api mínima: 2019-03-01.
|
capacityReservation
|
CapacityReservationProfile
|
Especifica os detalhes relacionados à reserva de capacidade de um conjunto de escalas. Versão mínima api: 2021-04-01.
|
diagnosticsProfile
|
DiagnosticsProfile
|
Especifica o estado das configurações de diagnóstico de inicialização. Versão mínima da api: 2015-06-15.
|
evictionPolicy
|
VirtualMachineEvictionPolicyTypes
|
Especifica a política de remoção para a máquina virtual do Azure Spot e o conjunto de escala do Azure Spot. Para máquinas virtuais do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2019-03-01. Para conjuntos de escala do Azure Spot, há suporte para 'Deslocalizar' e 'Excluir' e a versão mínima da api é 2017-10-30-preview.
|
extensionProfile
|
VirtualMachineScaleSetExtensionProfile
|
Especifica uma coleção de configurações para extensões instaladas em máquinas virtuais no conjunto de escala.
|
hardwareProfile
|
VirtualMachineScaleSetHardwareProfile
|
Especifica os detalhes relacionados ao perfil de hardware de um conjunto de escala. Versão mínima api: 2021-11-01.
|
licenseType
|
string
|
Especifica que a imagem ou o disco que está sendo usado foi licenciado localmente.
Os valores possíveis para o sistema operacional Windows Server são:
Windows_Client
Windows_Server
Os valores possíveis para o sistema operacional Linux Server são:
RHEL_BYOS (para RHEL)
SLES_BYOS (para SUSE)
Para obter mais informações, consulte Benefício de Uso Híbrido do Azure para Windows Server
Benefício de Uso Híbrido do Azure para Linux Server
Versão mínima da api: 2015-06-15
|
networkProfile
|
VirtualMachineScaleSetNetworkProfile
|
Especifica as propriedades das interfaces de rede das máquinas virtuais no conjunto de escala.
|
osProfile
|
VirtualMachineScaleSetOSProfile
|
Especifica as configurações do sistema operacional para as máquinas virtuais no conjunto de escala.
|
priority
|
VirtualMachinePriorityTypes
|
Especifica a prioridade para as máquinas virtuais no conjunto de escala. Versão mínima da api: 2017-10-30-preview.
|
scheduledEventsProfile
|
ScheduledEventsProfile
|
Especifica as configurações relacionadas a Eventos Agendados.
|
securityPostureReference
|
SecurityPostureReference
|
Especifica a postura de segurança a ser usada no conjunto de escalas. Versão mínima da api: 2023-03-01
|
securityProfile
|
SecurityProfile
|
Especifica as configurações de perfil relacionadas à segurança para as máquinas virtuais no conjunto de escala.
|
serviceArtifactReference
|
ServiceArtifactReference
|
Especifica a ID de referência do artefato de serviço usada para definir a mesma versão de imagem para todas as máquinas virtuais no conjunto de escala ao usar a versão de imagem 'mais recente'. Versão mínima api: 2022-11-01
|
storageProfile
|
VirtualMachineScaleSetStorageProfile
|
Especifica as configurações de armazenamento para os discos da máquina virtual.
|
timeCreated
|
string
|
Especifica a hora em que esse perfil de VM para o Conjunto de Dimensionamento de Máquina Virtual foi criado. Esse valor será adicionado às tags VM Flex do VMSS ao criar/atualizar o Perfil da VM do VMSS. A versão mínima da API para esta propriedade é 2023-09-01.
|
userData
|
string
|
UserData para as máquinas virtuais no conjunto de escala, que deve ser codificado em base-64. O cliente não deve passar nenhum segredo aqui. Versão mínima da api: 2021-03-01.
|
VMDiskSecurityProfile
Especifica as configurações de perfil de segurança para o disco gerenciado.
Nota: Ele só pode ser definido para VMs confidenciais.
Name |
Tipo |
Description |
diskEncryptionSet
|
DiskEncryptionSetParameters
|
Especifica a ID do recurso do conjunto de criptografia de disco gerenciado pelo cliente para o disco gerenciado usado para a Chave Gerenciada do Cliente criptografada, o Disco do SO ConfidentialVM e o blob VMGuest.
|
securityEncryptionType
|
securityEncryptionTypes
|
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado junto com o blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado do firmware no blob VMGuestState.
Nota: Ele pode ser definido apenas para VMs confidenciais.
|
VMGalleryApplication
Especifica as informações necessárias para fazer referência a uma versão do aplicativo da galeria de computação
Name |
Tipo |
Description |
configurationReference
|
string
|
Opcional, Especifica o uri para um blob azure que substituirá a configuração padrão para o pacote, se fornecido
|
enableAutomaticUpgrade
|
boolean
|
Se definido como true, quando uma nova versão do Aplicativo Gallery estiver disponível no PIR/SIG, ela será atualizada automaticamente para a VM/VMSS
|
order
|
integer
|
Opcional, Especifica a ordem em que os pacotes devem ser instalados
|
packageReferenceId
|
string
|
Especifica a id do recurso GalleryApplicationVersion no formato /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}
|
tags
|
string
|
Opcional, Especifica um valor de passagem para contexto mais genérico.
|
treatFailureAsDeploymentFailure
|
boolean
|
Opcional, se verdadeiro, qualquer falha para qualquer operação no VmApplication falhará na implantação
|
VMSizeProperties
Especifica as configurações da Propriedade de Tamanho da VM na máquina virtual.
Name |
Tipo |
Description |
vCPUsAvailable
|
integer
|
Especifica o número de vCPUs disponíveis para a VM. Quando essa propriedade não é especificada no corpo da solicitação, o comportamento padrão é defini-la com o valor de vCPUs disponíveis para esse tamanho de VM exposto na resposta da api de Listar todos os tamanhos de máquina virtual disponíveis em uma região.
|
vCPUsPerCore
|
integer
|
Especifica a relação vCPU para núcleo físico. Quando essa propriedade não é especificada no corpo da solicitação, o comportamento padrão é definido como o valor de vCPUsPerCore para o Tamanho da VM exposto na resposta da api de Listar todos os tamanhos de máquina virtual disponíveis em uma região.
Definir essa propriedade como 1 também significa que o hyper-threading está desabilitado.
|
WindowsConfiguration
Especifica as configurações do sistema operacional Windows na máquina virtual.
Name |
Tipo |
Description |
additionalUnattendContent
|
AdditionalUnattendContent[]
|
Especifica informações adicionais formatadas em XML codificadas em base 64 que podem ser incluídas no arquivo Unattend.xml, que é usado pela Instalação do Windows.
|
enableAutomaticUpdates
|
boolean
|
Indica se as Atualizações Automáticas estão habilitadas para a máquina virtual do Windows. O valor padrão é true. Para conjuntos de dimensionamento de máquina virtual, essa propriedade pode ser atualizada e as atualizações entrarão em vigor no reprovisionamento do sistema operacional.
|
enableVMAgentPlatformUpdates
|
boolean
|
Indica se as Atualizações da Plataforma VMAgent estão habilitadas para a Máquina Virtual do Windows.
|
patchSettings
|
PatchSettings
|
[Funcionalidade de pré-visualização] Especifica as configurações relacionadas ao patch de convidado de VM no Windows.
|
provisionVMAgent
|
boolean
|
Indica se o agente de máquina virtual deve ser provisionado na máquina virtual. Quando essa propriedade não é especificada no corpo da solicitação, ela é definida como true por padrão. Isso garantirá que o Agente de VM seja instalado na VM para que as extensões possam ser adicionadas à VM posteriormente.
|
timeZone
|
string
|
Especifica o fuso horário da máquina virtual. por exemplo, "Hora Padrão do Pacífico". Os valores possíveis podem ser TimeZoneInfo.Id valor de fusos horários retornados por TimeZoneInfo.GetSystemTimeZones.
|
winRM
|
WinRMConfiguration
|
Especifica os ouvintes do Gerenciamento Remoto do Windows. Isso habilita o Windows PowerShell remoto.
|
WindowsPatchAssessmentMode
Especifica o modo de avaliação de patch do convidado da VM para a máquina virtual IaaS.
Os valores possíveis são:
ImageDefault - Você controla o tempo das avaliações de patch em uma máquina virtual.
AutomaticByPlatform - A plataforma acionará avaliações periódicas de patches. A provisão de propriedadeVMAgent deve ser true.
Name |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
Name |
Tipo |
Description |
Always
|
string
|
|
IfRequired
|
string
|
|
Never
|
string
|
|
Unknown
|
string
|
|
Especifica configurações adicionais a serem aplicadas quando o modo de patch AutomaticByPlatform é selecionado nas configurações de patch do Windows.
Name |
Tipo |
Description |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Permite que o cliente agende patches sem atualizações acidentais
|
rebootSetting
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação do patch AutomaticByPlatform.
|
WindowsVMGuestPatchMode
Especifica o modo de aplicação de patches de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquina virtual com OrchestrationMode como flexível.
Os valores possíveis são:
Manual - Você controla a aplicação de patches em uma máquina virtual. Para fazer isso, aplique patches manualmente dentro da VM. Neste modo, as atualizações automáticas são desativadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser false
AutomaticByOS - A máquina virtual será atualizada automaticamente pelo SO. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser true.
AutomaticByPlatform - a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser true
Name |
Tipo |
Description |
AutomaticByOS
|
string
|
|
AutomaticByPlatform
|
string
|
|
Manual
|
string
|
|
WinRMConfiguration
Descreve a configuração do Gerenciamento Remoto do Windows da VM
Name |
Tipo |
Description |
listeners
|
WinRMListener[]
|
A lista de ouvintes do Gerenciamento Remoto do Windows
|
WinRMListener
Descreve o protocolo e a impressão digital do ouvinte do Gerenciamento Remoto do Windows
Name |
Tipo |
Description |
certificateUrl
|
string
|
Este é o URL de um certificado que foi carregado para o Cofre da Chave como um segredo. Para adicionar um segredo ao Cofre de Chaves, consulte Adicionar uma chave ou segredo ao Cofre de Chaves. Nesse caso, seu certificado precisa ser a codificação Base64 do seguinte objeto JSON que é codificado em UTF-8:
{ "dados":"", "dataType":"pfx", "senha":"" } Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual do Azure Key Vault para Linux ou a extensão de máquina virtual do Azure Key Vault para Windows.
|
protocol
|
ProtocolTypes
|
Especifica o protocolo do ouvinte do WinRM. Os valores possíveis são: httphttps.
|
ZonalPlatformFaultDomainAlignMode
Especifica o modo de alinhamento entre a computação do Conjunto de Escala da Máquina Virtual e a contagem de Domínio de Falha de armazenamento.
Name |
Tipo |
Description |
Aligned
|
string
|
|
Unaligned
|
string
|
|