Criar ou atualizar um conjunto de dimensionamento de VM.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}?api-version=2024-07-01
Parâmetros de URI
Nome |
Em |
Obrigató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. A ID da assinatura faz parte do URI para cada chamada de serviço.
|
vmScaleSetName
|
path |
True
|
string
|
O nome do conjunto de dimensionamento de VM a ser criado ou atualizado.
|
api-version
|
query |
True
|
string
|
Versão da API do cliente.
|
Nome |
Obrigatório |
Tipo |
Description |
If-Match
|
|
string
|
A ETag da transformação. Omita esse valor para sempre substituir o recurso atual. Especifique o valor de ETag visto pela última vez para impedir 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 têm suporte.
|
Corpo da solicitação
Nome |
Obrigatório |
Tipo |
Description |
location
|
True
|
string
|
Local do recurso
|
extendedLocation
|
|
ExtendedLocation
|
O local estendido do Conjunto de Dimensionamento de Máquinas Virtuais.
|
identity
|
|
VirtualMachineScaleSetIdentity
|
A identidade do conjunto de dimensionamento de máquinas virtuais, se configurado.
|
plan
|
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Esse elemento é usado apenas para imagens do marketplace. Antes de usar uma imagem do marketplace de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que você deseja usar e clique em Deseja implantar programaticamente, Introdução –>. Insira as informações necessárias e clique em Salvar.
|
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 dar suporte à anexação de discos de dados gerenciados com UltraSSD_LRS tipo de conta de armazenamento.
|
properties.automaticRepairsPolicy
|
|
AutomaticRepairsPolicy
|
Política para reparos automáticos.
|
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 apenas no número solicitado de VMs que são finalmente mantidas. Dessa forma, essa propriedade garantirá que as extensões não sejam executadas nas VMs extraprovisionadas.
|
properties.hostGroup
|
|
SubResource
|
Especifica informações sobre o grupo de hosts dedicado no qual reside o conjunto de dimensionamento de máquinas virtuais. Versão mínima da API: 2020-06-01.
|
properties.orchestrationMode
|
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de dimensionamento de máquinas virtuais.
|
properties.overprovision
|
|
boolean
|
Especifica se o Conjunto de Dimensionamento de Máquinas Virtuais deve ser superprovisionado.
|
properties.platformFaultDomainCount
|
|
integer
|
Contagem de domínios de falha para cada grupo de posicionamento.
|
properties.priorityMixPolicy
|
|
PriorityMixPolicy
|
Especifica os destinos desejados para misturar VMs spot e de prioridade regular na mesma instância do VMSS Flex.
|
properties.proximityPlacementGroup
|
|
SubResource
|
Especifica informações sobre o grupo de posicionamento por proximidade ao qual o conjunto de dimensionamento de máquinas virtuais deve ser atribuído. Versão mínima da API: 2018-04-01.
|
properties.resiliencyPolicy
|
|
ResiliencyPolicy
|
Política de resiliência
|
properties.scaleInPolicy
|
|
ScaleInPolicy
|
Especifica as políticas aplicadas ao dimensionamento em Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais.
|
properties.scheduledEventsPolicy
|
|
ScheduledEventsPolicy
|
O ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
|
boolean
|
Quando true, isso limita o conjunto de dimensionamento a um único grupo de posicionamento, de tamanho máximo de 100 máquinas virtuais. OBSERVAÇÃO: se singlePlacementGroup for true, ele poderá ser modificado para false. No entanto, se singlePlacementGroup for false, ele poderá não ser modificado para true.
|
properties.skuProfile
|
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de dimensionamento de máquinas virtuais.
|
properties.spotRestorePolicy
|
|
SpotRestorePolicy
|
Especifica as propriedades do Spot Restore para o conjunto de dimensionamento de máquinas virtuais.
|
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 Dimensionamento de Máquinas Virtuais e a contagem de domínios de falha de armazenamento.
|
properties.zoneBalance
|
|
boolean
|
Se deve forçar estritamente até mesmo a distribuição de Máquina Virtual entre zonas x no caso de haver interrupção de zona. A propriedade zoneBalance só poderá ser definida se a propriedade zones do conjunto de dimensionamento 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 dimensionamento de máquinas virtuais.
|
tags
|
|
object
|
Marcas de recurso
|
zones
|
|
string[]
|
As zonas do conjunto de dimensionamento de máquinas virtuais.
|
Respostas
Segurança
azure_auth
Fluxo OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Create a custom-image scale set from an unmanaged generalized os image.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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}"
}
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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.
Solicitação de exemplo
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://zcusa.951200.xyz/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 de exemplo
{
"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
Nome |
Description |
AdditionalCapabilities
|
Habilita ou desabilita uma funcionalidade na máquina virtual ou no conjunto de dimensionamento de máquinas virtuais.
|
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 pelo nome da configuração, pelo nome do componente e pela passagem na qual o conteúdo é aplicado.
|
AllocationStrategy
|
Especifica a estratégia de alocação para o conjunto de dimensionamento de máquinas virtuais com base no qual as VMs serão alocadas.
|
ApiEntityReference
|
A referência da entidade de API.
|
ApiError
|
Erro de API.
|
ApiErrorBase
|
Base de erros de API.
|
ApplicationProfile
|
Contém a lista de aplicativos da 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 dimensionamento de máquinas virtuais.
|
BillingProfile
|
Especifica os detalhes relacionados à cobrança de uma VM spot ou VMSS do Azure. Versão mínima da API: 2019-03-01.
|
BootDiagnostics
|
O Diagnóstico de Inicialização é um recurso de depuração que permite exibir a Saída do Console e a Captura de Tela para diagnosticar o status da VM. Você pode exibir 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 Standard. 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 de disco efêmero para o disco do sistema operacional. Essa 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 so efêmero. Para obter mais informações sobre os requisitos de tamanho do disco do sistema operacional efêmero, consulte os requisitos de tamanho de disco do sistema operacional efêmero para a VM do Windows em https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e VM linux em 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.
Observação: 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 dimensionamento 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 OrchestrationMode Flexível).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando a VM VMSS Flex for excluída.
Desanexar Se esse valor for usado, o disco do sistema operacional será mantido após a exclusão da VM VMSS Flex.
O valor padrão é definido como Excluir. Para um disco do sistema operacional efêmero, o valor padrão é definido como Excluir. O usuário não pode alterar a opção de exclusão do Disco do SO Efêmero.
|
DiskEncryptionSetParameters
|
Descreve o parâmetro da ID de recurso do conjunto de criptografia de disco gerenciado pelo cliente que pode ser especificada para disco.
Observação: A ID do recurso do conjunto de criptografia de disco só pode ser especificada 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 hash que foi gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice de VM serão os rótulos de nome de domínio dos recursos PublicIPAddress que serão criados
|
EncryptionIdentity
|
Especifica a Identidade Gerenciada usada pelo ADE para obter o token de acesso para operações de keyvault.
|
EventGridAndResourceGraph
|
Especifica configurações relacionadas ao evento agendado eventGridAndResourceGraph relacionadas.
|
ExtendedLocation
|
O tipo complexo do local estendido.
|
ExtendedLocationTypes
|
O tipo do local estendido.
|
ImageReference
|
Especifica informações sobre a imagem a ser usada. Você pode especificar informações sobre imagens de plataforma, imagens do marketplace ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, uma imagem do marketplace ou uma imagem de máquina virtual, mas não é usado em outras operações de criação. OBSERVAÇÃO: A oferta e o editor de referência de imagem só podem ser definidos quando você cria o conjunto de dimensionamento.
|
InnerError
|
Detalhes do erro interno.
|
IPVersion
|
Disponível de Api-Version 2019-07-01 em diante, ele representa se a ipconfiguração específica é IPv4 ou IPv6. O padrão é usado como 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 do Linux com suporte, consulte Linux nodistribuições de Azure-Endorsed.
|
LinuxPatchAssessmentMode
|
Especifica o modo de Avaliação de Patch 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
|
LinuxPatchSettings
|
Especifica as configurações relacionadas à aplicação de patch de convidado da VM no Linux.
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação de 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 patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
ImageDefault – a configuração de aplicação de patch padrão da máquina virtual é usada.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. A propriedade provisionVMAgent deve ser verdadeira
|
Mode
|
Especifica o modo no qual o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não imporá o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo auditoria, enquanto no modo Impor imporá o controle de acesso. O valor padrão é o modo Impor.
|
NetworkApiVersion
|
especifica a versão da API Microsoft.Network usada ao criar recursos de rede nas Configurações de Interface de Rede para o Conjunto de Dimensionamento de Máquinas Virtuais com o modo de orquestração 'Flexível'
|
NetworkInterfaceAuxiliaryMode
|
Especifica se o modo Auxiliar está habilitado para o recurso de Interface de Rede.
|
NetworkInterfaceAuxiliarySku
|
Especifica se o sku auxiliar está habilitado para o recurso de Interface de Rede.
|
OperatingSystemTypes
|
Essa propriedade permite que você especifique o tipo do sistema operacional incluído no disco se criar uma VM com base na imagem do usuário ou em um VHD especializado. Os valores possíveis são: Windows,Linux.
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de dimensionamento de máquinas virtuais.
|
OSImageNotificationProfile
|
|
PassNames
|
O nome da passagem. Atualmente, o único valor permitido é OobeSystem.
|
PatchSettings
|
Especifica as configurações relacionadas à aplicação de patch de convidado da VM no Windows.
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Esse elemento é usado apenas para imagens do marketplace. Antes de usar uma imagem do marketplace de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que você deseja usar e clique em Deseja implantar programaticamente, Introdução –>. Insira as informações necessárias e clique em Salvar.
|
PriorityMixPolicy
|
Especifica as divisões de destino para VMs de prioridade spot e regular em um conjunto de dimensionamento 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 do VMSS é expandida e a divisão entre VMs de prioridade regular e Spot após esse destino base ter sido atingido.
|
ProtocolTypes
|
Especifica o protocolo do ouvinte WinRM. Os valores possíveis são: http,https.
|
ProxyAgentSettings
|
Especifica as configurações de ProxyAgent ao criar a máquina virtual. Versão mínima da API: 2023-09-01.
|
PublicIPAddressSku
|
Descreve o Sku de IP público. Ele só pode ser definido com OrchestrationMode como Flexível.
|
PublicIPAddressSkuName
|
Especificar o nome do sku de IP público
|
PublicIPAddressSkuTier
|
Especificar a camada de sku de IP público
|
RepairAction
|
Tipo de ação de reparo (substituir, reiniciar, reimagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de dimensionamento. 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 durante a execução da exclusão de VM resiliente.
|
ResourceIdentityType
|
O tipo de identidade usado para o conjunto de dimensionamento de máquinas virtuais. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'None' removerá as identidades do conjunto de dimensionamento de máquinas virtuais.
|
RollingUpgradePolicy
|
Os parâmetros de configuração usados durante a execução de uma atualização sem interrupção.
|
ScaleInPolicy
|
Descreve uma política de dimensionamento para um conjunto de dimensionamento de máquinas virtuais.
|
ScheduledEventsAdditionalPublishingTargets
|
|
ScheduledEventsPolicy
|
Especifica a reimplantação, reinicialização e configurações relacionadas ao evento agendado ScheduledEventsAdditionalPublishingTargets.
|
ScheduledEventsProfile
|
|
securityEncryptionTypes
|
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado juntamente com blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado de firmware no blob VMGuestState..
Observação: Ele pode ser definido apenas para VMs confidenciais.
|
SecurityPostureReference
|
Especifica a postura de segurança a ser usada no conjunto de dimensionamento. 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 de máquinas virtuais.
|
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 dimensionamento ao usar a versão de imagem 'mais recente'. Versão mínima da 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 do conjunto de dimensionamento de máquinas virtuais. OBSERVAÇÃO: Se não houver suporte para a nova SKU de VM no hardware em que o conjunto de dimensionamento está atualmente, você precisará desalocar as VMs no conjunto de dimensionamento antes de modificar o nome da SKU.
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de dimensionamento de máquinas virtuais. 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 dimensionamento de máquinas virtuais. Com essa propriedade, o cliente pode habilitar ou desabilitar a restauração automática das instâncias de VM do Spot VMSS removidas de forma oportunista com base na disponibilidade da capacidade e na restrição de preços.
|
SshConfiguration
|
Configuração de 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 do Linux em que a chave pública é colocada.
|
StorageAccountTypes
|
Especifica o tipo de conta de armazenamento para o disco gerenciado. OBSERVAÇÃO: UltraSSD_LRS só pode ser usado com discos de dados, ele não pode ser usado com o Disco do SISTEMA Operacional.
|
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 mínima da API: 2020-12-01.
|
UpgradeMode
|
Especifica o modo de uma atualização para máquinas virtuais no conjunto de dimensionamento.
Os valores possíveis são:
Manual – você controla a aplicação de atualizações para máquinas virtuais no conjunto de dimensionamento. Faça isso usando a ação manualUpgrade.
automático – todas as máquinas virtuais no conjunto de dimensionamento são atualizadas automaticamente ao mesmo tempo.
|
UpgradePolicy
|
Descreve uma política de atualização – automática, manual ou sem interrupção.
|
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 do ARM no formulário: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
UserInitiatedReboot
|
Especifica as configurações relacionadas ao Evento Agendado relacionadas à reinicialização.
|
UserInitiatedRedeploy
|
Especifica as configurações relacionadas ao Evento Agendado relacionadas à reimplantação.
|
VaultCertificate
|
Descreve uma única referência de certificado em um Key Vault e onde o certificado deve residir na VM.
|
VaultSecretGroup
|
Descreve um conjunto de certificados que estão todos no mesmo Key Vault.
|
VirtualHardDisk
|
Descreve o uri de um disco.
|
VirtualMachineEvictionPolicyTypes
|
Especifica a política de remoção para a máquina virtual spot do Azure e o conjunto de dimensionamento spot do Azure. Para máquinas virtuais spot do Azure, há suporte para 'Desalocar' e 'Excluir' e a versão mínima da API é 2019-03-01. Para conjuntos de dimensionamento do Spot do Azure, há suporte para 'Desalocar' e 'Excluir' e a versão mínima da API é 2017-10-30-preview.
|
VirtualMachinePriorityTypes
|
Especifica a prioridade das máquinas virtuais no conjunto de dimensionamento. Versão mínima da api: 2017-10-30-preview.
|
VirtualMachineScaleSet
|
Descreve um conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetDataDisk
|
Descreve um disco de dados do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetExtension
|
Descreve uma extensão do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetExtensionProfile
|
Descreve um perfil de extensão do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetHardwareProfile
|
Especifica as configurações de hardware para o conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetIdentity
|
Identidade do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetIPConfiguration
|
Descreve a configuração de IP de um perfil de rede do conjunto de dimensionamento de máquinas virtuais.
|
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 do perfil de rede de um conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
Descreve as configurações DNS de uma configuração de rede de conjuntos de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetNetworkProfile
|
Descreve um perfil de rede de conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetOSDisk
|
Descreve um disco do sistema operacional do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetOSProfile
|
Descreve um perfil do sistema operacional do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetPublicIPAddressConfiguration
|
Descreve a configuração publicIPAddress de um conjunto de dimensionamento de máquinas virtuais
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
|
Descreve as configurações DNS de uma configuração de rede de conjuntos de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetScaleInRules
|
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquinas virtuais.
Os valores possíveis são:
Padrão Quando um conjunto de dimensionamento de máquinas virtuais é dimensionado, o conjunto de dimensionamento será primeiro equilibrado entre zonas se for um conjunto de dimensionamento zonal. Em seguida, ele será equilibrado entre domínios de falha na medida do possível. Em 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 o scale-in.
OldestVM quando um conjunto de dimensionamento de máquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em 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áquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra a escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em 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 do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetVMProfile
|
Descreve um perfil de máquina virtual do conjunto de dimensionamento de máquinas virtuais.
|
VMDiskSecurityProfile
|
Especifica as configurações de perfil de segurança para o disco gerenciado.
Observação: 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 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 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação de 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 patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
manual – você controla a aplicação de patches em uma máquina virtual. Faça isso aplicando patches manualmente dentro da VM. Nesse modo, as atualizações automáticas são desabilitadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser falsa
AutomaticByOS – a máquina virtual será atualizada automaticamente pelo sistema operacional. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser verdadeira.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser verdadeiras
|
WinRMConfiguration
|
Descreve a configuração de Gerenciamento Remoto do Windows da VM
|
WinRMListener
|
Descreve o protocolo e a impressão digital do ouvinte de Gerenciamento Remoto do Windows
|
ZonalPlatformFaultDomainAlignMode
|
Especifica o modo de alinhamento entre a computação do Conjunto de Dimensionamento de Máquinas Virtuais e a contagem de domínios de falha de armazenamento.
|
AdditionalCapabilities
Habilita ou desabilita uma funcionalidade na máquina virtual ou no conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
hibernationEnabled
|
boolean
|
O sinalizador que habilita ou desabilita a funcionalidade 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. Discos gerenciados com tipo de conta de armazenamento UltraSSD_LRS podem ser adicionados a uma máquina virtual ou conjunto de dimensionamento de máquinas virtuais 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 pelo nome da configuração, pelo nome do componente e pela passagem na qual o conteúdo é aplicado.
Nome |
Tipo |
Description |
componentName
|
ComponentNames
|
O nome do componente. Atualmente, o único valor permitido é Microsoft-Windows-Shell-Setup.
|
content
|
string
|
Especifica o conteúdo formatado XML que é adicionado ao arquivo 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 o recurso que está sendo inserido.
|
passName
|
PassNames
|
O nome da passagem. 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 dimensionamento de máquinas virtuais com base no qual as VMs serão alocadas.
Nome |
Tipo |
Description |
CapacityOptimized
|
string
|
|
LowestPrice
|
string
|
|
ApiEntityReference
A referência da entidade de API.
Nome |
Tipo |
Description |
id
|
string
|
A ID de recurso do ARM na forma de /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
|
ApiError
Erro de API.
Nome |
Tipo |
Description |
code
|
string
|
O código de erro.
|
details
|
ApiErrorBase[]
|
Os detalhes do erro da API
|
innererror
|
InnerError
|
O erro interno da API
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro específico.
|
ApiErrorBase
Base de erros de API.
Nome |
Tipo |
Description |
code
|
string
|
O código de erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro específico.
|
ApplicationProfile
Contém a lista de aplicativos da galeria que devem ser disponibilizados para a VM/VMSS
Nome |
Tipo |
Description |
galleryApplications
|
VMGalleryApplication[]
|
Especifica os aplicativos da 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.
Nome |
Tipo |
Description |
disableAutomaticRollback
|
boolean
|
Se o recurso de reversão de imagem do sistema operacional deve ser desabilitado. O valor padrão é falso.
|
enableAutomaticOSUpgrade
|
boolean
|
Indica se as atualizações do sistema operacional devem ser aplicadas automaticamente às instâncias do conjunto de dimensionamento de forma sem interrupção quando uma versão mais recente da imagem do sistema operacional estiver disponível. O valor padrão é falso. Se isso for definido como true para conjuntos de dimensionamento 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 sistema operacional deve passar por 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 sem interrupção está chegando, por meio da marca IMDS 'Platform.PendingOSUpgrade'. Em seguida, a atualização adia até que a atualização seja aprovada por meio de uma chamada ApproveRollingUpgrade.
|
useRollingUpgradePolicy
|
boolean
|
Indica se a política de atualização sem interrupção deve ser usada durante a Atualização automática do sistema operacional. O valor padrão é falso. A atualização automática do sistema operacional fará fallback para a 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 dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
enabled
|
boolean
|
Especifica se os reparos automáticos devem ser habilitados no conjunto de dimensionamento de máquinas virtuais. O valor padrão é false.
|
gracePeriod
|
string
|
A quantidade de tempo para 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 alteração de estado. Isso ajuda a evitar reparos prematuros ou acidentais. A duração do tempo deve ser especificada no formato ISO 8601. O período mínimo de carência permitido é de 10 minutos (PT10M), que também é o valor padrão. O período máximo de carência permitido é de 90 minutos (PT90M).
|
repairAction
|
RepairAction
|
Tipo de ação de reparo (substituir, reiniciar, reimagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de dimensionamento. O valor padrão é substituir.
|
BillingProfile
Especifica os detalhes relacionados à cobrança de uma VM spot ou VMSS do Azure. Versão mínima da API: 2019-03-01.
Nome |
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 está 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 da VM/VMSS spot do Azure e a operação só terá êxito se o maxPrice for maior que o preço spot atual do Azure.
O maxPrice também será usado para remover uma VM/VMSS spot do Azure se o preço atual do Spot do Azure ultrapassar o maxPrice após a criação da VM/VMSS.
Os valores possíveis são:
- Qualquer valor decimal maior que zero. Exemplo: 0,01538
-1 – indica que o preço padrão será up-to sob demanda.
Você pode definir o 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 será -1 se não for fornecido por você.
Versão mínima da API: 2019-03-01.
|
BootDiagnostics
O Diagnóstico de Inicialização é um recurso de depuração que permite exibir a Saída do Console e a Captura de Tela para diagnosticar o status da VM. Você pode exibir facilmente a saída do log do console. O Azure também permite que você veja uma captura de tela da VM do hipervisor.
Nome |
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 Standard. ReadOnly para armazenamento Premium.
Nome |
Tipo |
Description |
None
|
string
|
|
ReadOnly
|
string
|
|
ReadWrite
|
string
|
|
CapacityReservationProfile
Os parâmetros de um perfil de reserva de capacidade.
Nome |
Tipo |
Description |
capacityReservationGroup
|
SubResource
|
Especifica a ID de recurso do grupo de reserva de capacidade que deve ser usada para alocar as instâncias de VM de conjunto de dimensionamento ou máquina virtual, 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.
Nome |
Tipo |
Description |
error
|
ApiError
|
Erro de API.
|
ComponentNames
O nome do componente. Atualmente, o único valor permitido é Microsoft-Windows-Shell-Setup.
Nome |
Tipo |
Description |
Microsoft-Windows-Shell-Setup
|
string
|
|
DeleteOptions
Especificar o que acontece com o IP público quando a VM é excluída
Nome |
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.
Nome |
Tipo |
Description |
bootDiagnostics
|
BootDiagnostics
|
O Diagnóstico de Inicialização é um recurso de depuração que permite exibir a Saída do Console e a Captura de Tela para diagnosticar o status da VM.
OBSERVAÇÃO: se storageUri estiver sendo especificado, verifique se a conta de armazenamento está na mesma região e assinatura da VM. Você pode exibir 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.
Nome |
Tipo |
Description |
Local
|
string
|
|
DiffDiskPlacement
Especifica o posicionamento de disco efêmero para o disco do sistema operacional. Essa 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 so efêmero. Para obter mais informações sobre os requisitos de tamanho do disco do sistema operacional efêmero, consulte os requisitos de tamanho de disco do sistema operacional efêmero para a VM do Windows em https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e VM linux em https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. Versão mínima da API para NvmeDisk: 2024-03-01.
Nome |
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.
Observação: as configurações de disco efêmero só podem ser especificadas para o disco gerenciado.
DiskControllerTypes
Nome |
Tipo |
Description |
NVMe
|
string
|
|
SCSI
|
string
|
|
DiskCreateOptionTypes
Especifica como as máquinas virtuais no conjunto de dimensionamento 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.
Nome |
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 OrchestrationMode Flexível).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando a VM VMSS Flex for excluída.
Desanexar Se esse valor for usado, o disco do sistema operacional será mantido após a exclusão da VM VMSS Flex.
O valor padrão é definido como Excluir. Para um disco do sistema operacional efêmero, o valor padrão é definido como Excluir. O usuário não pode alterar a opção de exclusão do Disco do SO Efêmero.
Nome |
Tipo |
Description |
Delete
|
string
|
|
Detach
|
string
|
|
DiskEncryptionSetParameters
Descreve o parâmetro da ID de recurso do conjunto de criptografia de disco gerenciado pelo cliente que pode ser especificada para disco.
Observação: A ID do recurso do conjunto de criptografia de disco só pode ser especificada para o disco gerenciado. Consulte https://aka.ms/mdssewithcmkoverview para obter mais detalhes.
Nome |
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 hash que foi gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice de VM serão os rótulos de nome de domínio dos recursos PublicIPAddress que serão criados
Nome |
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 de keyvault.
Nome |
Tipo |
Description |
userAssignedIdentityResourceId
|
string
|
Especifica a ID de recurso do ARM de uma das identidades de usuário associadas à VM.
|
EventGridAndResourceGraph
Especifica configurações relacionadas ao evento agendado eventGridAndResourceGraph relacionadas.
Nome |
Tipo |
Description |
enable
|
boolean
|
Especifica se a grade de eventos e o grafo de recursos estão habilitados para configurações relacionadas a eventos agendados.
|
ExtendedLocation
O tipo complexo do local estendido.
Nome |
Tipo |
Description |
name
|
string
|
O nome do local estendido.
|
type
|
ExtendedLocationTypes
|
O tipo do local estendido.
|
ExtendedLocationTypes
O tipo do local estendido.
Nome |
Tipo |
Description |
EdgeZone
|
string
|
|
ImageReference
Especifica informações sobre a imagem a ser usada. Você pode especificar informações sobre imagens de plataforma, imagens do marketplace ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, uma imagem do marketplace ou uma imagem de máquina virtual, mas não é usado em outras operações de criação. OBSERVAÇÃO: A oferta e o editor de referência de imagem só podem ser definidos quando você cria o conjunto de dimensionamento.
Nome |
Tipo |
Description |
communityGalleryImageId
|
string
|
Especifica a ID exclusiva da imagem da galeria da comunidade para implantação de VM. Isso pode ser buscado na chamada GET da imagem da galeria da comunidade.
|
exactVersion
|
string
|
Especifica em números decimais, a versão da imagem da plataforma ou da imagem do marketplace usada para criar a máquina virtual. Esse campo readonly difere de 'version', somente se o valor especificado no campo 'version' for 'latest'.
|
id
|
string
|
ID do recurso
|
offer
|
string
|
Especifica a oferta da imagem da plataforma ou da imagem do marketplace usada para criar a máquina virtual.
|
publisher
|
string
|
O editor de imagens.
|
sharedGalleryImageId
|
string
|
Especifica a ID exclusiva da imagem da galeria compartilhada para implantação de VM. Isso pode ser buscado na chamada GET da imagem da galeria compartilhada.
|
sku
|
string
|
A SKU da imagem.
|
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 'latest'. 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 'latest', a imagem da VM não será atualizada automaticamente após o tempo de implantação, mesmo se uma nova versão estiver disponível. Não use o campo 'versão' para implantação de imagem da galeria, a imagem da galeria sempre deve 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.
Nome |
Tipo |
Description |
errordetail
|
string
|
A mensagem de erro interna ou o despejo de exceção.
|
exceptiontype
|
string
|
O tipo de exceção.
|
IPVersion
Disponível de Api-Version 2019-07-01 em diante, ele representa se a ipconfiguração específica é IPv4 ou IPv6. O padrão é usado como IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
Nome |
Tipo |
Description |
IPv4
|
string
|
|
IPv6
|
string
|
|
KeyVaultSecretReference
Descreve uma referência ao Segredo do Key Vault
Nome |
Tipo |
Description |
secretUrl
|
string
|
A URL que faz referência a um segredo em um Key Vault.
|
sourceVault
|
SubResource
|
A URL relativa do Key Vault 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 do Linux com suporte, consulte Linux nodistribuições de Azure-Endorsed.
Nome |
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 é falso.
|
patchSettings
|
LinuxPatchSettings
|
[Recurso de visualização] Especifica as configurações relacionadas à aplicação de patch de convidado da 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 de chave ssh para um sistema operacional Linux.
|
LinuxPatchAssessmentMode
Especifica o modo de Avaliação de Patch 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
Nome |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
LinuxPatchSettings
Especifica as configurações relacionadas à aplicação de patch de convidado da VM no Linux.
Nome |
Tipo |
Description |
assessmentMode
|
LinuxPatchAssessmentMode
|
Especifica o modo de Avaliação de Patch 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
|
automaticByPlatformSettings
|
LinuxVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais para o modo de patch AutomaticByPlatform na Aplicação de Patch de Convidado de VM no Linux.
|
patchMode
|
LinuxVMGuestPatchMode
|
Especifica o modo de aplicação de patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
ImageDefault – a configuração de aplicação de patch padrão da máquina virtual é usada.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. A propriedade provisionVMAgent deve ser verdadeira
|
Especifica a configuração de reinicialização para todas as operações de instalação de patch AutomaticByPlatform.
Nome |
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.
Nome |
Tipo |
Description |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Permite que o cliente agende a aplicação de patch sem atualizações acidentais
|
rebootSetting
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação de patch AutomaticByPlatform.
|
LinuxVMGuestPatchMode
Especifica o modo de aplicação de patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
ImageDefault – a configuração de aplicação de patch padrão da máquina virtual é usada.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. A propriedade provisionVMAgent deve ser verdadeira
Nome |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Mode
Especifica o modo no qual o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não imporá o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo auditoria, enquanto no modo Impor imporá o controle de acesso. O valor padrão é o modo Impor.
Nome |
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 o Conjunto de Dimensionamento de Máquinas Virtuais com o modo de orquestração 'Flexível'
Nome |
Tipo |
Description |
2020-11-01
|
string
|
|
NetworkInterfaceAuxiliaryMode
Especifica se o modo Auxiliar está habilitado para o recurso de Interface de Rede.
Nome |
Tipo |
Description |
AcceleratedConnections
|
string
|
|
Floating
|
string
|
|
None
|
string
|
|
NetworkInterfaceAuxiliarySku
Especifica se o sku auxiliar está habilitado para o recurso de Interface de Rede.
Nome |
Tipo |
Description |
A1
|
string
|
|
A2
|
string
|
|
A4
|
string
|
|
A8
|
string
|
|
None
|
string
|
|
OperatingSystemTypes
Essa propriedade permite que você especifique o tipo do sistema operacional incluído no disco se criar uma VM com base na imagem do usuário ou em um VHD especializado. Os valores possíveis são: Windows,Linux.
Nome |
Tipo |
Description |
Linux
|
string
|
|
Windows
|
string
|
|
OrchestrationMode
Especifica o modo de orquestração para o conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
Flexible
|
string
|
|
Uniform
|
string
|
|
OSImageNotificationProfile
Nome |
Tipo |
Description |
enable
|
boolean
|
Especifica se o evento agendado de imagem do sistema operacional está habilitado ou desabilitado.
|
notBeforeTimeout
|
string
|
O tempo que uma Máquina Virtual está sendo reimageada ou tendo 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 da passagem. Atualmente, o único valor permitido é OobeSystem.
Nome |
Tipo |
Description |
OobeSystem
|
string
|
|
PatchSettings
Especifica as configurações relacionadas à aplicação de patch de convidado da VM no Windows.
Nome |
Tipo |
Description |
assessmentMode
|
WindowsPatchAssessmentMode
|
Especifica o modo de avaliação de patch 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
|
automaticByPlatformSettings
|
WindowsVMGuestPatchAutomaticByPlatformSettings
|
Especifica configurações adicionais para o modo de patch AutomaticByPlatform na Aplicação de Patch de Convidado de VM 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 patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
manual – você controla a aplicação de patches em uma máquina virtual. Faça isso aplicando patches manualmente dentro da VM. Nesse modo, as atualizações automáticas são desabilitadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser falsa
AutomaticByOS – a máquina virtual será atualizada automaticamente pelo sistema operacional. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser verdadeira.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser verdadeiras
|
Plan
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Esse elemento é usado apenas para imagens do marketplace. Antes de usar uma imagem do marketplace de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que você deseja usar e clique em Deseja implantar programaticamente, Introdução –>. Insira as informações necessárias e clique em Salvar.
Nome |
Tipo |
Description |
name
|
string
|
A ID do plano.
|
product
|
string
|
Especifica o produto da imagem do marketplace. Esse é o mesmo valor que Offer no elemento imageReference.
|
promotionCode
|
string
|
O código de promoção.
|
publisher
|
string
|
A ID do editor.
|
PriorityMixPolicy
Especifica as divisões de destino para VMs de prioridade spot e regular em um conjunto de dimensionamento 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 do VMSS é expandida e a divisão entre VMs de prioridade regular e Spot após esse destino base ter sido atingido.
Nome |
Tipo |
Description |
baseRegularPriorityCount
|
integer
|
O número base de VMs de prioridade regular que serão criadas neste conjunto de dimensionamento conforme ele é dimensionado.
|
regularPriorityPercentageAboveBase
|
integer
|
O percentual de instâncias de VM, após a contagem de prioridade regular base ter sido atingida, que deverá usar a prioridade regular.
|
ProtocolTypes
Especifica o protocolo do ouvinte WinRM. Os valores possíveis são: http,https.
Nome |
Tipo |
Description |
Http
|
string
|
|
Https
|
string
|
|
ProxyAgentSettings
Especifica as configurações de ProxyAgent ao criar a máquina virtual. Versão mínima da API: 2023-09-01.
Nome |
Tipo |
Description |
enabled
|
boolean
|
Especifica se o recurso ProxyAgent deve ser habilitado na máquina virtual ou no conjunto de dimensionamento de máquinas virtuais.
|
keyIncarnationId
|
integer
|
Aumentar o valor dessa propriedade permite que o usuário redefina a chave usada para proteger o canal de comunicação entre o convidado e o host.
|
mode
|
Mode
|
Especifica o modo no qual o ProxyAgent será executado se o recurso estiver habilitado. O ProxyAgent começará a auditar ou monitorar, mas não imporá o controle de acesso sobre solicitações para hospedar pontos de extremidade no modo auditoria, enquanto no modo Impor imporá o controle de acesso. O valor padrão é o modo Impor.
|
PublicIPAddressSku
Descreve o Sku de IP público. Ele só pode ser definido com OrchestrationMode como Flexível.
PublicIPAddressSkuName
Especificar o nome do sku de IP público
Nome |
Tipo |
Description |
Basic
|
string
|
|
Standard
|
string
|
|
PublicIPAddressSkuTier
Especificar a camada de sku de IP público
Nome |
Tipo |
Description |
Global
|
string
|
|
Regional
|
string
|
|
RepairAction
Tipo de ação de reparo (substituir, reiniciar, reimagem) que será usada para reparar máquinas virtuais não íntegras no conjunto de dimensionamento. O valor padrão é substituir.
Nome |
Tipo |
Description |
Reimage
|
string
|
|
Replace
|
string
|
|
Restart
|
string
|
|
ResiliencyPolicy
Descreve uma política de resiliência - resilientVMCreationPolicy e/ou resilientVMDeletionPolicy.
Nome |
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 durante a execução da exclusão de VM resiliente.
|
ResilientVMCreationPolicy
Os parâmetros de configuração usados durante a execução da criação de VM resiliente.
Nome |
Tipo |
Description |
enabled
|
boolean
|
Especifica se a criação de VM resiliente deve ser habilitada no conjunto de dimensionamento de máquinas virtuais. O valor padrão é false.
|
ResilientVMDeletionPolicy
Os parâmetros de configuração usados durante a execução da exclusão de VM resiliente.
Nome |
Tipo |
Description |
enabled
|
boolean
|
Especifica se a exclusão de VM resiliente deve ser habilitada no conjunto de dimensionamento de máquinas virtuais. O valor padrão é false.
|
ResourceIdentityType
O tipo de identidade usado para o conjunto de dimensionamento de máquinas virtuais. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'None' removerá as identidades do conjunto de dimensionamento de máquinas virtuais.
Nome |
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 sem interrupção.
Nome |
Tipo |
Description |
enableCrossZoneUpgrade
|
boolean
|
Permitir que o VMSS ignore os limites do 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 é um máximo, instâncias não íntegras em lotes anteriores ou futuros podem fazer com que o percentual 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 dimensionamento, em vez de atualizar as máquinas virtuais existentes. As máquinas virtuais existentes serão excluídas depois que as novas máquinas virtuais forem criadas para cada lote.
|
maxUnhealthyInstancePercent
|
integer
|
O percentual máximo do total de instâncias de máquina virtual no conjunto de dimensionamento que pode ser simultaneamente não íntegro, seja como resultado da atualização ou por ser encontrado em um estado não íntegro pelas verificações de integridade da máquina virtual antes que a atualização sem interrupção seja anulada. Essa restrição será verificada antes de iniciar qualquer lote. O valor padrão para esse parâmetro é 20%.
|
maxUnhealthyUpgradedInstancePercent
|
integer
|
O percentual máximo de instâncias de máquina virtual atualizadas que podem ser encontradas em um estado não íntegro. Essa verificação ocorrerá depois que cada lote for atualizado. Se esse percentual for excedido, a atualização sem interrupção será anulada. O valor padrão para esse parâmetro é 20%.
|
pauseTimeBetweenBatches
|
string
|
O tempo de espera entre concluir a atualização de todas as máquinas virtuais em um lote e iniciar o próximo lote. A duração do tempo deve ser especificada no formato ISO 8601. O valor padrão é PT0S (0 segundos).
|
prioritizeUnhealthyInstances
|
boolean
|
Atualize todas as instâncias não íntegras em um conjunto de dimensionamento antes de qualquer instância íntegra.
|
rollbackFailedInstancesOnPolicyBreach
|
boolean
|
Reverter instâncias com falha para o modelo anterior se a política de Atualização Sem Interrupção for violada.
|
ScaleInPolicy
Descreve uma política de dimensionamento para um conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
forceDeletion
|
boolean
|
Essa propriedade permite especificar se as máquinas virtuais escolhidas para remoção devem ser forçadas a serem excluídas quando um conjunto de dimensionamento de máquinas virtuais está sendo dimensionado. (Recurso em versão prévia)
|
rules
|
VirtualMachineScaleSetScaleInRules[]
|
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquinas virtuais.
Os valores possíveis são:
Padrão Quando um conjunto de dimensionamento de máquinas virtuais é dimensionado, o conjunto de dimensionamento será primeiro equilibrado entre zonas se for um conjunto de dimensionamento zonal. Em seguida, ele será equilibrado entre domínios de falha na medida do possível. Em 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 o scale-in.
OldestVM quando um conjunto de dimensionamento de máquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em 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áquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra a escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em cada zona, as máquinas virtuais mais recentes que não estão protegidas serão escolhidas para remoção.
|
ScheduledEventsAdditionalPublishingTargets
Nome |
Tipo |
Description |
eventGridAndResourceGraph
|
EventGridAndResourceGraph
|
Os parâmetros de configuração usados durante a criação da configuração de evento agendado eventGridAndResourceGraph.
|
ScheduledEventsPolicy
Especifica a reimplantação, reinicialização e configurações relacionadas ao evento agendado ScheduledEventsAdditionalPublishingTargets.
Nome |
Tipo |
Description |
scheduledEventsAdditionalPublishingTargets
|
ScheduledEventsAdditionalPublishingTargets
|
Os parâmetros de configuração usados durante a publicação de scheduledEventsAdditionalPublishingTargets.
|
userInitiatedReboot
|
UserInitiatedReboot
|
Os parâmetros de configuração usados durante a criação da criação da configuração de evento agendada userInitiatedReboot.
|
userInitiatedRedeploy
|
UserInitiatedRedeploy
|
Os parâmetros de configuração usados durante a criação da criação da configuração de evento agendada userInitiatedRedeploy.
|
ScheduledEventsProfile
Nome |
Tipo |
Description |
osImageNotificationProfile
|
OSImageNotificationProfile
|
Especifica as configurações relacionadas ao evento agendado da imagem do sistema operacional.
|
terminateNotificationProfile
|
TerminateNotificationProfile
|
Especifica encerrar configurações relacionadas a eventos agendados.
|
securityEncryptionTypes
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado juntamente com blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado de firmware no blob VMGuestState..
Observação: Ele pode ser definido apenas para VMs confidenciais.
Nome |
Tipo |
Description |
DiskWithVMGuestState
|
string
|
|
NonPersistedTPM
|
string
|
|
VMGuestStateOnly
|
string
|
|
SecurityPostureReference
Especifica a postura de segurança a ser usada no conjunto de dimensionamento. Versão mínima da API: 2023-03-01
Nome |
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
|
A ID de referência de postura de segurança na forma de /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|mais recente
|
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 de máquinas virtuais.
Nome |
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áquinas virtuais. 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 verdadeira para o recurso.
|
encryptionIdentity
|
EncryptionIdentity
|
Especifica a Identidade Gerenciada usada pelo ADE para obter o token de acesso para operações de keyvault.
|
proxyAgentSettings
|
ProxyAgentSettings
|
Especifica as configurações de 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 mínima da API: 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.
Nome |
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 dimensionamento ao usar a versão de imagem 'mais recente'. Versão mínima da API: 2022-11-01
Nome |
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.
Nome |
Tipo |
Description |
AutoLogon
|
string
|
|
FirstLogonCommands
|
string
|
|
Sku
Descreve um sku do conjunto de dimensionamento de máquinas virtuais. OBSERVAÇÃO: Se não houver suporte para a nova SKU de VM no hardware em que o conjunto de dimensionamento está atualmente, você precisará desalocar as VMs no conjunto de dimensionamento antes de modificar o nome da SKU.
Nome |
Tipo |
Description |
capacity
|
integer
|
Especifica o número de máquinas virtuais no conjunto de dimensionamento.
|
name
|
string
|
O nome do sku.
|
tier
|
string
|
Especifica a camada de máquinas virtuais em um conjunto de dimensionamento.
Valores possíveis:
Standard
Básico
|
SkuProfile
Especifica o perfil de sku para o conjunto de dimensionamento de máquinas virtuais. Com essa propriedade, o cliente pode especificar uma lista de tamanhos de VM e uma estratégia de alocação.
Nome |
Tipo |
Description |
allocationStrategy
|
AllocationStrategy
|
Especifica a estratégia de alocação para o conjunto de dimensionamento de máquinas virtuais com base no qual as VMs serão alocadas.
|
vmSizes
|
SkuProfileVMSize[]
|
Especifica os tamanhos da VM para o conjunto de dimensionamento de máquinas virtuais.
|
SkuProfileVMSize
Especifica o tamanho da VM.
Nome |
Tipo |
Description |
name
|
string
|
Especifica o nome do Tamanho da VM.
|
SpotRestorePolicy
Especifica as propriedades spot-Try-Restore para o conjunto de dimensionamento de máquinas virtuais. Com essa propriedade, o cliente pode habilitar ou desabilitar a restauração automática das instâncias de VM do Spot VMSS removidas de forma oportunista com base na disponibilidade da capacidade e na restrição de preços.
Nome |
Tipo |
Description |
enabled
|
boolean
|
Habilita o recurso Spot-Try-Restore em que as instâncias SPOT do VMSS removidas serão tentadas para serem restauradas de forma oportunista com base na disponibilidade da capacidade e nas restrições de preços
|
restoreTimeout
|
string
|
Valor de tempo limite expresso como uma duração de tempo ISO 8601 após a qual a plataforma não tentará restaurar as instâncias SPOT do VMSS
|
SshConfiguration
Configuração de SSH para VMs baseadas em Linux em execução no Azure
Nome |
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 do Linux em que a chave pública é colocada.
Nome |
Tipo |
Description |
keyData
|
string
|
Certificado de chave pública SSH usado para autenticar com a VM por meio do ssh. A chave precisa ter pelo menos 2048 bits e no formato ssh-rsa. Para criar chaves ssh, consulte [Criar chaves SSH em VMs Linux e Mac para Linux no Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed).
|
path
|
string
|
Especifica o caminho completo na VM criada em que a chave pública ssh é armazenada. Se o arquivo já existir, a chave especificada será acrescentada ao arquivo. Exemplo: /home/user/.ssh/authorized_keys
|
StorageAccountTypes
Especifica o tipo de conta de armazenamento para o disco gerenciado. OBSERVAÇÃO: UltraSSD_LRS só pode ser usado com discos de dados, ele não pode ser usado com o Disco do SISTEMA Operacional.
Nome |
Tipo |
Description |
PremiumV2_LRS
|
string
|
|
Premium_LRS
|
string
|
|
Premium_ZRS
|
string
|
|
StandardSSD_LRS
|
string
|
|
StandardSSD_ZRS
|
string
|
|
Standard_LRS
|
string
|
|
UltraSSD_LRS
|
string
|
|
SubResource
Nome |
Tipo |
Description |
id
|
string
|
ID do recurso
|
TerminateNotificationProfile
Nome |
Tipo |
Description |
enable
|
boolean
|
Especifica se o evento Encerrar Agendado está habilitado ou desabilitado.
|
notBeforeTimeout
|
string
|
O período configurável de tempo que uma Máquina Virtual que está sendo excluída terá que possivelmente aprovar 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 mínima da API: 2020-12-01.
Nome |
Tipo |
Description |
secureBootEnabled
|
boolean
|
Especifica se a inicialização segura deve ser habilitada na máquina virtual. Versão mínima da API: 2020-12-01.
|
vTpmEnabled
|
boolean
|
Especifica se o vTPM deve ser habilitado na máquina virtual. Versão mínima da API: 2020-12-01.
|
UpgradeMode
Especifica o modo de uma atualização para máquinas virtuais no conjunto de dimensionamento.
Os valores possíveis são:
Manual – você controla a aplicação de atualizações para máquinas virtuais no conjunto de dimensionamento. Faça isso usando a ação manualUpgrade.
automático – todas as máquinas virtuais no conjunto de dimensionamento são atualizadas automaticamente ao mesmo tempo.
Nome |
Tipo |
Description |
Automatic
|
string
|
|
Manual
|
string
|
|
Rolling
|
string
|
|
UpgradePolicy
Descreve uma política de atualização – automática, manual ou sem interrupção.
Nome |
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 dimensionamento.
Os valores possíveis são:
Manual – você controla a aplicação de atualizações para máquinas virtuais no conjunto de dimensionamento. Faça isso usando a ação manualUpgrade.
automático – todas as máquinas virtuais no conjunto de dimensionamento são atualizadas automaticamente ao mesmo tempo.
|
rollingUpgradePolicy
|
RollingUpgradePolicy
|
Os parâmetros de configuração usados durante a execução de uma atualização sem interrupção.
|
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 do ARM no formulário: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
UserInitiatedReboot
Especifica as configurações relacionadas ao Evento Agendado relacionadas à reinicialização.
Nome |
Tipo |
Description |
automaticallyApprove
|
boolean
|
Especifica as configurações relacionadas ao evento agendado de reinicialização.
|
UserInitiatedRedeploy
Especifica as configurações relacionadas ao Evento Agendado relacionadas à reimplantação.
Nome |
Tipo |
Description |
automaticallyApprove
|
boolean
|
Especifica as configurações relacionadas ao Evento Agendado de Reimplantação.
|
VaultCertificate
Descreve uma única referência de certificado em um Key Vault e onde o certificado deve residir na VM.
Nome |
Tipo |
Description |
certificateStore
|
string
|
Para VMs do Windows, especifica o repositório de certificados na Máquina Virtual à qual o certificado deve ser adicionado. O repositório 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 formatados em .pem.
|
certificateUrl
|
string
|
Essa é a URL de um certificado que foi carregado no Key Vault como um segredo. Para adicionar um segredo ao Key Vault, consulte Adicionar uma chave ou segredo ao cofre de chaves. Nesse caso, seu certificado precisa ser a codificação Base64 do seguinte objeto JSON codificado em UTF-8:
{ "data":"", "dataType":"pfx", "password":"" } Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual 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 Key Vault.
Nome |
Tipo |
Description |
sourceVault
|
SubResource
|
A URL relativa do Key Vault 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.
Nome |
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 spot do Azure e o conjunto de dimensionamento spot do Azure. Para máquinas virtuais spot do Azure, há suporte para 'Desalocar' e 'Excluir' e a versão mínima da API é 2019-03-01. Para conjuntos de dimensionamento do Spot do Azure, há suporte para 'Desalocar' e 'Excluir' e a versão mínima da API é 2017-10-30-preview.
Nome |
Tipo |
Description |
Deallocate
|
string
|
|
Delete
|
string
|
|
VirtualMachinePriorityTypes
Especifica a prioridade das máquinas virtuais no conjunto de dimensionamento. Versão mínima da api: 2017-10-30-preview.
Nome |
Tipo |
Description |
Low
|
string
|
|
Regular
|
string
|
|
Spot
|
string
|
|
VirtualMachineScaleSet
Descreve um conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
etag
|
string
|
A etag é a propriedade retornada em Criar/Atualizar/Obter resposta 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áquinas Virtuais.
|
id
|
string
|
ID do recurso
|
identity
|
VirtualMachineScaleSetIdentity
|
A identidade do conjunto de dimensionamento de máquinas virtuais, se configurado.
|
location
|
string
|
Local do recurso
|
name
|
string
|
Nome do recurso
|
plan
|
Plan
|
Especifica informações sobre a imagem do marketplace usada para criar a máquina virtual. Esse elemento é usado apenas para imagens do marketplace. Antes de usar uma imagem do marketplace de uma API, você deve habilitar a imagem para uso programático. No portal do Azure, localize a imagem do marketplace que você deseja usar e clique em Deseja implantar programaticamente, Introdução –>. Insira as informações necessárias e clique em Salvar.
|
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 dar suporte à anexação de discos de dados gerenciados com UltraSSD_LRS tipo de conta de armazenamento.
|
properties.automaticRepairsPolicy
|
AutomaticRepairsPolicy
|
Política para reparos automáticos.
|
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 apenas no número solicitado de VMs que são finalmente mantidas. Dessa forma, essa propriedade garantirá que as extensões não sejam executadas nas VMs extraprovisionadas.
|
properties.hostGroup
|
SubResource
|
Especifica informações sobre o grupo de hosts dedicado no qual reside o conjunto de dimensionamento de máquinas virtuais. Versão mínima da API: 2020-06-01.
|
properties.orchestrationMode
|
OrchestrationMode
|
Especifica o modo de orquestração para o conjunto de dimensionamento de máquinas virtuais.
|
properties.overprovision
|
boolean
|
Especifica se o Conjunto de Dimensionamento de Máquinas Virtuais deve ser superprovisionado.
|
properties.platformFaultDomainCount
|
integer
|
Contagem de domínios de falha para cada grupo de posicionamento.
|
properties.priorityMixPolicy
|
PriorityMixPolicy
|
Especifica os destinos desejados para misturar VMs spot e de prioridade regular na mesma instância do VMSS Flex.
|
properties.provisioningState
|
string
|
O estado de provisionamento, que aparece apenas na resposta.
|
properties.proximityPlacementGroup
|
SubResource
|
Especifica informações sobre o grupo de posicionamento por proximidade ao qual o conjunto de dimensionamento de máquinas virtuais deve ser atribuído. Versão mínima da API: 2018-04-01.
|
properties.resiliencyPolicy
|
ResiliencyPolicy
|
Política de resiliência
|
properties.scaleInPolicy
|
ScaleInPolicy
|
Especifica as políticas aplicadas ao dimensionamento em Máquinas Virtuais no Conjunto de Dimensionamento de Máquinas Virtuais.
|
properties.scheduledEventsPolicy
|
ScheduledEventsPolicy
|
O ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
boolean
|
Quando true, isso limita o conjunto de dimensionamento a um único grupo de posicionamento, de tamanho máximo de 100 máquinas virtuais. OBSERVAÇÃO: se singlePlacementGroup for true, ele poderá ser modificado para false. No entanto, se singlePlacementGroup for false, ele poderá não ser modificado para true.
|
properties.skuProfile
|
SkuProfile
|
Especifica o perfil de sku para o conjunto de dimensionamento de máquinas virtuais.
|
properties.spotRestorePolicy
|
SpotRestorePolicy
|
Especifica as propriedades do Spot Restore para o conjunto de dimensionamento de máquinas virtuais.
|
properties.timeCreated
|
string
|
Especifica a hora em que o recurso Conjunto de Dimensionamento de Máquinas Virtuais foi criado. Versão mínima da API: 2021-11-01.
|
properties.uniqueId
|
string
|
Especifica a ID que identifica exclusivamente um Conjunto de Dimensionamento de Máquinas Virtuais.
|
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 Dimensionamento de Máquinas Virtuais e a contagem de domínios de falha de armazenamento.
|
properties.zoneBalance
|
boolean
|
Se deve forçar estritamente até mesmo a distribuição de Máquina Virtual entre zonas x no caso de haver interrupção de zona. A propriedade zoneBalance só poderá ser definida se a propriedade zones do conjunto de dimensionamento 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 dimensionamento de máquinas virtuais.
|
tags
|
object
|
Marcas de recurso
|
type
|
string
|
Tipo de recurso
|
zones
|
string[]
|
As zonas do conjunto de dimensionamento de máquinas virtuais.
|
VirtualMachineScaleSetDataDisk
Descreve um disco de dados do conjunto de dimensionamento de máquinas virtuais.
Nome |
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 Standard. 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 OrchestrationMode Flexível).
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á mantido após a exclusão da VM VMSS Flex.
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 de 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 anexado a uma VM.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Os parâmetros de 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 do conjunto de dimensionamento de máquinas virtuais.
Nome |
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 de 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 configurações protegidas de extensõ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 o qual essa extensão precisa ser provisionada.
|
properties.provisioningState
|
string
|
O estado de provisionamento, que aparece apenas na resposta.
|
properties.publisher
|
string
|
O nome do editor do manipulador de extensão.
|
properties.settings
|
object
|
Configurações públicas formatadas em Json 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 do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
extensions
|
VirtualMachineScaleSetExtension[]
|
Os recursos de extensão filho do conjunto de dimensionamento de máquinas virtuais.
|
extensionsTimeBudget
|
string
|
Especifica o tempo alocado para que todas as extensões comecem. A duração do tempo deve estar entre 15 minutos e 120 minutos (inclusive) e deve ser especificada no formato ISO 8601. O valor padrão é 90 minutos (PT1H30M). Versão mínima da API: 2020-06-01.
|
VirtualMachineScaleSetHardwareProfile
Especifica as configurações de hardware para o conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
vmSizeProperties
|
VMSizeProperties
|
Especifica as propriedades para personalizar o tamanho da máquina virtual. Versão mínima da API: 2021-11-01. Siga as instruções em de Personalização de VM para obter mais detalhes.
|
VirtualMachineScaleSetIdentity
Identidade do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
principalId
|
string
|
A ID principal da identidade do conjunto de dimensionamento de máquinas virtuais. Essa propriedade será fornecida apenas para uma identidade atribuída pelo sistema.
|
tenantId
|
string
|
A ID do locatário associada ao conjunto de dimensionamento de máquinas virtuais. Essa propriedade será fornecida apenas para uma identidade atribuída pelo sistema.
|
type
|
ResourceIdentityType
|
O tipo de identidade usado para o conjunto de dimensionamento de máquinas virtuais. O tipo 'SystemAssigned, UserAssigned' inclui uma identidade criada implicitamente e um conjunto de identidades atribuídas pelo usuário. O tipo 'None' removerá as identidades do conjunto de dimensionamento de máquinas virtuais.
|
userAssignedIdentities
|
UserAssignedIdentities
|
A lista de identidades de usuário associadas ao conjunto de dimensionamento de máquinas virtuais. As referências de chave do dicionário de identidade do usuário serão IDs de recurso do ARM no formulário: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
VirtualMachineScaleSetIPConfiguration
Descreve a configuração de IP de um perfil de rede do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
name
|
string
|
O nome da configuração de IP.
|
properties.applicationGatewayBackendAddressPools
|
SubResource[]
|
Especifica uma matriz de referências para pools de endereços de back-end de gateways de aplicativo. Um conjunto de dimensionamento pode referenciar pools de endereços de back-end de vários gateways de aplicativo. Vários conjuntos de dimensionamento 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 para pools de endereços de back-end de balanceadores de carga. Um conjunto de dimensionamento pode referenciar pools de endereços de back-end de um balanceador de carga público e interno. Vários conjuntos de dimensionamento não podem usar o mesmo balanceador de carga de sku básico.
|
properties.loadBalancerInboundNatPools
|
SubResource[]
|
Especifica uma matriz de referências aos pools nat de entrada dos balanceadores de carga. Um conjunto de dimensionamento pode referenciar pools nat de entrada de um balanceador de carga público e um interno. Vários conjuntos de dimensionamento não podem usar o mesmo balanceador de carga de sku básico.
|
properties.primary
|
boolean
|
Especifica o adaptador de rede primário caso a máquina virtual tenha mais de 1 adaptador de rede.
|
properties.privateIPAddressVersion
|
IPVersion
|
Disponível de Api-Version 2017-03-30 em diante, ele representa se a ipconfiguração específica é IPv4 ou IPv6. O padrão é usado como 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.
Nome |
Tipo |
Description |
ipTagType
|
string
|
Tipo de marca IP. Exemplo: FirstPartyUsage.
|
tag
|
string
|
Marca de IP associada ao IP público. Exemplo: SQL, Armazenamento etc.
|
VirtualMachineScaleSetManagedDiskParameters
Descreve os parâmetros de um disco gerenciado ScaleSet.
Nome |
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 do disco gerenciado.
|
storageAccountType
|
StorageAccountTypes
|
Especifica o tipo de conta de armazenamento para o disco gerenciado. OBSERVAÇÃO: UltraSSD_LRS só pode ser usado com discos de dados, ele não pode ser usado com o Disco do SISTEMA Operacional.
|
VirtualMachineScaleSetNetworkConfiguration
Descreve as configurações de rede do perfil de rede de um conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
name
|
string
|
O nome da configuração de rede.
|
properties.auxiliaryMode
|
NetworkInterfaceAuxiliaryMode
|
Especifica se o modo Auxiliar está habilitado para o recurso de Interface de Rede.
|
properties.auxiliarySku
|
NetworkInterfaceAuxiliarySku
|
Especifica se o sku auxiliar está habilitado para o recurso de Interface de Rede.
|
properties.deleteOption
|
DeleteOptions
|
Especificar o que acontece com o adaptador de rede quando a VM é excluída
|
properties.disableTcpStateTracking
|
boolean
|
Especifica se o adaptador de rede está desabilitado para o acompanhamento de estado tcp.
|
properties.dnsSettings
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
As configurações de dns a serem aplicadas nos adaptadores de rede.
|
properties.enableAcceleratedNetworking
|
boolean
|
Especifica se o adaptador de rede está habilitado para rede acelerada.
|
properties.enableFpga
|
boolean
|
Especifica se o adaptador de rede está habilitado para rede FPGA.
|
properties.enableIPForwarding
|
boolean
|
Se o encaminhamento de IP está habilitado nessa NIC.
|
properties.ipConfigurations
|
VirtualMachineScaleSetIPConfiguration[]
|
Especifica as configurações de IP do adaptador de rede.
|
properties.networkSecurityGroup
|
SubResource
|
O grupo de segurança de rede.
|
properties.primary
|
boolean
|
Especifica o adaptador de rede primário caso a máquina virtual tenha mais de 1 adaptador de rede.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
Descreve as configurações DNS de uma configuração de rede de conjuntos de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
dnsServers
|
string[]
|
Lista de endereços IP de servidores DNS
|
VirtualMachineScaleSetNetworkProfile
Descreve um perfil de rede de conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
healthProbe
|
ApiEntityReference
|
Uma referência a uma investigação de balanceador de carga usada para determinar a integridade de uma instância no conjunto de dimensionamento de máquinas virtuais. A referência estará no formulário: '/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 o Conjunto de Dimensionamento de Máquinas Virtuais com o 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áquinas virtuais.
Nome |
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 Standard. ReadOnly para armazenamento Premium.
|
createOption
|
DiskCreateOptionTypes
|
Especifica como as máquinas virtuais no conjunto de dimensionamento 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 OrchestrationMode Flexível).
Valores possíveis:
Excluir Se esse valor for usado, o disco do sistema operacional será excluído quando a VM VMSS Flex for excluída.
Desanexar Se esse valor for usado, o disco do sistema operacional será mantido após a exclusão da VM VMSS Flex.
O valor padrão é definido como Excluir. Para um disco do sistema operacional efêmero, o valor padrão é definido como Excluir. O usuário não pode alterar a opção de exclusão do Disco do SO Efêmero.
|
diffDiskSettings
|
DiffDiskSettings
|
Especifica as configurações de disco efêmero para o disco do sistema operacional usado pelo conjunto de dimensionamento de máquinas virtuais.
|
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 de usuário não gerenciada para basear o conjunto de dimensionamento.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Os parâmetros de disco gerenciado.
|
name
|
string
|
O nome do disco.
|
osType
|
OperatingSystemTypes
|
Essa propriedade permite que você especifique o tipo do sistema operacional incluído no disco se criar uma VM com base na imagem do usuário ou em um VHD especializado. Os valores possíveis são: Windows,Linux.
|
vhdContainers
|
string[]
|
Especifica as URLs de contêiner usadas para armazenar discos do sistema operacional para o conjunto de dimensionamento.
|
writeAcceleratorEnabled
|
boolean
|
Especifica se writeAccelerator deve ser habilitado ou desabilitado no disco.
|
VirtualMachineScaleSetOSProfile
Descreve um perfil do sistema operacional do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
adminPassword
|
string
|
Especifica a senha da conta de administrador.
Comprimento mínimo (Windows): 8 caracteres
Comprimento mínimo (Linux): 6 caracteres
comprimento máximo (Windows): 123 caracteres
comprimento máximo (Linux): 72 caracteres
requisitos de complexidade: 3 de 4 condições abaixo precisam ser atendidas Tem caracteres inferiores Tem caracteres superiores Tem um dígito Tem um caractere especial (correspondência regex [\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 logon em uma VM do Windows
Para redefinir a senha raiz, 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 do Windows: Não é possível terminar em "".
valores não permitidos: "administrador", "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
comprimento máximo (Linux): 64 caracteres
comprimento máximo (Windows): 20 caracteres
|
allowExtensionOperations
|
boolean
|
Especifica se as operações de extensão devem ser permitidas no conjunto de dimensionamento de máquinas virtuais. Isso só poderá ser definido como False quando nenhuma extensão estiver presente no conjunto de dimensionamento de máquinas virtuais.
|
computerNamePrefix
|
string
|
Especifica o prefixo de nome do computador para todas as máquinas virtuais no conjunto de dimensionamento. Os prefixos de nome do 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 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 do 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 do Linux com suporte, consulte Linux nodistribuições de Azure-Endorsed.
|
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 dimensionamento. Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual 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 a configuração publicIPAddress de um conjunto de dimensionamento de máquinas virtuais
Nome |
Tipo |
Description |
name
|
string
|
O nome da configuração de endereço publicIP.
|
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 publicIP.
|
properties.idleTimeoutInMinutes
|
integer
|
O tempo limite ocioso do endereço IP público.
|
properties.ipTags
|
VirtualMachineScaleSetIpTag[]
|
A lista de marcas IP associadas ao endereço IP público.
|
properties.publicIPAddressVersion
|
IPVersion
|
Disponível de Api-Version 2019-07-01 em diante, ele representa se a ipconfiguração específica é IPv4 ou IPv6. O padrão é usado como IPv4. Os valores possíveis são: 'IPv4' e 'IPv6'.
|
properties.publicIPPrefix
|
SubResource
|
O PublicIPPrefix do qual alocar endereços publicIP.
|
sku
|
PublicIPAddressSku
|
Descreve o Sku de IP público. Ele só pode ser definido com OrchestrationMode como Flexível.
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
Descreve as configurações DNS de uma configuração de rede de conjuntos de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
domainNameLabel
|
string
|
O rótulo de nome de domínio. A concatenação do rótulo de nome de domínio e do índice de 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 hash que foi gerado de acordo com a política do escopo do rótulo de nome de domínio e do índice de VM serão os rótulos de nome de domínio dos recursos PublicIPAddress que serão criados
|
VirtualMachineScaleSetScaleInRules
As regras a serem seguidas ao dimensionar um conjunto de dimensionamento de máquinas virtuais.
Os valores possíveis são:
Padrão Quando um conjunto de dimensionamento de máquinas virtuais é dimensionado, o conjunto de dimensionamento será primeiro equilibrado entre zonas se for um conjunto de dimensionamento zonal. Em seguida, ele será equilibrado entre domínios de falha na medida do possível. Em 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 o scale-in.
OldestVM quando um conjunto de dimensionamento de máquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais antigas que não estão protegidas contra escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em 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áquinas virtuais estiver sendo dimensionado, as máquinas virtuais mais recentes que não estão protegidas contra a escala serão escolhidas para remoção. Para conjuntos de dimensionamento de máquinas virtuais zonais, o conjunto de dimensionamento será primeiro equilibrado entre zonas. Em cada zona, as máquinas virtuais mais recentes que não estão protegidas serão escolhidas para remoção.
Nome |
Tipo |
Description |
Default
|
string
|
|
NewestVM
|
string
|
|
OldestVM
|
string
|
|
VirtualMachineScaleSetStorageProfile
Descreve um perfil de armazenamento do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
dataDisks
|
VirtualMachineScaleSetDataDisk[]
|
Especifica os parâmetros usados para adicionar discos de dados às máquinas virtuais no conjunto de dimensionamento. 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 dimensionamento. 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 do marketplace ou imagens de máquina virtual. Esse elemento é necessário quando você deseja usar uma imagem de plataforma, uma imagem do marketplace ou uma 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 dimensionamento. 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 do conjunto de dimensionamento de máquinas virtuais.
Nome |
Tipo |
Description |
applicationProfile
|
ApplicationProfile
|
Especifica os aplicativos da 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 mínima da API: 2019-03-01.
|
capacityReservation
|
CapacityReservationProfile
|
Especifica os detalhes relacionados à reserva de capacidade de um conjunto de dimensionamento. Versão mínima da 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 spot do Azure e o conjunto de dimensionamento spot do Azure. Para máquinas virtuais spot do Azure, há suporte para 'Desalocar' e 'Excluir' e a versão mínima da API é 2019-03-01. Para conjuntos de dimensionamento do Spot do Azure, há suporte para 'Desalocar' 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 dimensionamento.
|
hardwareProfile
|
VirtualMachineScaleSetHardwareProfile
|
Especifica os detalhes relacionados ao perfil de hardware de um conjunto de dimensionamento. Versão mínima da 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 o Windows Server
Benefício de Uso Híbrido do Azure para o 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 dimensionamento.
|
osProfile
|
VirtualMachineScaleSetOSProfile
|
Especifica as configurações do sistema operacional para as máquinas virtuais no conjunto de dimensionamento.
|
priority
|
VirtualMachinePriorityTypes
|
Especifica a prioridade das máquinas virtuais no conjunto de dimensionamento. Versão mínima da api: 2017-10-30-preview.
|
scheduledEventsProfile
|
ScheduledEventsProfile
|
Especifica configurações relacionadas a eventos agendados.
|
securityPostureReference
|
SecurityPostureReference
|
Especifica a postura de segurança a ser usada no conjunto de dimensionamento. 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 dimensionamento.
|
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 dimensionamento ao usar a versão de imagem 'mais recente'. Versão mínima da 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áquinas Virtuais foi criado. Esse valor será adicionado às marcas de VM flex do VMSS ao criar/atualizar o Perfil da VM VMSS. A versão mínima da API para essa propriedade é 2023-09-01.
|
userData
|
string
|
UserData para as máquinas virtuais no conjunto de dimensionamento, que deve ser codificado em base 64. O cliente não deve passar segredos aqui. Versão mínima da API: 2021-03-01.
|
VMDiskSecurityProfile
Especifica as configurações de perfil de segurança para o disco gerenciado.
Observação: Ele só pode ser definido para VMs confidenciais.
Nome |
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 pelo Cliente criptografado disco do sistema operacional ConfidentialVM e blob VMGuest.
|
securityEncryptionType
|
securityEncryptionTypes
|
Especifica o EncryptionType do disco gerenciado. Ele é definido como DiskWithVMGuestState para criptografia do disco gerenciado juntamente com blob VMGuestState, VMGuestStateOnly para criptografia apenas do blob VMGuestState e NonPersistedTPM para não persistir o estado de firmware no blob VMGuestState..
Observação: 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
Nome |
Tipo |
Description |
configurationReference
|
string
|
Opcional, especifica o uri para um blob do azure que substituirá a configuração padrão do pacote, se fornecido
|
enableAutomaticUpgrade
|
boolean
|
Se definido como true, quando uma nova versão do Aplicativo da Galeria estiver disponível no PIR/SIG, ela será atualizada automaticamente para a VM/VMSS
|
order
|
integer
|
Opcional, especifica a ordem na qual os pacotes precisam ser instalados
|
packageReferenceId
|
string
|
Especifica a ID do recurso GalleryApplicationVersion na forma de /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}
|
tags
|
string
|
Opcional, especifica um valor de passagem para um contexto mais genérico.
|
treatFailureAsDeploymentFailure
|
boolean
|
Opcional, se for true, qualquer falha em qualquer operação no VmApplication falhará na implantação
|
VMSizeProperties
Especifica as configurações da Propriedade tamanho da VM na máquina virtual.
Nome |
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 para o valor de vCPUs disponíveis para esse tamanho de VM exposto na resposta à API de Listar todos os tamanhos de máquina virtual disponíveis em uma região.
|
vCPUsPerCore
|
integer
|
Especifica a relação vCPU com 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 à 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 hiper-threading está desabilitado.
|
WindowsConfiguration
Especifica as configurações do sistema operacional Windows na máquina virtual.
Nome |
Tipo |
Description |
additionalUnattendContent
|
AdditionalUnattendContent[]
|
Especifica informações XML codificadas em base 64 adicionais 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 é verdadeiro. Para conjuntos de dimensionamento de máquinas virtuais, 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
|
[Recurso de visualização] Especifica as configurações relacionadas à aplicação de patch de convidado da 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, "Horário 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 de Gerenciamento Remoto do Windows. Isso habilita o Windows PowerShell remoto.
|
WindowsPatchAssessmentMode
Especifica o modo de avaliação de patch 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 disparará avaliações periódicas de patch. A propriedade provisionVMAgent deve ser verdadeira.
Nome |
Tipo |
Description |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Especifica a configuração de reinicialização para todas as operações de instalação de patch AutomaticByPlatform.
Nome |
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.
Nome |
Tipo |
Description |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Permite que o cliente agende a aplicação de patch sem atualizações acidentais
|
rebootSetting
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Especifica a configuração de reinicialização para todas as operações de instalação de patch AutomaticByPlatform.
|
WindowsVMGuestPatchMode
Especifica o modo de aplicação de patch de convidado de VM para máquina virtual IaaS ou máquinas virtuais associadas ao conjunto de dimensionamento de máquinas virtuais com OrchestrationMode como Flexível.
Os valores possíveis são:
manual – você controla a aplicação de patches em uma máquina virtual. Faça isso aplicando patches manualmente dentro da VM. Nesse modo, as atualizações automáticas são desabilitadas; a propriedade WindowsConfiguration.enableAutomaticUpdates deve ser falsa
AutomaticByOS – a máquina virtual será atualizada automaticamente pelo sistema operacional. A propriedade WindowsConfiguration.enableAutomaticUpdates deve ser verdadeira.
AutomaticByPlatform – a máquina virtual será atualizada automaticamente pela plataforma. As propriedades provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devem ser verdadeiras
Nome |
Tipo |
Description |
AutomaticByOS
|
string
|
|
AutomaticByPlatform
|
string
|
|
Manual
|
string
|
|
WinRMConfiguration
Descreve a configuração de Gerenciamento Remoto do Windows da VM
Nome |
Tipo |
Description |
listeners
|
WinRMListener[]
|
A lista de ouvintes de Gerenciamento Remoto do Windows
|
WinRMListener
Descreve o protocolo e a impressão digital do ouvinte de Gerenciamento Remoto do Windows
Nome |
Tipo |
Description |
certificateUrl
|
string
|
Essa é a URL de um certificado que foi carregado no Key Vault como um segredo. Para adicionar um segredo ao Key Vault, consulte Adicionar uma chave ou segredo ao cofre de chaves. Nesse caso, seu certificado precisa ser a codificação Base64 do seguinte objeto JSON codificado em UTF-8:
{ "data":"", "dataType":"pfx", "password":"" } Para instalar certificados em uma máquina virtual, é recomendável usar a extensão de máquina virtual 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 WinRM. Os valores possíveis são: http,https.
|
ZonalPlatformFaultDomainAlignMode
Especifica o modo de alinhamento entre a computação do Conjunto de Dimensionamento de Máquinas Virtuais e a contagem de domínios de falha de armazenamento.
Nome |
Tipo |
Description |
Aligned
|
string
|
|
Unaligned
|
string
|
|