Creare o aggiornare un set di scalabilità di macchine virtuali.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}?api-version=2024-07-01
Parametri dell'URI
Nome |
In |
Necessario |
Tipo |
Descrizione |
resourceGroupName
|
path |
True
|
string
|
Nome del gruppo di risorse.
|
subscriptionId
|
path |
True
|
string
|
Credenziali di sottoscrizione che identificano in modo univoco la sottoscrizione di Microsoft Azure. L'ID sottoscrizione fa parte dell'URI per ogni chiamata al servizio.
|
vmScaleSetName
|
path |
True
|
string
|
Nome del set di scalabilità di macchine virtuali da creare o aggiornare.
|
api-version
|
query |
True
|
string
|
Versione dell'API client.
|
Nome |
Necessario |
Tipo |
Descrizione |
If-Match
|
|
string
|
ETag della trasformazione. Omettere questo valore per sovrascrivere sempre la risorsa corrente. Specificare l'ultimo valore ETag visualizzato per impedire la sovrascrittura accidentale delle modifiche simultanee.
|
If-None-Match
|
|
string
|
Impostare su '*' per consentire la creazione di un nuovo set di record, ma per impedire l'aggiornamento di un set di record esistente. Gli altri valori genereranno errori dal server perché non sono supportati.
|
Corpo della richiesta
Nome |
Necessario |
Tipo |
Descrizione |
location
|
True
|
string
|
Percorso risorsa
|
extendedLocation
|
|
ExtendedLocation
|
Posizione estesa del set di scalabilità di macchine virtuali.
|
identity
|
|
VirtualMachineScaleSetIdentity
|
Identità del set di scalabilità di macchine virtuali, se configurata.
|
plan
|
|
Plan
|
Specifica informazioni sull'immagine del marketplace usata per creare la macchina virtuale. Questo elemento viene usato solo per le immagini del Marketplace. Prima di poter usare un'immagine del marketplace da un'API, è necessario abilitare l'immagine per l'uso a livello di codice. Nel portale di Azure individuare l'immagine del Marketplace che si vuole usare e quindi fare clic su Si vuole distribuire a livello di codice, Introduzione ->. Immettere le informazioni necessarie e quindi fare clic su Salva.
|
properties.additionalCapabilities
|
|
AdditionalCapabilities
|
Specifica funzionalità aggiuntive abilitate o disabilitate nelle macchine virtuali nel set di scalabilità di macchine virtuali. Ad esempio, se le macchine virtuali hanno la possibilità di supportare il collegamento di dischi dati gestiti con UltraSSD_LRS tipo di account di archiviazione.
|
properties.automaticRepairsPolicy
|
|
AutomaticRepairsPolicy
|
Criteri per le riparazioni automatiche.
|
properties.constrainedMaximumCapacity
|
|
boolean
|
Proprietà facoltativa che deve essere impostata su True o omessa.
|
properties.doNotRunExtensionsOnOverprovisionedVMs
|
|
boolean
|
Quando l'overprovision è abilitato, le estensioni vengono avviate solo sul numero richiesto di macchine virtuali che vengono infine mantenute. Questa proprietà garantisce quindi che le estensioni non vengano eseguite nelle macchine virtuali con provisioning eccessivo aggiuntivo.
|
properties.hostGroup
|
|
SubResource
|
Specifica informazioni sul gruppo host dedicato in cui risiede il set di scalabilità di macchine virtuali. Versione minima api: 2020-06-01.
|
properties.orchestrationMode
|
|
OrchestrationMode
|
Specifica la modalità di orchestrazione per il set di scalabilità di macchine virtuali.
|
properties.overprovision
|
|
boolean
|
Specifica se il set di scalabilità di macchine virtuali deve essere sottoposto a provisioning eccessivo.
|
properties.platformFaultDomainCount
|
|
integer
|
Numero di domini di errore per ogni gruppo di posizionamento.
|
properties.priorityMixPolicy
|
|
PriorityMixPolicy
|
Specifica le destinazioni desiderate per combinare macchine virtuali con priorità spot e regolare all'interno della stessa istanza di VMSS Flex.
|
properties.proximityPlacementGroup
|
|
SubResource
|
Specifica informazioni sul gruppo di posizionamento di prossimità a cui deve essere assegnato il set di scalabilità di macchine virtuali. Versione minima api: 2018-04-01.
|
properties.resiliencyPolicy
|
|
ResiliencyPolicy
|
Criteri per la resilienza
|
properties.scaleInPolicy
|
|
ScaleInPolicy
|
Specifica i criteri applicati durante il ridimensionamento nelle macchine virtuali nel set di scalabilità di macchine virtuali.
|
properties.scheduledEventsPolicy
|
|
ScheduledEventsPolicy
|
The ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
|
boolean
|
Se true, questo limita il set di scalabilità a un singolo gruppo di posizionamento, con dimensioni massime di 100 macchine virtuali. NOTA: se singlePlacementGroup è true, può essere modificato in false. Tuttavia, se singlePlacementGroup è false, potrebbe non essere modificato in true.
|
properties.skuProfile
|
|
SkuProfile
|
Specifica il profilo sku per il set di scalabilità di macchine virtuali.
|
properties.spotRestorePolicy
|
|
SpotRestorePolicy
|
Specifica le proprietà di ripristino spot per il set di scalabilità di macchine virtuali.
|
properties.upgradePolicy
|
|
UpgradePolicy
|
Criteri di aggiornamento.
|
properties.virtualMachineProfile
|
|
VirtualMachineScaleSetVMProfile
|
Profilo della macchina virtuale.
|
properties.zonalPlatformFaultDomainAlignMode
|
|
ZonalPlatformFaultDomainAlignMode
|
Specifica la modalità di allineamento tra il calcolo del set di scalabilità di macchine virtuali e il numero di domini di errore di archiviazione.
|
properties.zoneBalance
|
|
boolean
|
Se forzare rigorosamente anche la distribuzione di macchine virtuali tra zone x in caso di interruzione della zona. La proprietà zoneBalance può essere impostata solo se la proprietà zone del set di scalabilità contiene più di una zona. Se non sono specificate zone o una sola zona, la proprietà zoneBalance non deve essere impostata.
|
sku
|
|
Sku
|
SKU del set di scalabilità di macchine virtuali.
|
tags
|
|
object
|
Tag delle risorse
|
zones
|
|
string[]
|
Zone del set di scalabilità di macchine virtuali.
|
Risposte
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
Nome |
Descrizione |
user_impersonation
|
rappresentare l'account utente
|
Esempio
Create a custom-image scale set from an unmanaged generalized os image.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"caching": "ReadWrite",
"image": {
"uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"
},
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualHardDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
*/
/**
* Sample code: Create a custom-image scale set from an unmanaged generalized os image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createACustomImageScaleSetFromAnUnmanagedGeneralizedOsImage(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withImage(new VirtualHardDisk().withUri(
"http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_custom_image_from_an_unmanaged_generalized_os_image.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"
},
"name": "osDisk",
}
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createACustomImageScaleSetFromAnUnmanagedGeneralizedOsImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
Image: &armcompute.VirtualHardDisk{
URI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d6e9ab29-f8c9-4792-978c-ae2c07b98f17"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// Image: &armcompute.VirtualHardDisk{
// URI: to.Ptr("https://{existing-storage-account-name}.blob.core.windows.net/system/Microsoft.Compute/Images/vhds/{existing-generalized-os-image-blob-name}.vhd"),
// },
// OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
*/
async function createACustomImageScaleSetFromAnUnmanagedGeneralizedOSImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
image: {
uri: "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_CustomImageFromAnUnmanagedGeneralizedOsImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
ImageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"),
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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}"
}
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk",
"vhdContainers": [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer"
]
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
*/
/**
* Sample code: Create a platform-image scale set with unmanaged os disks.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAPlatformImageScaleSetWithUnmanagedOsDisks(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withVhdContainers(Arrays.asList(
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer"))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_platform_image_with_unmanaged_os_disks.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk",
"vhdContainers": [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer",
],
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAPlatformImageScaleSetWithUnmanagedOsDisks() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
VhdContainers: []*string{
to.Ptr("http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer"),
to.Ptr("http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer")},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("77b7df9a-32fe-45e3-8911-60ac9c9b9c64"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// VhdContainers: []*string{
// to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net/vhds")},
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
*/
async function createAPlatformImageScaleSetWithUnmanagedOSDisks() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
vhdContainers: [
"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer",
"http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer",
],
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_PlatformImageWithUnmanagedOsDisks.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
VhdContainers = { "http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer" },
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
*/
/**
* Sample code: Create a scale set from a custom image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetFromACustomImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_acustom_image.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromACustomImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
*/
async function createAScaleSetFromACustomImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromACustomImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
*/
/**
* Sample code: Create a scale set from a generalized shared image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetFromAGeneralizedSharedImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_ageneralized_shared_image.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromAGeneralizedSharedImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
*/
async function createAScaleSetFromAGeneralizedSharedImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromAGeneralizedSharedImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
*/
/**
* Sample code: Create a scale set from a specialized shared image.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetFromASpecializedSharedImage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withStorageProfile(
new VirtualMachineScaleSetStorageProfile().withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_aspecialized_shared_image.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetFromASpecializedSharedImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
*/
async function createAScaleSetFromASpecializedSharedImage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromASpecializedSharedImage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4"
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
*/
/**
* Sample code: Create a scale set where nic config has DisableTcpStateTracking property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig1-name}")
.withPrimary(true).withEnableAcceleratedNetworking(true).withDisableTcpStateTracking(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true),
new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig2-name}")
.withPrimary(false).withEnableAcceleratedNetworking(false)
.withDisableTcpStateTracking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{nicConfig2-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"))
.withPrimary(true).withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_disable_tcp_state_tracking_network_interface.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"disableTcpStateTracking": True,
"enableAcceleratedNetworking": True,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{nicConfig2-name}",
"properties": {
"disableTcpStateTracking": False,
"enableAcceleratedNetworking": False,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{nicConfig1-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(true),
EnableAcceleratedNetworking: to.Ptr(true),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(false),
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(true),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(true),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(false),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(false),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
*/
async function createAScaleSetWhereNicConfigHasDisableTcpStateTrackingProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{nicConfig1-name}",
disableTcpStateTracking: true,
enableAcceleratedNetworking: true,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{nicConfig2-name}",
disableTcpStateTracking: false,
enableAcceleratedNetworking: false,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{nicConfig2-name}",
primary: true,
privateIPAddressVersion: "IPv4",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithDisableTcpStateTrackingNetworkInterface.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}")
{
Primary = true,
EnableAcceleratedNetworking = true,
IsTcpStateTrackingDisabled = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
IsTcpStateTrackingDisabled = false,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
Primary = true,
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
*/
/**
* Sample code: Create a scale set with a marketplace image plan.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithAMarketplaceImagePlan(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_amarketplace_image_plan.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAMarketplaceImagePlan() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
*/
async function createAScaleSetWithAMarketplaceImagePlan() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAMarketplaceImagePlan.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
*/
/**
* Sample code: Create a scale set with an azure application gateway.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithAnAzureApplicationGateway(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile()
.withNetworkInterfaceConfigurations(Arrays.asList(
new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}").withPrimary(
true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}").withSubnet(
new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withApplicationGatewayBackendAddressPools(
Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}")))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_azure_application_gateway.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAnAzureApplicationGateway() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("a0134477-b9d9-484b-b0e3-205c1c089ffa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/nsgExistingAppGw/backendAddressPools/appGatewayBackendPool"),
// }},
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
*/
async function createAScaleSetWithAnAzureApplicationGateway() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
applicationGatewayBackendAddressPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}",
},
],
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureApplicationGateway.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
ApplicationGatewayBackendAddressPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"publicIPAddressVersion": "IPv4"
}
},
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"
}
],
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
]
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
*/
/**
* Sample code: Create a scale set with an azure load balancer.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithAnAzureLoadBalancer(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile()
.withNetworkInterfaceConfigurations(Arrays.asList(
new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}").withPrimary(
true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}").withSubnet(
new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration()
.withName("{vmss-name}").withPublicIpAddressVersion(IpVersion.IPV4))
.withLoadBalancerBackendAddressPools(Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}")))
.withLoadBalancerInboundNatPools(Arrays.asList(new SubResource().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}")))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_azure_load_balancer.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"loadBalancerBackendAddressPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"
}
],
"loadBalancerInboundNatPools": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"
}
],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {"publicIPAddressVersion": "IPv4"},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAnAzureLoadBalancer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
LoadBalancerBackendAddressPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
LoadBalancerInboundNatPools: []*armcompute.SubResource{
{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"),
}},
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
PublicIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ec0b21ca-51ec-414b-9323-f236ffc21479"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// LoadBalancerBackendAddressPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/backendAddressPools/lbBackendPool"),
// }},
// LoadBalancerInboundNatPools: []*armcompute.SubResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/myLb/inboundNatPools/lbNatPool"),
// }},
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
*/
async function createAScaleSetWithAnAzureLoadBalancer() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
loadBalancerBackendAddressPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}",
},
],
loadBalancerInboundNatPools: [
{
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}",
},
],
publicIPAddressConfiguration: {
name: "{vmss-name}",
publicIPAddressVersion: "IPv4",
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAzureLoadBalancer.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("{vmss-name}")
{
PublicIPAddressVersion = IPVersion.IPv4,
},
LoadBalancerBackendAddressPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"),
}},
LoadBalancerInboundNatPools = {new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"),
}},
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"applicationProfile": {
"galleryApplications": [
{
"tags": "myTag1",
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
"treatFailureAsDeploymentFailure": true,
"enableAutomaticUpgrade": false
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.ApplicationProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMGalleryApplication;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
*/
/**
* Sample code: Create a scale set with Application Profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithApplicationProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withApplicationProfile(new ApplicationProfile().withGalleryApplications(Arrays.asList(
new VMGalleryApplication().withTags("myTag1").withOrder(1).withPackageReferenceId(
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0")
.withConfigurationReference(
"https://mystorageaccount.blob.core.windows.net/configurations/settings.config")
.withTreatFailureAsDeploymentFailure(true).withEnableAutomaticUpgrade(false),
new VMGalleryApplication().withPackageReferenceId(
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_application_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"applicationProfile": {
"galleryApplications": [
{
"configurationReference": "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
"enableAutomaticUpgrade": False,
"order": 1,
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
"tags": "myTag1",
"treatFailureAsDeploymentFailure": True,
},
{
"packageReferenceId": "/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"
},
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithApplicationProfile() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
ApplicationProfile: &armcompute.ApplicationProfile{
GalleryApplications: []*armcompute.VMGalleryApplication{
{
ConfigurationReference: to.Ptr("https://mystorageaccount.blob.core.windows.net/configurations/settings.config"),
EnableAutomaticUpgrade: to.Ptr(false),
Order: to.Ptr[int32](1),
PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0"),
Tags: to.Ptr("myTag1"),
TreatFailureAsDeploymentFailure: to.Ptr(true),
},
{
PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"),
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ffb27c5c-39a5-4d4e-b307-b32598689813"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// ApplicationProfile: &armcompute.ApplicationProfile{
// GalleryApplications: []*armcompute.VMGalleryApplication{
// {
// ConfigurationReference: to.Ptr("https://mystorageaccount.blob.core.windows.net/configurations/settings.config"),
// Order: to.Ptr[int32](1),
// PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0"),
// Tags: to.Ptr("myTag1"),
// },
// {
// PackageReferenceID: to.Ptr("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1"),
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
*/
async function createAScaleSetWithApplicationProfile() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
applicationProfile: {
galleryApplications: [
{
configurationReference:
"https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
enableAutomaticUpgrade: false,
order: 1,
packageReferenceId:
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0",
tags: "myTag1",
treatFailureAsDeploymentFailure: true,
},
{
packageReferenceId:
"/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithApplicationProfile.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
GalleryApplications = {new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0")
{
Tags = "myTag1",
Order = 1,
ConfigurationReference = "https://mystorageaccount.blob.core.windows.net/configurations/settings.config",
TreatFailureAsDeploymentFailure = true,
EnableAutomaticUpgrade = false,
}, new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"automaticRepairsPolicy": {
"enabled": true,
"gracePeriod": "PT10M"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticRepairsPolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
*/
/**
* Sample code: Create a scale set with automatic repairs enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithAutomaticRepairsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withAutomaticRepairsPolicy(new AutomaticRepairsPolicy().withEnabled(true).withGracePeriod("PT10M"))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_automatic_repairs.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"automaticRepairsPolicy": {"enabled": True, "gracePeriod": "PT10M"},
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithAutomaticRepairsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
AutomaticRepairsPolicy: &armcompute.AutomaticRepairsPolicy{
Enabled: to.Ptr(true),
GracePeriod: to.Ptr("PT10M"),
},
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// AutomaticRepairsPolicy: &armcompute.AutomaticRepairsPolicy{
// Enabled: to.Ptr(true),
// GracePeriod: to.Ptr("PT10M"),
// },
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
*/
async function createAScaleSetWithAutomaticRepairsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
automaticRepairsPolicy: { enabled: true, gracePeriod: "PT10M" },
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithAutomaticRepairs.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
AutomaticRepairsPolicy = new AutomaticRepairsPolicy
{
Enabled = true,
GracePeriod = "PT10M",
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
*/
/**
* Sample code: Create a scale set with boot diagnostics.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithBootDiagnostics(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net"))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_boot_diagnostics.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithBootDiagnostics() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
*/
async function createAScaleSetWithBootDiagnostics() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithBootDiagnostics.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
},
"diskControllerType": "NVMe"
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VMSizeProperties;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetHardwareProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
*/
/**
* Sample code: Create a scale set with Disk Controller Type.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithDiskControllerType(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDiskControllerType("NVMe"))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ==")
.withHardwareProfile(new VirtualMachineScaleSetHardwareProfile()
.withVmSizeProperties(new VMSizeProperties().withVCpusAvailable(1).withVCpusPerCore(1))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_disk_controller_type.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"hardwareProfile": {"vmSizeProperties": {"vCPUsAvailable": 1, "vCPUsPerCore": 1}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"diskControllerType": "NVMe",
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithDiskControllerType() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
VMSizeProperties: &armcompute.VMSizeProperties{
VCPUsAvailable: to.Ptr[int32](1),
VCPUsPerCore: to.Ptr[int32](1),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DiskControllerType: to.Ptr("NVMe"),
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
// VMSizeProperties: &armcompute.VMSizeProperties{
// VCPUsAvailable: to.Ptr[int32](1),
// VCPUsPerCore: to.Ptr[int32](1),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DiskControllerType: to.Ptr("NVMe"),
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
*/
async function createAScaleSetWithDiskControllerType() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
hardwareProfile: {
vmSizeProperties: { vCPUsAvailable: 1, vCPUsPerCore: 1 },
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
diskControllerType: "NVMe",
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskControllerType.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DiskControllerType = "NVMe",
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
HardwareVmSizeProperties = new VirtualMachineSizeProperties
{
VCpusAvailable = 1,
VCpusPerCore = 1,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"createOption": "FromImage"
},
"dataDisks": [
{
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS",
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
}
},
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.DiskEncryptionSetParameters;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
*/
/**
* Sample code: Create a scale set with DiskEncryptionSet resource in os disk and data disk.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithDiskEncryptionSetResourceInOsDiskAndDataDisk(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)
.withDiskEncryptionSet(new DiskEncryptionSetParameters().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"))))
.withDataDisks(Arrays.asList(new VirtualMachineScaleSetDataDisk().withLun(0)
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)
.withDiskEncryptionSet(new DiskEncryptionSetParameters().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"))))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_disk_encryption_set_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{
"caching": "ReadWrite",
"createOption": "Empty",
"diskSizeGB": 1023,
"lun": 0,
"managedDisk": {
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
},
"storageAccountType": "Standard_LRS",
},
}
],
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {
"diskEncryptionSet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
},
"storageAccountType": "Standard_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithDiskEncryptionSetResourceInOsDiskAndDataDisk() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
}},
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// DiskEncryptionSet: &armcompute.DiskEncryptionSetParameters{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
*/
async function createAScaleSetWithDiskEncryptionSetResourceInOSDiskAndDataDisk() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{
caching: "ReadWrite",
createOption: "Empty",
diskSizeGB: 1023,
lun: 0,
managedDisk: {
diskEncryptionSet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
storageAccountType: "Standard_LRS",
},
},
],
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: {
diskEncryptionSet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
storageAccountType: "Standard_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiskEncryptionSetResource.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 1023,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
},
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
},
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 1
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
*/
/**
* Sample code: Create a scale set with empty data disks on each vm.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEmptyDataDisksOnEachVm(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D2_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE).withDiskSizeGB(512)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDataDisks(Arrays.asList(
new VirtualMachineScaleSetDataDisk().withLun(0)
.withCreateOption(DiskCreateOptionTypes.EMPTY).withDiskSizeGB(1023),
new VirtualMachineScaleSetDataDisk().withLun(1)
.withCreateOption(DiskCreateOptionTypes.EMPTY).withDiskSizeGB(1023))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_empty_data_disks_on_each_vm.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 0},
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 1},
],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diskSizeGB": 512,
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEmptyDataDisksOnEachVm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
},
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](1),
}},
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiskSizeGB: to.Ptr[int32](512),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("8042c376-4690-4c47-9fa2-fbdad70e32fa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](1),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiskSizeGB: to.Ptr[int32](512),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
*/
async function createAScaleSetWithEmptyDataDisksOnEachVM() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{ createOption: "Empty", diskSizeGB: 1023, lun: 0 },
{ createOption: "Empty", diskSizeGB: 1023, lun: 1 },
],
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
diskSizeGB: 512,
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEmptyDataDisksOnEachVm.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 512,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "NvmeDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskPlacement;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
*/
/**
* Sample code: Create a scale set with ephemeral os disk provisioning in Nvme disk using placement property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDiskProvisioningInNvmeDiskUsingPlacementProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL)
.withPlacement(DiffDiskPlacement.NVME_DISK))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_a_with_diff_os_disk_using_diff_disk_placement_as_nvme_disk.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local", "placement": "NvmeDisk"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDiskProvisioningInNvmeDiskUsingPlacementProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
Placement: to.Ptr(armcompute.DiffDiskPlacementNvmeDisk),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// Placement: to.Ptr(armcompute.DiffDiskPlacementNvmeDisk),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
*/
async function createAScaleSetWithEphemeralOSDiskProvisioningInNvmeDiskUsingPlacementProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local", placement: "NvmeDisk" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacementAsNvmeDisk.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
Placement = DiffDiskPlacement.NvmeDisk,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local",
"placement": "ResourceDisk"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskPlacement;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
*/
/**
* Sample code: Create a scale set with ephemeral os disks using placement property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDisksUsingPlacementProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL)
.withPlacement(DiffDiskPlacement.RESOURCE_DISK))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_a_with_diff_os_disk_using_diff_disk_placement.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local", "placement": "ResourceDisk"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDisksUsingPlacementProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
Placement: to.Ptr(armcompute.DiffDiskPlacementResourceDisk),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// Placement: to.Ptr(armcompute.DiffDiskPlacementResourceDisk),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
*/
async function createAScaleSetWithEphemeralOSDisksUsingPlacementProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local", placement: "ResourceDisk" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_CreateA_WithDiffOsDiskUsingDiffDiskPlacement.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
Placement = DiffDiskPlacement.ResourceDisk,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local"
},
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiffDiskOptions;
import com.azure.resourcemanager.compute.models.DiffDiskSettings;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
*/
/**
* Sample code: Create a scale set with ephemeral os disks.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithEphemeralOsDisks(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withDiffDiskSettings(new DiffDiskSettings().withOption(DiffDiskOptions.LOCAL))
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_diff_os_disk.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"diffDiskSettings": {"option": "Local"},
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithEphemeralOsDisks() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiffDiskSettings: &armcompute.DiffDiskSettings{
Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
},
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiffDiskSettings: &armcompute.DiffDiskSettings{
// Option: to.Ptr(armcompute.DiffDiskOptionsLocal),
// },
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
*/
async function createAScaleSetWithEphemeralOSDisks() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
diffDiskSettings: { option: "Local" },
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithDiffOsDisk.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
DiffDiskSettings = new DiffDiskSettings
{
Option = DiffDiskOption.Local,
},
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {}
}
}
],
"extensionsTimeBudget": "PT1H20M"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
*/
/**
* Sample code: Create a scale set with extension time budget.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithExtensionTimeBudget(com.azure.resourcemanager.AzureResourceManager azure)
throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile()
.withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter()
.deserialize("{}", Object.class, SerializerEncoding.JSON))))
.withExtensionsTimeBudget("PT1H20M")))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_extensions_time_budget.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"publisher": "{extension-Publisher}",
"settings": {},
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
],
"extensionsTimeBudget": "PT1H20M",
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithExtensionTimeBudget() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
ExtensionsTimeBudget: to.Ptr("PT1H20M"),
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// ExtensionsTimeBudget: to.Ptr("PT1H20M"),
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
*/
async function createAScaleSetWithExtensionTimeBudget() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensionsTimeBudget: "PT1H20M",
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
publisher: "{extension-Publisher}",
settings: {},
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsTimeBudget.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
}},
ExtensionsTimeBudget = "PT1H20M",
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"enableFpga": true,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
"privateIPAddressVersion": "IPv4"
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
*/
/**
* Sample code: Create a scale set with Fpga Network Interfaces.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithFpgaNetworkInterfaces(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true),
new VirtualMachineScaleSetNetworkConfiguration().withName("{fpgaNic-Name}")
.withPrimary(false).withEnableAcceleratedNetworking(false).withEnableFpga(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{fpgaNic-Name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"))
.withPrimary(true).withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_fpga_network_interface.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{fpgaNic-Name}",
"properties": {
"enableAcceleratedNetworking": False,
"enableFpga": True,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{fpgaNic-Name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithFpgaNetworkInterfaces() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{fpgaNic-Name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableAcceleratedNetworking: to.Ptr(false),
EnableFpga: to.Ptr(true),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{fpgaNic-Name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{fpgaNic-Name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{fpgaNic-Name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
*/
async function createAScaleSetWithFpgaNetworkInterfaces() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{fpgaNic-Name}",
enableAcceleratedNetworking: false,
enableFpga: true,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{fpgaNic-Name}",
primary: true,
privateIPAddressVersion: "IPv4",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithFpgaNetworkInterface.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}, new VirtualMachineScaleSetNetworkConfiguration("{fpgaNic-Name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
EnableFpga = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{fpgaNic-Name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"),
Primary = true,
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows2016",
"publisher": "microsoft-ads",
"version": "latest",
"offer": "windows-data-science-vm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"encryptionAtHost": true
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"plan": {
"publisher": "microsoft-ads",
"product": "windows-data-science-vm",
"name": "windows2016"
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Plan;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
*/
/**
* Sample code: Create a scale set with Host Encryption using encryptionAtHost property.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withPlan(new Plan().withName("windows2016").withPublisher("microsoft-ads")
.withProduct("windows-data-science-vm"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("microsoft-ads")
.withOffer("windows-data-science-vm").withSku("windows2016").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile().withEncryptionAtHost(true)))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_encryption_at_host.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"plan": {"name": "windows2016", "product": "windows-data-science-vm", "publisher": "microsoft-ads"},
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {"encryptionAtHost": True},
"storageProfile": {
"imageReference": {
"offer": "windows-data-science-vm",
"publisher": "microsoft-ads",
"sku": "windows2016",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Plan: &armcompute.Plan{
Name: to.Ptr("windows2016"),
Product: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
},
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
EncryptionAtHost: to.Ptr(true),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windows-data-science-vm"),
Publisher: to.Ptr("microsoft-ads"),
SKU: to.Ptr("windows2016"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Plan: &armcompute.Plan{
// Name: to.Ptr("standard-data-science-vm"),
// Product: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// },
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// EncryptionAtHost: to.Ptr(true),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("standard-data-science-vm"),
// Publisher: to.Ptr("microsoft-ads"),
// SKU: to.Ptr("standard-data-science-vm"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
*/
async function createAScaleSetWithHostEncryptionUsingEncryptionAtHostProperty() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
plan: {
name: "windows2016",
product: "windows-data-science-vm",
publisher: "microsoft-ads",
},
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: { encryptionAtHost: true },
storageProfile: {
imageReference: {
offer: "windows-data-science-vm",
publisher: "microsoft-ads",
sku: "windows2016",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithEncryptionAtHost.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Plan = new ComputePlan
{
Name = "windows2016",
Publisher = "microsoft-ads",
Product = "windows-data-science-vm",
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "microsoft-ads",
Offer = "windows-data-science-vm",
Sku = "windows2016",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
EncryptionAtHost = true,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
*/
/**
* Sample code: Create a scale set with managed boot diagnostics.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithManagedBootDiagnostics(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_managed_boot_diagnostics.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {"bootDiagnostics": {"enabled": True}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithManagedBootDiagnostics() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
*/
async function createAScaleSetWithManagedBootDiagnostics() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: { bootDiagnostics: { enabled: true } },
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithManagedBootDiagnostics.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"disableTcpStateTracking": true,
"enableAcceleratedNetworking": true,
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1",
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
},
{
"name": "{nicConfig2-name}",
"properties": {
"primary": false,
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"disableTcpStateTracking": false,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": true,
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": {
"name": "publicip",
"properties": {
"idleTimeoutInMinutes": 10,
"dnsSettings": {
"domainNameLabel": "vmsstestlabel01",
"domainNameLabelScope": "NoReuse"
}
}
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.DomainNameLabelScopeTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.IpVersion;
import com.azure.resourcemanager.compute.models.NetworkInterfaceAuxiliaryMode;
import com.azure.resourcemanager.compute.models.NetworkInterfaceAuxiliarySku;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfigurationDnsSettings;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
*/
/**
* Sample code: Create a scale set with Network Interfaces with public ip address dns settings.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithNetworkInterfacesWithPublicIpAddressDnsSettings(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig1-name}")
.withPrimary(true).withEnableAcceleratedNetworking(true).withDisableTcpStateTracking(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)
.withAuxiliaryMode(NetworkInterfaceAuxiliaryMode.ACCELERATED_CONNECTIONS)
.withAuxiliarySku(NetworkInterfaceAuxiliarySku.A1),
new VirtualMachineScaleSetNetworkConfiguration().withName("{nicConfig2-name}")
.withPrimary(false).withEnableAcceleratedNetworking(false)
.withDisableTcpStateTracking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{nicConfig2-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"))
.withPrimary(true)
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration().withName("publicip")
.withIdleTimeoutInMinutes(10).withDnsSettings(
new VirtualMachineScaleSetPublicIpAddressConfigurationDnsSettings()
.withDomainNameLabel("vmsstestlabel01")
.withDomainNameLabelScope(DomainNameLabelScopeTypes.NO_REUSE)))
.withPrivateIpAddressVersion(IpVersion.IPV4)))
.withEnableIpForwarding(false)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_from_with_network_interface_with_dns_settings.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{nicConfig1-name}",
"properties": {
"auxiliaryMode": "AcceleratedConnections",
"auxiliarySku": "A1",
"disableTcpStateTracking": True,
"enableAcceleratedNetworking": True,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
},
{
"name": "{nicConfig2-name}",
"properties": {
"disableTcpStateTracking": False,
"enableAcceleratedNetworking": False,
"enableIPForwarding": False,
"ipConfigurations": [
{
"name": "{nicConfig2-name}",
"properties": {
"primary": True,
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": {
"name": "publicip",
"properties": {
"dnsSettings": {
"domainNameLabel": "vmsstestlabel01",
"domainNameLabelScope": "NoReuse",
},
"idleTimeoutInMinutes": 10,
},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"
},
},
}
],
"primary": False,
},
},
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithNetworkInterfacesWithPublicIpAddressDnsSettings() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{nicConfig1-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
AuxiliaryMode: to.Ptr(armcompute.NetworkInterfaceAuxiliaryModeAcceleratedConnections),
AuxiliarySKU: to.Ptr(armcompute.NetworkInterfaceAuxiliarySKUA1),
DisableTCPStateTracking: to.Ptr(true),
EnableAcceleratedNetworking: to.Ptr(true),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
},
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
DisableTCPStateTracking: to.Ptr(false),
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(false),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{nicConfig2-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(true),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("publicip"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
DNSSettings: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationDNSSettings{
DomainNameLabel: to.Ptr("vmsstestlabel01"),
DomainNameLabelScope: to.Ptr(armcompute.DomainNameLabelScopeTypesNoReuse),
},
IdleTimeoutInMinutes: to.Ptr[int32](10),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
},
},
}},
Primary: to.Ptr(false),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("afa2afa8-9e49-48fb-9d18-c86323b5d064"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// AuxiliaryMode: to.Ptr(armcompute.NetworkInterfaceAuxiliaryModeAcceleratedConnections),
// AuxiliarySKU: to.Ptr(armcompute.NetworkInterfaceAuxiliarySKUA1),
// DisableTCPStateTracking: to.Ptr(true),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(true),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig1-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
// Name: to.Ptr("publicip"),
// Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationDNSSettings{
// DomainNameLabel: to.Ptr("vmsstestlabel01"),
// DomainNameLabelScope: to.Ptr(armcompute.DomainNameLabelScopeTypesTenantReuse),
// },
// IdleTimeoutInMinutes: to.Ptr[int32](10),
// },
// },
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// },
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DisableTCPStateTracking: to.Ptr(false),
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableFpga: to.Ptr(false),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{nicConfig2-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// Primary: to.Ptr(true),
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
// },
// },
// }},
// Primary: to.Ptr(false),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(false),
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/nsgcustom"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
*/
async function createAScaleSetWithNetworkInterfacesWithPublicIPAddressDnsSettings() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{nicConfig1-name}",
auxiliaryMode: "AcceleratedConnections",
auxiliarySku: "A1",
disableTcpStateTracking: true,
enableAcceleratedNetworking: true,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
{
name: "{nicConfig2-name}",
disableTcpStateTracking: false,
enableAcceleratedNetworking: false,
enableIPForwarding: false,
ipConfigurations: [
{
name: "{nicConfig2-name}",
primary: true,
privateIPAddressVersion: "IPv4",
publicIPAddressConfiguration: {
name: "publicip",
dnsSettings: {
domainNameLabel: "vmsstestlabel01",
domainNameLabelScope: "NoReuse",
},
idleTimeoutInMinutes: 10,
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}",
},
},
],
primary: false,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_FromWithNetworkInterfaceWithDnsSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"),
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}")
{
Primary = true,
EnableAcceleratedNetworking = true,
IsTcpStateTrackingDisabled = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
AuxiliaryMode = ComputeNetworkInterfaceAuxiliaryMode.AcceleratedConnections,
AuxiliarySku = ComputeNetworkInterfaceAuxiliarySku.A1,
}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}")
{
Primary = false,
EnableAcceleratedNetworking = false,
IsTcpStateTrackingDisabled = false,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"),
Primary = true,
PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("publicip")
{
IdleTimeoutInMinutes = 10,
DnsSettings = new VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings("vmsstestlabel01")
{
DomainNameLabelScope = DomainNameLabelScopeType.NoReuse,
},
},
PrivateIPAddressVersion = IPVersion.IPv4,
}},
EnableIPForwarding = false,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT15M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.OSImageNotificationProfile;
import com.azure.resourcemanager.compute.models.ScheduledEventsProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
*/
/**
* Sample code: Create a scale set with OS image scheduled events enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithOSImageScheduledEventsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withScheduledEventsProfile(new ScheduledEventsProfile().withOsImageNotificationProfile(
new OSImageNotificationProfile().withNotBeforeTimeout("PT15M").withEnable(true))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_os_image_scheduled_event_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"scheduledEventsProfile": {
"osImageNotificationProfile": {"enable": True, "notBeforeTimeout": "PT15M"}
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithOsImageScheduledEventsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
OSImageNotificationProfile: &armcompute.OSImageNotificationProfile{
Enable: to.Ptr(true),
NotBeforeTimeout: to.Ptr("PT15M"),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
// OSImageNotificationProfile: &armcompute.OSImageNotificationProfile{
// Enable: to.Ptr(true),
// NotBeforeTimeout: to.Ptr("PT15M"),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
*/
async function createAScaleSetWithOSImageScheduledEventsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
scheduledEventsProfile: {
osImageNotificationProfile: { enable: true, notBeforeTimeout: "PT15M" },
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithOSImageScheduledEventEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ScheduledEventsProfile = new ComputeScheduledEventsProfile
{
OSImageNotificationProfile = new OSImageNotificationProfile
{
NotBeforeTimeout = "PT15M",
Enable = true,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
*/
/**
* Sample code: Create a scale set with password authentication.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPasswordAuthentication(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_password_authentication.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPasswordAuthentication() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("ffb27c5c-39a5-4d4e-b307-b32598689813"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
*/
async function createAScaleSetWithPasswordAuthentication() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPasswordAuthentication.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
*/
/**
* Sample code: Create a scale set with premium storage.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPremiumStorage(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy()
.withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile().withOsProfile(
new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile().withImageReference(
new ImageReference().withPublisher("MicrosoftWindowsServer").withOffer("WindowsServer")
.withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk()
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.PREMIUM_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_premium_storage.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Premium_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPremiumStorage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesPremiumLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("19fd38a2-f50a-42c6-9dc7-3f9cf3791225"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesPremiumLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
*/
async function createAScaleSetWithPremiumStorage() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Premium_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPremiumStorage.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.PremiumLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {
"baseRegularPriorityCount": 10,
"regularPriorityPercentageAboveBase": 50
},
"virtualMachineProfile": {
"priority": "Spot",
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts-gen2",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"enableAcceleratedNetworking": false,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
"primary": true,
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {
"idleTimeoutInMinutes": 15
}
}
}
}
]
}
}
],
"networkApiVersion": "2020-11-01"
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.NetworkApiVersion;
import com.azure.resourcemanager.compute.models.OrchestrationMode;
import com.azure.resourcemanager.compute.models.PriorityMixPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetPublicIpAddressConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
*/
/**
* Sample code: Create a scale set with priority mix policy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithPriorityMixPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_A8m_v2").withTier("Standard").withCapacity(2L))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("0001-com-ubuntu-server-focal").withSku("20_04-lts-gen2").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true).withEnableAcceleratedNetworking(false)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))
.withPrimary(true)
.withPublicIpAddressConfiguration(
new VirtualMachineScaleSetPublicIpAddressConfiguration().withName("{vmss-name}")
.withIdleTimeoutInMinutes(15))
.withApplicationGatewayBackendAddressPools(Arrays.asList())
.withLoadBalancerBackendAddressPools(Arrays.asList())))
.withEnableIpForwarding(true)))
.withNetworkApiVersion(NetworkApiVersion.TWO_ZERO_TWO_ZERO_ONE_ONE_ZERO_ONE))
.withPriority(VirtualMachinePriorityTypes.SPOT))
.withPlatformFaultDomainCount(1).withOrchestrationMode(OrchestrationMode.FLEXIBLE)
.withPriorityMixPolicy(new PriorityMixPolicy().withBaseRegularPriorityCount(10)
.withRegularPriorityPercentageAboveBase(50)),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_priority_mix_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"platformFaultDomainCount": 1,
"priorityMixPolicy": {"baseRegularPriorityCount": 10, "regularPriorityPercentageAboveBase": 50},
"virtualMachineProfile": {
"networkProfile": {
"networkApiVersion": "2020-11-01",
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableAcceleratedNetworking": False,
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"applicationGatewayBackendAddressPools": [],
"loadBalancerBackendAddressPools": [],
"primary": True,
"publicIPAddressConfiguration": {
"name": "{vmss-name}",
"properties": {"idleTimeoutInMinutes": 15},
},
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
},
},
}
],
"primary": True,
},
}
],
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "0001-com-ubuntu-server-focal",
"publisher": "Canonical",
"sku": "20_04-lts-gen2",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A8m_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithPriorityMixPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
PlatformFaultDomainCount: to.Ptr[int32](1),
PriorityMixPolicy: &armcompute.PriorityMixPolicy{
BaseRegularPriorityCount: to.Ptr[int32](10),
RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkAPIVersion: to.Ptr(armcompute.NetworkAPIVersionTwoThousandTwenty1101),
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableAcceleratedNetworking: to.Ptr(false),
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{},
LoadBalancerBackendAddressPools: []*armcompute.SubResource{},
Primary: to.Ptr(true),
PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
IdleTimeoutInMinutes: to.Ptr[int32](15),
},
},
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("0001-com-ubuntu-server-focal"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("20_04-lts-gen2"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A8m_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
// PlatformFaultDomainCount: to.Ptr[int32](1),
// PriorityMixPolicy: &armcompute.PriorityMixPolicy{
// BaseRegularPriorityCount: to.Ptr[int32](10),
// RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkAPIVersion: to.Ptr(armcompute.NetworkAPIVersionTwoThousandTwenty1101),
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// ApplicationGatewayBackendAddressPools: []*armcompute.SubResource{
// },
// LoadBalancerBackendAddressPools: []*armcompute.SubResource{
// },
// Primary: to.Ptr(true),
// PublicIPAddressConfiguration: &armcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
// IdleTimeoutInMinutes: to.Ptr[int32](15),
// },
// },
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminPassword: to.Ptr("{your-password}"),
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("0001-com-ubuntu-server-focal"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("20_04-lts-gen2"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A8m_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
*/
async function createAScaleSetWithPriorityMixPolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
orchestrationMode: "Flexible",
platformFaultDomainCount: 1,
priorityMixPolicy: {
baseRegularPriorityCount: 10,
regularPriorityPercentageAboveBase: 50,
},
sku: { name: "Standard_A8m_v2", capacity: 2, tier: "Standard" },
virtualMachineProfile: {
networkProfile: {
networkApiVersion: "2020-11-01",
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableAcceleratedNetworking: false,
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
applicationGatewayBackendAddressPools: [],
loadBalancerBackendAddressPools: [],
primary: true,
publicIPAddressConfiguration: {
name: "{vmss-name}",
idleTimeoutInMinutes: 15,
},
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "0001-com-ubuntu-server-focal",
publisher: "Canonical",
sku: "20_04-lts-gen2",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithPriorityMixPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_A8m_v2",
Tier = "Standard",
Capacity = 10L,
},
Properties = new VirtualMachineScaleSetProperties
{
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
SinglePlacementGroup = false,
OrchestrationMode = OrchestrationMode.Flexible,
PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy
{
BaseRegularPriorityCount = 4,
RegularPriorityPercentageAboveBase = 50,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"proxyAgentSettings": {
"enabled": true,
"mode": "Enforce"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Mode;
import com.azure.resourcemanager.compute.models.ProxyAgentSettings;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
*/
/**
* Sample code: Create a scale set with ProxyAgent Settings of enabled and mode.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithProxyAgentSettingsOfEnabledAndMode(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D2s_v3").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2019-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withProxyAgentSettings(new ProxyAgentSettings().withEnabled(true).withMode(Mode.ENFORCE))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_proxy_agent_settings.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {"proxyAgentSettings": {"enabled": True, "mode": "Enforce"}},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "StandardSSD_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2s_v3", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithProxyAgentSettingsOfEnabledAndMode() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
ProxyAgentSettings: &armcompute.ProxyAgentSettings{
Enabled: to.Ptr(true),
Mode: to.Ptr(armcompute.ModeEnforce),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2019-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2s_v3"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// ProxyAgentSettings: &armcompute.ProxyAgentSettings{
// Enabled: to.Ptr(true),
// Mode: to.Ptr(armcompute.ModeEnforce),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2019-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2s_v3"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
*/
async function createAScaleSetWithProxyAgentSettingsOfEnabledAndMode() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2s_v3", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
proxyAgentSettings: { enabled: true, mode: "Enforce" },
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2019-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "StandardSSD_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProxyAgentSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2s_v3",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2019-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
ProxyAgentSettings = new ProxyAgentSettings
{
Enabled = true,
Mode = Mode.Enforce,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMCreationPolicy": {
"enabled": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ResiliencyPolicy;
import com.azure.resourcemanager.compute.models.ResilientVMCreationPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
*/
/**
* Sample code: Create a scale set with Resilient VM Creation enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithResilientVMCreationEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(false)
.withResiliencyPolicy(new ResiliencyPolicy()
.withResilientVMCreationPolicy(new ResilientVMCreationPolicy().withEnabled(true))),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_resilient_vm_creation_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": False,
"resiliencyPolicy": {"resilientVMCreationPolicy": {"enabled": True}},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithResilientVmCreationEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(false),
ResiliencyPolicy: &armcompute.ResiliencyPolicy{
ResilientVMCreationPolicy: &armcompute.ResilientVMCreationPolicy{
Enabled: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(false),
// ProvisioningState: to.Ptr("Succeeded"),
// ResiliencyPolicy: &armcompute.ResiliencyPolicy{
// ResilientVMCreationPolicy: &armcompute.ResilientVMCreationPolicy{
// Enabled: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
*/
async function createAScaleSetWithResilientVMCreationEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: false,
resiliencyPolicy: { resilientVMCreationPolicy: { enabled: true } },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = false,
ResiliencyPolicy = new ResiliencyPolicy
{
ResilientVmCreationPolicyEnabled = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"resiliencyPolicy": {
"resilientVMDeletionPolicy": {
"enabled": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ResiliencyPolicy;
import com.azure.resourcemanager.compute.models.ResilientVMDeletionPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
*/
/**
* Sample code: Create a scale set with Resilient VM Deletion enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithResilientVMDeletionEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(false)
.withResiliencyPolicy(new ResiliencyPolicy()
.withResilientVMDeletionPolicy(new ResilientVMDeletionPolicy().withEnabled(true))),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_resilient_vm_deletion_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": False,
"resiliencyPolicy": {"resilientVMDeletionPolicy": {"enabled": True}},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithResilientVmDeletionEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(false),
ResiliencyPolicy: &armcompute.ResiliencyPolicy{
ResilientVMDeletionPolicy: &armcompute.ResilientVMDeletionPolicy{
Enabled: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(false),
// ProvisioningState: to.Ptr("Succeeded"),
// ResiliencyPolicy: &armcompute.ResiliencyPolicy{
// ResilientVMDeletionPolicy: &armcompute.ResilientVMDeletionPolicy{
// Enabled: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
*/
async function createAScaleSetWithResilientVMDeletionEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: false,
resiliencyPolicy: { resilientVMDeletionPolicy: { enabled: true } },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMDeletionPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = false,
ResiliencyPolicy = new ResiliencyPolicy
{
ResilientVmDeletionPolicyEnabled = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scaleInPolicy": {
"rules": [
"OldestVM"
],
"forceDeletion": true
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScaleInPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetScaleInRules;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
*/
/**
* Sample code: Create a scale set with scaleInPolicy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithScaleInPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true)
.withScaleInPolicy(new ScaleInPolicy()
.withRules(Arrays.asList(VirtualMachineScaleSetScaleInRules.OLDEST_VM)).withForceDeletion(true)),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_scale_in_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scaleInPolicy": {"forceDeletion": True, "rules": ["OldestVM"]},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithScaleInPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScaleInPolicy: &armcompute.ScaleInPolicy{
ForceDeletion: to.Ptr(true),
Rules: []*armcompute.VirtualMachineScaleSetScaleInRules{
to.Ptr(armcompute.VirtualMachineScaleSetScaleInRulesOldestVM)},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScaleInPolicy: &armcompute.ScaleInPolicy{
// ForceDeletion: to.Ptr(true),
// Rules: []*armcompute.VirtualMachineScaleSetScaleInRules{
// to.Ptr(armcompute.VirtualMachineScaleSetScaleInRulesOldestVM)},
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
*/
async function createAScaleSetWithScaleInPolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scaleInPolicy: { forceDeletion: true, rules: ["OldestVM"] },
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithScaleInPolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
ScaleInPolicy = new ScaleInPolicy
{
Rules = { VirtualMachineScaleSetScaleInRule.OldestVm },
ForceDeletion = true,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"location": "eastus2euap",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityPostureReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
*/
/**
* Sample code: Create a scale set with Security Posture Reference.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithSecurityPostureReference(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("eastus2euap")
.withSku(new Sku().withName("Standard_A1").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withEnableAutomaticOSUpgrade(true)))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2022-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityPostureReference(new SecurityPostureReference().withId(
"/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest")))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_posture_reference.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "eastus2euap",
"properties": {
"overprovision": True,
"upgradePolicy": {"automaticOSUpgradePolicy": {"enableAutomaticOSUpgrade": True}, "mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityPostureReference": {
"id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-Datacenter",
"version": "latest",
},
"osDisk": {"caching": "ReadWrite", "createOption": "FromImage", "name": "osDisk"},
},
},
},
"sku": {"capacity": 3, "name": "Standard_A1", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityPostureReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("eastus2euap"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
EnableAutomaticOSUpgrade: to.Ptr(true),
},
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityPostureReference: &armcompute.SecurityPostureReference{
ID: to.Ptr("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2022-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("eastus2euap"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d12ccb3d-ab15-4794-9836-c4196392e9f2"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
// EnableAutomaticOSUpgrade: to.Ptr(true),
// },
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityPostureReference: &armcompute.SecurityPostureReference{
// ID: to.Ptr("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest"),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2022-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
*/
async function createAScaleSetWithSecurityPostureReference() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "eastus2euap",
overprovision: true,
sku: { name: "Standard_A1", capacity: 3, tier: "Standard" },
upgradePolicy: {
automaticOSUpgradePolicy: { enableAutomaticOSUpgrade: true },
mode: "Automatic",
},
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityPostureReference: {
id: "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2022-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityPostureReference.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap"))
{
Sku = new ComputeSku
{
Name = "Standard_A1",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy
{
EnableAutomaticOSUpgrade = true,
},
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2022-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityPostureReference = new ComputeSecurityPostureReference(new ResourceIdentifier("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest")),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2as_v5"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows-cvm",
"publisher": "MicrosoftWindowsServer",
"version": "17763.2183.2109130127",
"offer": "2019-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "VMGuestStateOnly"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityEncryptionTypes;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMDiskSecurityProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
*/
/**
* Sample code: Create a scale set with SecurityType as ConfidentialVM.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithSecurityTypeAsConfidentialVM(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DC2as_v5").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("2019-datacenter-cvm").withSku("windows-cvm")
.withVersion("17763.2183.2109130127"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS)
.withSecurityProfile(new VMDiskSecurityProfile()
.withSecurityEncryptionType(SecurityEncryptionTypes.VMGUEST_STATE_ONLY)))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(true).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.CONFIDENTIAL_VM)))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_type_confidential_vm.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "ConfidentialVM",
"uefiSettings": {"secureBootEnabled": True, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "2019-datacenter-cvm",
"publisher": "MicrosoftWindowsServer",
"sku": "windows-cvm",
"version": "17763.2183.2109130127",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {
"securityProfile": {"securityEncryptionType": "VMGuestStateOnly"},
"storageAccountType": "StandardSSD_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DC2as_v5", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityTypeAsConfidentialVm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(true),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("2019-datacenter-cvm"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("windows-cvm"),
Version: to.Ptr("17763.2183.2109130127"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
SecurityProfile: &armcompute.VMDiskSecurityProfile{
SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesVMGuestStateOnly),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DC2as_v5"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(true),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("2019-datacenter-cvm"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("windows-cvm"),
// Version: to.Ptr("17763.2183.2109130127"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// SecurityProfile: &armcompute.VMDiskSecurityProfile{
// SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesVMGuestStateOnly),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DC2as_v5"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
*/
async function createAScaleSetWithSecurityTypeAsConfidentialVM() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DC2as_v5", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "ConfidentialVM",
uefiSettings: { secureBootEnabled: true, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "2019-datacenter-cvm",
publisher: "MicrosoftWindowsServer",
sku: "windows-cvm",
version: "17763.2183.2109130127",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: {
securityProfile: { securityEncryptionType: "VMGuestStateOnly" },
storageAccountType: "StandardSSD_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVM.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DC2as_v5",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "2019-datacenter-cvm",
Sku = "windows-cvm",
Version = "17763.2183.2109130127",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
SecurityProfile = new VirtualMachineDiskSecurityProfile
{
SecurityEncryptionType = SecurityEncryptionType.VmGuestStateOnly,
},
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = true,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.ConfidentialVm,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DC2es_v5"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "linux-cvm",
"publisher": "UbuntuServer",
"version": "17763.2183.2109130127",
"offer": "2022-datacenter-cvm"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS",
"securityProfile": {
"securityEncryptionType": "NonPersistedTPM"
}
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": false,
"vTpmEnabled": true
},
"securityType": "ConfidentialVM"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityEncryptionTypes;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMDiskSecurityProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.
* json
*/
/**
* Sample code: Create a scale set with SecurityType as ConfidentialVM and NonPersistedTPM securityEncryptionType.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSecurityTypeAsConfidentialVMAndNonPersistedTPMSecurityEncryptionType(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DC2es_v5").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("UbuntuServer")
.withOffer("2022-datacenter-cvm").withSku("linux-cvm").withVersion("17763.2183.2109130127"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS)
.withSecurityProfile(new VMDiskSecurityProfile()
.withSecurityEncryptionType(SecurityEncryptionTypes.NON_PERSISTED_TPM)))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(false).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.CONFIDENTIAL_VM)))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_security_type_confidential_vm_with_non_persisted_tpm.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "ConfidentialVM",
"uefiSettings": {"secureBootEnabled": False, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "2022-datacenter-cvm",
"publisher": "UbuntuServer",
"sku": "linux-cvm",
"version": "17763.2183.2109130127",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {
"securityProfile": {"securityEncryptionType": "NonPersistedTPM"},
"storageAccountType": "StandardSSD_LRS",
},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DC2es_v5", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSecurityTypeAsConfidentialVmAndNonPersistedTpmSecurityEncryptionType() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(false),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("2022-datacenter-cvm"),
Publisher: to.Ptr("UbuntuServer"),
SKU: to.Ptr("linux-cvm"),
Version: to.Ptr("17763.2183.2109130127"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
SecurityProfile: &armcompute.VMDiskSecurityProfile{
SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesNonPersistedTPM),
},
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DC2es_v5"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesConfidentialVM),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(false),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("2022-datacenter-cvm"),
// Publisher: to.Ptr("UbuntuServer"),
// SKU: to.Ptr("linux-cvm"),
// Version: to.Ptr("17763.2183.2109130127"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// SecurityProfile: &armcompute.VMDiskSecurityProfile{
// SecurityEncryptionType: to.Ptr(armcompute.SecurityEncryptionTypesNonPersistedTPM),
// },
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DC2es_v5"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
*/
async function createAScaleSetWithSecurityTypeAsConfidentialVMAndNonPersistedTpmSecurityEncryptionType() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DC2es_v5", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "ConfidentialVM",
uefiSettings: { secureBootEnabled: false, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "2022-datacenter-cvm",
publisher: "UbuntuServer",
sku: "linux-cvm",
version: "17763.2183.2109130127",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: {
securityProfile: { securityEncryptionType: "NonPersistedTPM" },
storageAccountType: "StandardSSD_LRS",
},
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSecurityTypeConfidentialVMWithNonPersistedTPM.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DC2es_v5",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "UbuntuServer",
Offer = "2022-datacenter-cvm",
Sku = "linux-cvm",
Version = "17763.2183.2109130127",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
SecurityProfile = new VirtualMachineDiskSecurityProfile
{
SecurityEncryptionType = SecurityEncryptionType.NonPersistedTPM,
},
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = false,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.ConfidentialVm,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_A1"
},
"location": "eastus2euap",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"sku": "2022-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"name": "osDisk"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ServiceArtifactReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
*/
/**
* Sample code: Create a scale set with Service Artifact Reference.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithServiceArtifactReference(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("eastus2euap")
.withSku(new Sku().withName("Standard_A1").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withEnableAutomaticOSUpgrade(true)))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2022-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withName("osDisk")
.withCaching(CachingTypes.READ_WRITE).withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withServiceArtifactReference(new ServiceArtifactReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName")))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_service_artifact_reference.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "eastus2euap",
"properties": {
"overprovision": True,
"upgradePolicy": {"automaticOSUpgradePolicy": {"enableAutomaticOSUpgrade": True}, "mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"serviceArtifactReference": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-Datacenter",
"version": "latest",
},
"osDisk": {"caching": "ReadWrite", "createOption": "FromImage", "name": "osDisk"},
},
},
},
"sku": {"capacity": 3, "name": "Standard_A1", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithServiceArtifactReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("eastus2euap"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
EnableAutomaticOSUpgrade: to.Ptr(true),
},
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ServiceArtifactReference: &armcompute.ServiceArtifactReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2022-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Name: to.Ptr("osDisk"),
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("eastus2euap"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("77b7df9a-32fe-45e3-8911-60ac9c9b9c64"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armcompute.AutomaticOSUpgradePolicy{
// EnableAutomaticOSUpgrade: to.Ptr(true),
// },
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ServiceArtifactReference: &armcompute.ServiceArtifactReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2022-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Name: to.Ptr("osDisk"),
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
*/
async function createAScaleSetWithServiceArtifactReference() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "eastus2euap",
overprovision: true,
sku: { name: "Standard_A1", capacity: 3, tier: "Standard" },
upgradePolicy: {
automaticOSUpgradePolicy: { enableAutomaticOSUpgrade: true },
mode: "Automatic",
},
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
serviceArtifactReference: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2022-Datacenter",
version: "latest",
},
osDisk: {
name: "osDisk",
caching: "ReadWrite",
createOption: "FromImage",
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithServiceArtifactReference.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap"))
{
Sku = new ComputeSku
{
Name = "Standard_A1",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy
{
EnableAutomaticOSUpgrade = true,
},
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2022-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Name = "osDisk",
Caching = CachingType.ReadWrite,
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"capacity": 10,
"name": "Mix"
},
"location": "westus",
"properties": {
"singlePlacementGroup": false,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"orchestrationMode": "Flexible",
"priorityMixPolicy": {
"baseRegularPriorityCount": 4,
"regularPriorityPercentageAboveBase": 50
},
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5"
},
{
"name": "Standard_E16s_v5"
},
{
"name": "Standard_D2s_v5"
}
],
"allocationStrategy": "CapacityOptimized"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.AllocationStrategy;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BillingProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.OrchestrationMode;
import com.azure.resourcemanager.compute.models.PriorityMixPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SkuProfile;
import com.azure.resourcemanager.compute.models.SkuProfileVMSize;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineEvictionPolicyTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
*/
/**
* Sample code: Create a scale set with sku profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSkuProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Mix").withCapacity(10L))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withPriority(VirtualMachinePriorityTypes.SPOT)
.withEvictionPolicy(VirtualMachineEvictionPolicyTypes.DEALLOCATE)
.withBillingProfile(new BillingProfile().withMaxPrice(-1.0D)))
.withSinglePlacementGroup(false).withOrchestrationMode(OrchestrationMode.FLEXIBLE)
.withPriorityMixPolicy(
new PriorityMixPolicy().withBaseRegularPriorityCount(4).withRegularPriorityPercentageAboveBase(50))
.withSkuProfile(new SkuProfile()
.withVmSizes(Arrays.asList(new SkuProfileVMSize().withName("Standard_D8s_v5"),
new SkuProfileVMSize().withName("Standard_E16s_v5"),
new SkuProfileVMSize().withName("Standard_D2s_v5")))
.withAllocationStrategy(AllocationStrategy.CAPACITY_OPTIMIZED)),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_sku_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"orchestrationMode": "Flexible",
"priorityMixPolicy": {"baseRegularPriorityCount": 4, "regularPriorityPercentageAboveBase": 50},
"singlePlacementGroup": False,
"skuProfile": {
"allocationStrategy": "CapacityOptimized",
"vmSizes": [{"name": "Standard_D8s_v5"}, {"name": "Standard_E16s_v5"}, {"name": "Standard_D2s_v5"}],
},
"virtualMachineProfile": {
"billingProfile": {"maxPrice": -1},
"evictionPolicy": "Deallocate",
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 10, "name": "Mix"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSkuProfile() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
PriorityMixPolicy: &armcompute.PriorityMixPolicy{
BaseRegularPriorityCount: to.Ptr[int32](4),
RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
},
SinglePlacementGroup: to.Ptr(false),
SKUProfile: &armcompute.SKUProfile{
AllocationStrategy: to.Ptr(armcompute.AllocationStrategyCapacityOptimized),
VMSizes: []*armcompute.SKUProfileVMSize{
{
Name: to.Ptr("Standard_D8s_v5"),
},
{
Name: to.Ptr("Standard_E16s_v5"),
},
{
Name: to.Ptr("Standard_D2s_v5"),
}},
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
BillingProfile: &armcompute.BillingProfile{
MaxPrice: to.Ptr[float64](-1),
},
EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Mix"),
Capacity: to.Ptr[int64](10),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// OrchestrationMode: to.Ptr(armcompute.OrchestrationModeFlexible),
// PriorityMixPolicy: &armcompute.PriorityMixPolicy{
// BaseRegularPriorityCount: to.Ptr[int32](4),
// RegularPriorityPercentageAboveBase: to.Ptr[int32](50),
// },
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(false),
// SKUProfile: &armcompute.SKUProfile{
// AllocationStrategy: to.Ptr(armcompute.AllocationStrategyCapacityOptimized),
// VMSizes: []*armcompute.SKUProfileVMSize{
// {
// Name: to.Ptr("Standard_D8s_v5"),
// },
// {
// Name: to.Ptr("Standard_E16s_v5"),
// },
// {
// Name: to.Ptr("Standard_D2s_v5"),
// }},
// },
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// BillingProfile: &armcompute.BillingProfile{
// MaxPrice: to.Ptr[float64](-1),
// },
// EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Mix"),
// Capacity: to.Ptr[int64](10),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
*/
async function createAScaleSetWithSkuProfile() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
orchestrationMode: "Flexible",
priorityMixPolicy: {
baseRegularPriorityCount: 4,
regularPriorityPercentageAboveBase: 50,
},
singlePlacementGroup: false,
sku: { name: "Mix", capacity: 10 },
skuProfile: {
allocationStrategy: "CapacityOptimized",
vmSizes: [
{ name: "Standard_D8s_v5" },
{ name: "Standard_E16s_v5" },
{ name: "Standard_D2s_v5" },
],
},
virtualMachineProfile: {
billingProfile: { maxPrice: -1 },
evictionPolicy: "Deallocate",
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSkuProfile.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Mix",
Capacity = 10L,
},
Properties = new VirtualMachineScaleSetProperties
{
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
SinglePlacementGroup = false,
OrchestrationMode = OrchestrationMode.Flexible,
PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy
{
BaseRegularPriorityCount = 4,
RegularPriorityPercentageAboveBase = 50,
},
SkuProfile = new ComputeSkuProfile
{
VmSizes = {new ComputeSkuProfileVmSize
{
Name = "Standard_D8s_v5",
}, new ComputeSkuProfileVmSize
{
Name = "Standard_E16s_v5",
}, new ComputeSkuProfileVmSize
{
Name = "Standard_D2s_v5",
}},
AllocationStrategy = ComputeAllocationStrategy.CapacityOptimized,
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A8m_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"priority": "Spot",
"evictionPolicy": "Deallocate",
"billingProfile": {
"maxPrice": -1
}
},
"upgradePolicy": {
"mode": "Manual"
},
"spotRestorePolicy": {
"enabled": true,
"restoreTimeout": "PT1H"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BillingProfile;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SpotRestorePolicy;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineEvictionPolicyTypes;
import com.azure.resourcemanager.compute.models.VirtualMachinePriorityTypes;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
*/
/**
* Sample code: Create a scale set with spot restore policy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSpotRestorePolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_A8m_v2").withTier("Standard").withCapacity(2L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withPriority(VirtualMachinePriorityTypes.SPOT)
.withEvictionPolicy(VirtualMachineEvictionPolicyTypes.DEALLOCATE)
.withBillingProfile(new BillingProfile().withMaxPrice(-1.0D)))
.withOverprovision(true)
.withSpotRestorePolicy(new SpotRestorePolicy().withEnabled(true).withRestoreTimeout("PT1H")), null,
null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_spot_restore_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"spotRestorePolicy": {"enabled": True, "restoreTimeout": "PT1H"},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"billingProfile": {"maxPrice": -1},
"evictionPolicy": "Deallocate",
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"priority": "Spot",
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A8m_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSpotRestorePolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
SpotRestorePolicy: &armcompute.SpotRestorePolicy{
Enabled: to.Ptr(true),
RestoreTimeout: to.Ptr("PT1H"),
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
BillingProfile: &armcompute.BillingProfile{
MaxPrice: to.Ptr[float64](-1),
},
EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A8m_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// SpotRestorePolicy: &armcompute.SpotRestorePolicy{
// Enabled: to.Ptr(true),
// RestoreTimeout: to.Ptr("PT1H"),
// },
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// BillingProfile: &armcompute.BillingProfile{
// MaxPrice: to.Ptr[float64](-1),
// },
// EvictionPolicy: to.Ptr(armcompute.VirtualMachineEvictionPolicyTypesDeallocate),
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// Priority: to.Ptr(armcompute.VirtualMachinePriorityTypesSpot),
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A8m_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
*/
async function createAScaleSetWithSpotRestorePolicy() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_A8m_v2", capacity: 2, tier: "Standard" },
spotRestorePolicy: { enabled: true, restoreTimeout: "PT1H" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
billingProfile: { maxPrice: -1 },
evictionPolicy: "Deallocate",
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
priority: "Spot",
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSpotRestorePolicy.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_A8m_v2",
Tier = "Standard",
Capacity = 2L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
Priority = VirtualMachinePriorityType.Spot,
EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate,
BillingMaxPrice = -1,
},
Overprovision = true,
SpotRestorePolicy = new SpotRestorePolicy
{
Enabled = true,
RestoreTimeout = "PT1H",
},
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"linuxConfiguration": {
"ssh": {
"publicKeys": [
{
"path": "/home/{your-username}/.ssh/authorized_keys",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"
}
]
},
"disablePasswordAuthentication": true
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.LinuxConfiguration;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.SshConfiguration;
import com.azure.resourcemanager.compute.models.SshPublicKey;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
*/
/**
* Sample code: Create a scale set with ssh authentication.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithSshAuthentication(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}")
.withLinuxConfiguration(new LinuxConfiguration().withDisablePasswordAuthentication(true)
.withSsh(new SshConfiguration().withPublicKeys(
Arrays.asList(new SshPublicKey().withPath("/home/{your-username}/.ssh/authorized_keys")
.withKeyData("fakeTokenPlaceholder"))))))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_ssh_authentication.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
"linuxConfiguration": {
"disablePasswordAuthentication": True,
"ssh": {
"publicKeys": [
{
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
"path": "/home/{your-username}/.ssh/authorized_keys",
}
]
},
},
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithSshAuthentication() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
LinuxConfiguration: &armcompute.LinuxConfiguration{
DisablePasswordAuthentication: to.Ptr(true),
SSH: &armcompute.SSHConfiguration{
PublicKeys: []*armcompute.SSHPublicKey{
{
Path: to.Ptr("/home/{your-username}/.ssh/authorized_keys"),
KeyData: to.Ptr("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"),
}},
},
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("fb73af19-0090-467c-9ced-b00bceab1c45"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// LinuxConfiguration: &armcompute.LinuxConfiguration{
// DisablePasswordAuthentication: to.Ptr(true),
// SSH: &armcompute.SSHConfiguration{
// PublicKeys: []*armcompute.SSHPublicKey{
// {
// Path: to.Ptr("/home/{your-username}/.ssh/authorized_keys"),
// KeyData: to.Ptr("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"),
// }},
// },
// },
// Secrets: []*armcompute.VaultSecretGroup{
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("16.04-LTS"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
*/
async function createAScaleSetWithSshAuthentication() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
linuxConfiguration: {
disablePasswordAuthentication: true,
ssh: {
publicKeys: [
{
path: "/home/{your-username}/.ssh/authorized_keys",
keyData:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
},
],
},
},
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithSshAuthentication.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
LinuxConfiguration = new LinuxConfiguration
{
IsPasswordAuthenticationDisabled = true,
SshPublicKeys = {new SshPublicKeyConfiguration
{
Path = "/home/{your-username}/.ssh/authorized_keys",
KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
}},
},
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {
"enable": true,
"notBeforeTimeout": "PT5M"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsProfile;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.TerminateNotificationProfile;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
*/
/**
* Sample code: Create a scale set with terminate scheduled events enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithTerminateScheduledEventsEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withScheduledEventsProfile(new ScheduledEventsProfile().withTerminateNotificationProfile(
new TerminateNotificationProfile().withNotBeforeTimeout("PT5M").withEnable(true))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_terminate_scheduled_event_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"scheduledEventsProfile": {
"terminateNotificationProfile": {"enable": True, "notBeforeTimeout": "PT5M"}
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithTerminateScheduledEventsEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
TerminateNotificationProfile: &armcompute.TerminateNotificationProfile{
Enable: to.Ptr(true),
NotBeforeTimeout: to.Ptr("PT5M"),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// ScheduledEventsProfile: &armcompute.ScheduledEventsProfile{
// TerminateNotificationProfile: &armcompute.TerminateNotificationProfile{
// Enable: to.Ptr(true),
// NotBeforeTimeout: to.Ptr("PT5M"),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
*/
async function createAScaleSetWithTerminateScheduledEventsEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
scheduledEventsProfile: {
terminateNotificationProfile: {
enable: true,
notBeforeTimeout: "PT5M",
},
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithTerminateScheduledEventEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
ScheduledEventsProfile = new ComputeScheduledEventsProfile
{
TerminateNotificationProfile = new TerminateNotificationProfile
{
NotBeforeTimeout = "PT5M",
Enable = true,
},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D2s_v3"
},
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "windows10-tvm",
"publisher": "MicrosoftWindowsServer",
"version": "18363.592.2001092016",
"offer": "windowsserver-gen2preview-preview"
},
"osDisk": {
"caching": "ReadOnly",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"createOption": "FromImage"
}
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "TrustedLaunch"
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
},
"location": "westus"
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.SecurityProfile;
import com.azure.resourcemanager.compute.models.SecurityTypes;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UefiSettings;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
*/
/**
* Sample code: Create a scale set with Uefi Settings of secureBoot and vTPM.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithUefiSettingsOfSecureBootAndVTPM(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName(
"Standard_D2s_v3").withTier(
"Standard")
.withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(
new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("windowsserver-gen2preview-preview").withSku("windows10-tvm")
.withVersion("18363.592.2001092016"))
.withOsDisk(
new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_ONLY)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_SSD_LRS))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration()
.withName("{vmss-name}").withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withSecurityProfile(new SecurityProfile()
.withUefiSettings(new UefiSettings().withSecureBootEnabled(true).withVTpmEnabled(true))
.withSecurityType(SecurityTypes.TRUSTED_LAUNCH)))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_uefi_settings.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"securityProfile": {
"securityType": "TrustedLaunch",
"uefiSettings": {"secureBootEnabled": True, "vTpmEnabled": True},
},
"storageProfile": {
"imageReference": {
"offer": "windowsserver-gen2preview-preview",
"publisher": "MicrosoftWindowsServer",
"sku": "windows10-tvm",
"version": "18363.592.2001092016",
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "StandardSSD_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D2s_v3", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithUefiSettingsOfSecureBootAndVTpm() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
SecurityProfile: &armcompute.SecurityProfile{
SecurityType: to.Ptr(armcompute.SecurityTypesTrustedLaunch),
UefiSettings: &armcompute.UefiSettings{
SecureBootEnabled: to.Ptr(true),
VTpmEnabled: to.Ptr(true),
},
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("windowsserver-gen2preview-preview"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("windows10-tvm"),
Version: to.Ptr("18363.592.2001092016"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadOnly),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D2s_v3"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("b9e23088-6ffc-46e0-9e02-b0a6eeef47db"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// SecurityProfile: &armcompute.SecurityProfile{
// SecurityType: to.Ptr(armcompute.SecurityTypesTrustedLaunch),
// UefiSettings: &armcompute.UefiSettings{
// SecureBootEnabled: to.Ptr(true),
// VTpmEnabled: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("windowsserver-gen2preview-preview"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("windows10-tvm"),
// Version: to.Ptr("18363.592.2001092016"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadOnly),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardSSDLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D2s_v3"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
*/
async function createAScaleSetWithUefiSettingsOfSecureBootAndVTpm() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D2s_v3", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
securityProfile: {
securityType: "TrustedLaunch",
uefiSettings: { secureBootEnabled: true, vTpmEnabled: true },
},
storageProfile: {
imageReference: {
offer: "windowsserver-gen2preview-preview",
publisher: "MicrosoftWindowsServer",
sku: "windows10-tvm",
version: "18363.592.2001092016",
},
osDisk: {
caching: "ReadOnly",
createOption: "FromImage",
managedDisk: { storageAccountType: "StandardSSD_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUefiSettings.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D2s_v3",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "windowsserver-gen2preview-preview",
Sku = "windows10-tvm",
Version = "18363.592.2001092016",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadOnly,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardSsdLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
SecurityProfile = new SecurityProfile
{
UefiSettings = new UefiSettings
{
IsSecureBootEnabled = true,
IsVirtualTpmEnabled = true,
},
SecurityType = SecurityType.TrustedLaunch,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
*/
/**
* Sample code: Create a scale set with userData.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithUserData(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ=="))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_user_data.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithUserData() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
*/
async function createAScaleSetWithUserData() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithUserData.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 2,
"name": "Standard_A1_v2"
},
"location": "centralus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"diskSizeGB": 512
},
"dataDisks": [
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 0
},
{
"diskSizeGB": 1023,
"createOption": "Empty",
"lun": 1
}
]
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Automatic"
}
},
"zones": [
"1",
"3"
]
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
*/
/**
* Sample code: Create a scale set with virtual machines in different zones.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAScaleSetWithVirtualMachinesInDifferentZones(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("centralus")
.withSku(new Sku().withName("Standard_A1_v2").withTier("Standard").withCapacity(2L))
.withZones(
Arrays.asList("1", "3"))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC))
.withVirtualMachineProfile(
new VirtualMachineScaleSetVMProfile()
.withOsProfile(
new VirtualMachineScaleSetOSProfile()
.withComputerNamePrefix("{vmss-name}").withAdminUsername("{your-username}")
.withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(
new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE).withDiskSizeGB(512)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)))
.withDataDisks(
Arrays
.asList(
new VirtualMachineScaleSetDataDisk()
.withLun(0).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023),
new VirtualMachineScaleSetDataDisk().withLun(
1).withCreateOption(DiskCreateOptionTypes.EMPTY)
.withDiskSizeGB(1023))))
.withNetworkProfile(
new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration()
.withName("{vmss-name}").withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_vms_in_different_zones.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "centralus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Automatic"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"dataDisks": [
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 0},
{"createOption": "Empty", "diskSizeGB": 1023, "lun": 1},
],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diskSizeGB": 512,
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 2, "name": "Standard_A1_v2", "tier": "Standard"},
"zones": ["1", "3"],
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithVirtualMachinesInDifferentZones() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("centralus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](0),
},
{
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
DiskSizeGB: to.Ptr[int32](1023),
Lun: to.Ptr[int32](1),
}},
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
DiskSizeGB: to.Ptr[int32](512),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_A1_v2"),
Capacity: to.Ptr[int64](2),
Tier: to.Ptr("Standard"),
},
Zones: []*string{
to.Ptr("1"),
to.Ptr("3")},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("centralus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(false),
// UniqueID: to.Ptr("8042c376-4690-4c47-9fa2-fbdad70e32fa"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeAutomatic),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// DataDisks: []*armcompute.VirtualMachineScaleSetDataDisk{
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](0),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// {
// Caching: to.Ptr(armcompute.CachingTypesNone),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesEmpty),
// DiskSizeGB: to.Ptr[int32](1023),
// Lun: to.Ptr[int32](1),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// }},
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// DiskSizeGB: to.Ptr[int32](512),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// ZoneBalance: to.Ptr(false),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_A1_v2"),
// Capacity: to.Ptr[int64](2),
// Tier: to.Ptr("Standard"),
// },
// Zones: []*string{
// to.Ptr("1"),
// to.Ptr("3")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
*/
async function createAScaleSetWithVirtualMachinesInDifferentZones() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "centralus",
overprovision: true,
sku: { name: "Standard_A1_v2", capacity: 2, tier: "Standard" },
upgradePolicy: { mode: "Automatic" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
dataDisks: [
{ createOption: "Empty", diskSizeGB: 1023, lun: 0 },
{ createOption: "Empty", diskSizeGB: 1023, lun: 1 },
],
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
diskSizeGB: 512,
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
zones: ["1", "3"],
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMsInDifferentZones.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("centralus"))
{
Sku = new ComputeSku
{
Name = "Standard_A1_v2",
Tier = "Standard",
Capacity = 2L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Automatic,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
DiskSizeGB = 512,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty)
{
DiskSizeGB = 1023,
}},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
},
Zones = { "1", "3" },
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
"hardwareProfile": {
"vmSizeProperties": {
"vCPUsAvailable": 1,
"vCPUsPerCore": 1
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
}
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VMSizeProperties;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetHardwareProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
*/
/**
* Sample code: Create a scale set with vm size properties.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithVmSizeProperties(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withUserData("RXhhbXBsZSBVc2VyRGF0YQ==")
.withHardwareProfile(new VirtualMachineScaleSetHardwareProfile()
.withVmSizeProperties(new VMSizeProperties().withVCpusAvailable(1).withVCpusPerCore(1))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_vm_size_properties.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"hardwareProfile": {"vmSizeProperties": {"vCPUsAvailable": 1, "vCPUsPerCore": 1}},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
"userData": "RXhhbXBsZSBVc2VyRGF0YQ==",
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithVmSizeProperties() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
VMSizeProperties: &armcompute.VMSizeProperties{
VCPUsAvailable: to.Ptr[int32](1),
VCPUsPerCore: to.Ptr[int32](1),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
UserData: to.Ptr("RXhhbXBsZSBVc2VyRGF0YQ=="),
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// HardwareProfile: &armcompute.VirtualMachineScaleSetHardwareProfile{
// VMSizeProperties: &armcompute.VMSizeProperties{
// VCPUsAvailable: to.Ptr[int32](1),
// VCPUsPerCore: to.Ptr[int32](1),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
*/
async function createAScaleSetWithVMSizeProperties() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
hardwareProfile: {
vmSizeProperties: { vCPUsAvailable: 1, vCPUsPerCore: 1 },
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
userData: "RXhhbXBsZSBVc2VyRGF0YQ==",
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithVMSizeProperties.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
HardwareVmSizeProperties = new VirtualMachineSizeProperties
{
VCpusAvailable = 1,
VCpusPerCore = 1,
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
},
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {
"eventGridAndResourceGraph": {
"enable": true
}
},
"userInitiatedRedeploy": {
"automaticallyApprove": true
},
"userInitiatedReboot": {
"automaticallyApprove": true
}
},
"zonalPlatformFaultDomainAlignMode": "Aligned"
}
}
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.EventGridAndResourceGraph;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.ScheduledEventsAdditionalPublishingTargets;
import com.azure.resourcemanager.compute.models.ScheduledEventsPolicy;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.UserInitiatedReboot;
import com.azure.resourcemanager.compute.models.UserInitiatedRedeploy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import com.azure.resourcemanager.compute.models.ZonalPlatformFaultDomainAlignMode;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
*/
/**
* Sample code: Create a scale set with zonalPlatformFaultDomainAlignMode as Aligned.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets().createOrUpdate("myResourceGroup",
"{vmss-name}",
new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withScheduledEventsPolicy(new ScheduledEventsPolicy()
.withUserInitiatedRedeploy(new UserInitiatedRedeploy().withAutomaticallyApprove(true))
.withUserInitiatedReboot(new UserInitiatedReboot().withAutomaticallyApprove(true))
.withScheduledEventsAdditionalPublishingTargets(new ScheduledEventsAdditionalPublishingTargets()
.withEventGridAndResourceGraph(new EventGridAndResourceGraph().withEnable(true))))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true)))))
.withOverprovision(true).withZonalPlatformFaultDomainAlignMode(
ZonalPlatformFaultDomainAlignMode.ALIGNED),
null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_zonal_platform_fault_domain_align_mode.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"scheduledEventsPolicy": {
"scheduledEventsAdditionalPublishingTargets": {"eventGridAndResourceGraph": {"enable": True}},
"userInitiatedReboot": {"automaticallyApprove": True},
"userInitiatedRedeploy": {"automaticallyApprove": True},
},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
"zonalPlatformFaultDomainAlignMode": "Aligned",
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
Enable: to.Ptr(true),
},
},
UserInitiatedReboot: &armcompute.UserInitiatedReboot{
AutomaticallyApprove: to.Ptr(true),
},
UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
AutomaticallyApprove: to.Ptr(true),
},
},
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
ZonalPlatformFaultDomainAlignMode: to.Ptr(armcompute.ZonalPlatformFaultDomainAlignModeAligned),
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// ScheduledEventsPolicy: &armcompute.ScheduledEventsPolicy{
// ScheduledEventsAdditionalPublishingTargets: &armcompute.ScheduledEventsAdditionalPublishingTargets{
// EventGridAndResourceGraph: &armcompute.EventGridAndResourceGraph{
// Enable: to.Ptr(true),
// },
// },
// UserInitiatedReboot: &armcompute.UserInitiatedReboot{
// AutomaticallyApprove: to.Ptr(true),
// },
// UserInitiatedRedeploy: &armcompute.UserInitiatedRedeploy{
// AutomaticallyApprove: to.Ptr(true),
// },
// },
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// ZonalPlatformFaultDomainAlignMode: to.Ptr(armcompute.ZonalPlatformFaultDomainAlignModeAligned),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
*/
async function createAScaleSetWithZonalPlatformFaultDomainAlignModeAsAligned() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
scheduledEventsPolicy: {
scheduledEventsAdditionalPublishingTargets: {
eventGridAndResourceGraph: { enable: true },
},
userInitiatedReboot: { automaticallyApprove: true },
userInitiatedRedeploy: { automaticallyApprove: true },
},
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
zonalPlatformFaultDomainAlignMode: "Aligned",
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithZonalPlatformFaultDomainAlignMode.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
ScheduledEventsPolicy = new ScheduledEventsPolicy
{
UserInitiatedRedeploy = new UserInitiatedRedeploy
{
AutomaticallyApprove = true,
},
AutomaticallyApprove = true,
Enable = true,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
},
Overprovision = true,
ZonalPlatformFaultDomainAlignMode = ZonalPlatformFaultDomainAlignMode.Aligned,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"suppressFailures": true
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
*/
/**
* Sample code: Create a VMSS with an extension that has suppressFailures enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAVMSSWithAnExtensionThatHasSuppressFailuresEnabled(
com.azure.resourcemanager.AzureResourceManager azure) throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile().withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON))
.withSuppressFailures(true)))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_extensions_suppress_failures_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"publisher": "{extension-Publisher}",
"settings": {},
"suppressFailures": True,
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAVmssWithAnExtensionThatHasSuppressFailuresEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
SuppressFailures: to.Ptr(true),
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// SuppressFailures: to.Ptr(true),
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
*/
async function createAVmssWithAnExtensionThatHasSuppressFailuresEnabled() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
publisher: "{extension-Publisher}",
settings: {},
suppressFailures: true,
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithExtensionsSuppressFailuresEnabled.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
SuppressFailures = true,
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_D1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"diagnosticsProfile": {
"bootDiagnostics": {
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": false,
"publisher": "{extension-Publisher}",
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
"settings": {},
"protectedSettingsFromKeyVault": {
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"
}
}
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetExtensionInner;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.BootDiagnostics;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.DiagnosticsProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.KeyVaultSecretReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetExtensionProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.io.IOException;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
*/
/**
* Sample code: Create a VMSS with an extension with protectedSettingsFromKeyVault.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAVMSSWithAnExtensionWithProtectedSettingsFromKeyVault(
com.azure.resourcemanager.AzureResourceManager azure) throws IOException {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_D1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withDiagnosticsProfile(
new DiagnosticsProfile().withBootDiagnostics(new BootDiagnostics().withEnabled(true)
.withStorageUri("http://{existing-storage-account-name}.blob.core.windows.net")))
.withExtensionProfile(new VirtualMachineScaleSetExtensionProfile().withExtensions(
Arrays.asList(new VirtualMachineScaleSetExtensionInner().withName("{extension-name}")
.withPublisher("{extension-Publisher}").withTypePropertiesType("{extension-Type}")
.withTypeHandlerVersion("{handler-version}").withAutoUpgradeMinorVersion(false)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON))
.withProtectedSettingsFromKeyVault(new KeyVaultSecretReference()
.withSecretUrl("fakeTokenPlaceholder")
.withSourceVault(new SubResource().withId(
"/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName")))))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_protected_settings_from_key_vault.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": True,
"storageUri": "http://{existing-storage-account-name}.blob.core.windows.net",
}
},
"extensionProfile": {
"extensions": [
{
"name": "{extension-name}",
"properties": {
"autoUpgradeMinorVersion": False,
"protectedSettingsFromKeyVault": {
"secretUrl": "https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e",
"sourceVault": {
"id": "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"
},
},
"publisher": "{extension-Publisher}",
"settings": {},
"type": "{extension-Type}",
"typeHandlerVersion": "{handler-version}",
},
}
]
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createAVmssWithAnExtensionWithProtectedSettingsFromKeyVault() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
DiagnosticsProfile: &armcompute.DiagnosticsProfile{
BootDiagnostics: &armcompute.BootDiagnostics{
Enabled: to.Ptr(true),
StorageURI: to.Ptr("http://{existing-storage-account-name}.blob.core.windows.net"),
},
},
ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("{extension-name}"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Type: to.Ptr("{extension-Type}"),
AutoUpgradeMinorVersion: to.Ptr(false),
ProtectedSettingsFromKeyVault: &armcompute.KeyVaultSecretReference{
SecretURL: to.Ptr("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"),
SourceVault: &armcompute.SubResource{
ID: to.Ptr("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
},
},
Publisher: to.Ptr("{extension-Publisher}"),
Settings: map[string]any{},
TypeHandlerVersion: to.Ptr("{handler-version}"),
},
}},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_D1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// DiagnosticsProfile: &armcompute.DiagnosticsProfile{
// BootDiagnostics: &armcompute.BootDiagnostics{
// Enabled: to.Ptr(true),
// StorageURI: to.Ptr("http://nsgdiagnostic.blob.core.windows.net"),
// },
// },
// ExtensionProfile: &armcompute.VirtualMachineScaleSetExtensionProfile{
// Extensions: []*armcompute.VirtualMachineScaleSetExtension{
// {
// Name: to.Ptr("{extension-name}"),
// Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
// Type: to.Ptr("{extension-Type}"),
// AutoUpgradeMinorVersion: to.Ptr(false),
// ProtectedSettingsFromKeyVault: &armcompute.KeyVaultSecretReference{
// SecretURL: to.Ptr("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"),
// SourceVault: &armcompute.SubResource{
// ID: to.Ptr("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
// },
// },
// Publisher: to.Ptr("{extension-Publisher}"),
// Settings: map[string]any{
// },
// TypeHandlerVersion: to.Ptr("{handler-version}"),
// },
// }},
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_D1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
*/
async function createAVmssWithAnExtensionWithProtectedSettingsFromKeyVault() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_D1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
diagnosticsProfile: {
bootDiagnostics: {
enabled: true,
storageUri: "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
extensionProfile: {
extensions: [
{
name: "{extension-name}",
typePropertiesType: "{extension-Type}",
autoUpgradeMinorVersion: false,
protectedSettingsFromKeyVault: {
secretUrl:
"https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e",
sourceVault: {
id: "/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName",
},
},
publisher: "{extension-Publisher}",
settings: {},
typeHandlerVersion: "{handler-version}",
},
],
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithProtectedSettingsFromKeyVault.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_D1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
BootDiagnostics = new BootDiagnostics
{
Enabled = true,
StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"),
},
ExtensionProfile = new VirtualMachineScaleSetExtensionProfile
{
Extensions = {new VirtualMachineScaleSetExtensionData
{
Publisher = "{extension-Publisher}",
ExtensionType = "{extension-Type}",
TypeHandlerVersion = "{handler-version}",
AutoUpgradeMinorVersion = false,
Settings = BinaryData.FromObjectAsJson(new object()),
KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"), new WritableSubResource
{
Id = new ResourceIdentifier("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"),
}),
}},
},
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}?api-version=2024-07-01
{
"sku": {
"tier": "Standard",
"capacity": 3,
"name": "Standard_DS1_v2"
},
"location": "westus",
"properties": {
"overprovision": true,
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
}
},
"osProfile": {
"computerNamePrefix": "{vmss-name}",
"adminUsername": "{your-username}",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"primary": true,
"enableIPForwarding": true,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
}
}
]
}
}
]
},
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
}
},
"upgradePolicy": {
"mode": "Manual"
}
}
}
import com.azure.core.management.SubResource;
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineScaleSetInner;
import com.azure.resourcemanager.compute.models.ApiEntityReference;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.CapacityReservationProfile;
import com.azure.resourcemanager.compute.models.DiskCreateOptionTypes;
import com.azure.resourcemanager.compute.models.ImageReference;
import com.azure.resourcemanager.compute.models.Sku;
import com.azure.resourcemanager.compute.models.StorageAccountTypes;
import com.azure.resourcemanager.compute.models.UpgradeMode;
import com.azure.resourcemanager.compute.models.UpgradePolicy;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetIpConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetManagedDiskParameters;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkConfiguration;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetNetworkProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetOSProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetStorageProfile;
import com.azure.resourcemanager.compute.models.VirtualMachineScaleSetVMProfile;
import java.util.Arrays;
/**
* Samples for VirtualMachineScaleSets CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/
* virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
*/
/**
* Sample code: Create or update a scale set with capacity reservation.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAScaleSetWithCapacityReservation(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getVirtualMachineScaleSets()
.createOrUpdate("myResourceGroup", "{vmss-name}", new VirtualMachineScaleSetInner().withLocation("westus")
.withSku(new Sku().withName("Standard_DS1_v2").withTier("Standard").withCapacity(3L))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.MANUAL))
.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile()
.withOsProfile(new VirtualMachineScaleSetOSProfile().withComputerNamePrefix("{vmss-name}")
.withAdminUsername("{your-username}").withAdminPassword("fakeTokenPlaceholder"))
.withStorageProfile(new VirtualMachineScaleSetStorageProfile()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter").withVersion("latest"))
.withOsDisk(new VirtualMachineScaleSetOSDisk().withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS))))
.withNetworkProfile(new VirtualMachineScaleSetNetworkProfile().withNetworkInterfaceConfigurations(
Arrays.asList(new VirtualMachineScaleSetNetworkConfiguration().withName("{vmss-name}")
.withPrimary(true)
.withIpConfigurations(Arrays.asList(new VirtualMachineScaleSetIpConfiguration()
.withName("{vmss-name}")
.withSubnet(new ApiEntityReference().withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"))))
.withEnableIpForwarding(true))))
.withCapacityReservation(
new CapacityReservationProfile().withCapacityReservationGroup(new SubResource().withId(
"subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"))))
.withOverprovision(true), null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_capacity_reservation.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": True,
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"capacityReservation": {
"capacityReservationGroup": {
"id": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_DS1_v2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
func ExampleVirtualMachineScaleSetsClient_BeginCreateOrUpdate_createOrUpdateAScaleSetWithCapacityReservation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewVirtualMachineScaleSetsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "{vmss-name}", armcompute.VirtualMachineScaleSet{
Location: to.Ptr("westus"),
Properties: &armcompute.VirtualMachineScaleSetProperties{
Overprovision: to.Ptr(true),
UpgradePolicy: &armcompute.UpgradePolicy{
Mode: to.Ptr(armcompute.UpgradeModeManual),
},
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
CapacityReservation: &armcompute.CapacityReservationProfile{
CapacityReservationGroup: &armcompute.SubResource{
ID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
},
},
NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.Ptr("{vmss-name}"),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &armcompute.APIEntityReference{
ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
},
},
}},
Primary: to.Ptr(true),
},
}},
},
OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
AdminPassword: to.Ptr("{your-password}"),
AdminUsername: to.Ptr("{your-username}"),
ComputerNamePrefix: to.Ptr("{vmss-name}"),
},
StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
ImageReference: &armcompute.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter"),
Version: to.Ptr("latest"),
},
OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
Caching: to.Ptr(armcompute.CachingTypesReadWrite),
CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
},
},
},
},
},
SKU: &armcompute.SKU{
Name: to.Ptr("Standard_DS1_v2"),
Capacity: to.Ptr[int64](3),
Tier: to.Ptr("Standard"),
},
}, &armcompute.VirtualMachineScaleSetsClientBeginCreateOrUpdateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.VirtualMachineScaleSet = armcompute.VirtualMachineScaleSet{
// Name: to.Ptr("{vmss-name}"),
// Type: to.Ptr("Microsoft.Compute/virtualMachineScaleSets"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}"),
// Location: to.Ptr("westus"),
// Properties: &armcompute.VirtualMachineScaleSetProperties{
// Overprovision: to.Ptr(true),
// ProvisioningState: to.Ptr("Succeeded"),
// SinglePlacementGroup: to.Ptr(true),
// UniqueID: to.Ptr("d053ec5a-8da6-495f-ab13-38216503c6d7"),
// UpgradePolicy: &armcompute.UpgradePolicy{
// Mode: to.Ptr(armcompute.UpgradeModeManual),
// },
// VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{
// CapacityReservation: &armcompute.CapacityReservationProfile{
// CapacityReservationGroup: &armcompute.SubResource{
// ID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
// },
// },
// NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{
// NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{
// DNSSettings: &armcompute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{
// DNSServers: []*string{
// },
// },
// EnableAcceleratedNetworking: to.Ptr(false),
// EnableIPForwarding: to.Ptr(true),
// IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{
// {
// Name: to.Ptr("{vmss-name}"),
// Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
// PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4),
// Subnet: &armcompute.APIEntityReference{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/nsgExistingVnet/subnets/nsgExistingSubnet"),
// },
// },
// }},
// Primary: to.Ptr(true),
// },
// }},
// },
// OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{
// AdminUsername: to.Ptr("{your-username}"),
// ComputerNamePrefix: to.Ptr("{vmss-name}"),
// Secrets: []*armcompute.VaultSecretGroup{
// },
// WindowsConfiguration: &armcompute.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(true),
// ProvisionVMAgent: to.Ptr(true),
// },
// },
// StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{
// ImageReference: &armcompute.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter"),
// Version: to.Ptr("latest"),
// },
// OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{
// Caching: to.Ptr(armcompute.CachingTypesReadWrite),
// CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage),
// ManagedDisk: &armcompute.VirtualMachineScaleSetManagedDiskParameters{
// StorageAccountType: to.Ptr(armcompute.StorageAccountTypesStandardLRS),
// },
// },
// },
// },
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](3),
// Tier: to.Ptr("Standard"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create or update a VM scale set.
*
* @summary Create or update a VM scale set.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
*/
async function createOrUpdateAScaleSetWithCapacityReservation() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const vmScaleSetName = "{vmss-name}";
const parameters = {
location: "westus",
overprovision: true,
sku: { name: "Standard_DS1_v2", capacity: 3, tier: "Standard" },
upgradePolicy: { mode: "Manual" },
virtualMachineProfile: {
capacityReservation: {
capacityReservationGroup: {
id: "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}",
},
},
networkProfile: {
networkInterfaceConfigurations: [
{
name: "{vmss-name}",
enableIPForwarding: true,
ipConfigurations: [
{
name: "{vmss-name}",
subnet: {
id: "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}",
},
},
],
primary: true,
},
],
},
osProfile: {
adminPassword: "{your-password}",
adminUsername: "{your-username}",
computerNamePrefix: "{vmss-name}",
},
storageProfile: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter",
version: "latest",
},
osDisk: {
caching: "ReadWrite",
createOption: "FromImage",
managedDisk: { storageAccountType: "Standard_LRS" },
},
},
},
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.virtualMachineScaleSets.beginCreateOrUpdateAndWait(
resourceGroupName,
vmScaleSetName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithCapacityReservation.json
// this example is just showing the usage of "VirtualMachineScaleSets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this VirtualMachineScaleSetResource
VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets();
// invoke the operation
string virtualMachineScaleSetName = "{vmss-name}";
VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus"))
{
Sku = new ComputeSku
{
Name = "Standard_DS1_v2",
Tier = "Standard",
Capacity = 3L,
},
Properties = new VirtualMachineScaleSetProperties
{
UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy
{
Mode = VirtualMachineScaleSetUpgradeMode.Manual,
},
VirtualMachineProfile = new VirtualMachineScaleSetVmProfile
{
OSProfile = new VirtualMachineScaleSetOSProfile
{
ComputerNamePrefix = "{vmss-name}",
AdminUsername = "{your-username}",
AdminPassword = "{your-password}",
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage)
{
Caching = CachingType.ReadWrite,
ManagedDisk = new VirtualMachineScaleSetManagedDisk
{
StorageAccountType = StorageAccountType.StandardLrs,
},
},
},
NetworkProfile = new VirtualMachineScaleSetNetworkProfile
{
NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}")
{
Primary = true,
IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}")
{
SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"),
}},
EnableIPForwarding = true,
}},
},
CapacityReservationGroupId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"),
},
Overprovision = true,
},
};
ArmOperation<VirtualMachineScaleSetResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineScaleSetName, data);
VirtualMachineScaleSetResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
VirtualMachineScaleSetData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Risposta di esempio
{
"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}"
}
Definizioni
Nome |
Descrizione |
AdditionalCapabilities
|
Abilita o disabilita una funzionalità nella macchina virtuale o nel set di scalabilità di macchine virtuali.
|
AdditionalUnattendContent
|
Specifica informazioni aggiuntive in formato XML che possono essere incluse nel file Unattend.xml, utilizzato dal programma di installazione di Windows. Il contenuto viene definito impostando il nome, il nome del componente e il passaggio in cui viene applicato il contenuto.
|
AllocationStrategy
|
Specifica la strategia di allocazione per il set di scalabilità di macchine virtuali in base alla quale verranno allocate le macchine virtuali.
|
ApiEntityReference
|
Informazioni di riferimento sulle entità API.
|
ApiError
|
Errore dell'API.
|
ApiErrorBase
|
Base degli errori api.
|
ApplicationProfile
|
Contiene l'elenco delle applicazioni della raccolta che devono essere rese disponibili per la macchina virtuale/set di scalabilità di macchine virtuali
|
AutomaticOSUpgradePolicy
|
Parametri di configurazione usati per eseguire l'aggiornamento automatico del sistema operativo.
|
AutomaticRepairsPolicy
|
Specifica i parametri di configurazione per le riparazioni automatiche nel set di scalabilità di macchine virtuali.
|
BillingProfile
|
Specifica i dettagli relativi alla fatturazione di una macchina virtuale spot di Azure o del set di scalabilità di macchine virtuali. Versione minima api: 2019-03-01.
|
BootDiagnostics
|
Diagnostica di avvio è una funzionalità di debug che consente di visualizzare l'output e lo screenshot della console per diagnosticare lo stato della macchina virtuale. È possibile visualizzare facilmente l'output del log della console. Azure consente anche di visualizzare uno screenshot della macchina virtuale dall'hypervisor.
|
CachingTypes
|
Specifica i requisiti di memorizzazione nella cache. I valori possibili sono: None,ReadOnly,ReadWrite. I valori predefiniti sono: Nessuno per l'archiviazione Standard. ReadOnly per l'archiviazione Premium.
|
CapacityReservationProfile
|
Parametri di un profilo di prenotazione della capacità.
|
CloudError
|
Risposta di errore dal servizio di calcolo.
|
ComponentNames
|
Nome del componente. Attualmente, l'unico valore consentito è Microsoft-Windows-Shell-Setup.
|
DeleteOptions
|
Specificare cosa accade all'indirizzo IP pubblico quando la macchina virtuale viene eliminata
|
DiagnosticsProfile
|
Specifica lo stato delle impostazioni di diagnostica di avvio. Versione minima api: 2015-06-15.
|
DiffDiskOptions
|
Specifica le impostazioni temporanee del disco per il disco del sistema operativo.
|
DiffDiskPlacement
|
Specifica il posizionamento temporaneo del disco per il disco del sistema operativo. Questa proprietà può essere usata dall'utente nella richiesta per scegliere il percorso, ad esempio il disco della cache, il disco delle risorse o lo spazio su disco nvme per il provisioning temporaneo del disco del sistema operativo. Per altre informazioni sui requisiti delle dimensioni del disco del sistema operativo temporaneo, vedere Requisiti delle dimensioni del disco del sistema operativo temporaneo per la macchina virtuale Windows in https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e macchina virtuale Linux all'indirizzo https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. Versione minima api per NvmeDisk: 2024-03-01.
|
DiffDiskSettings
|
Descrive i parametri delle impostazioni temporanee del disco che possono essere specificate per il disco del sistema operativo.
Nota: Le impostazioni temporanee del disco possono essere specificate solo per il disco gestito.
|
DiskControllerTypes
|
|
DiskCreateOptionTypes
|
Specifica la modalità di creazione delle macchine virtuali nel set di scalabilità. L'unico valore consentito è: FromImage. Questo valore viene usato quando si usa un'immagine per creare la macchina virtuale. Se si usa un'immagine della piattaforma, si usa anche l'elemento imageReference descritto in precedenza. Se si usa un'immagine del marketplace, si usa anche l'elemento di piano descritto in precedenza.
|
DiskDeleteOptionTypes
|
Specifica se il disco del sistema operativo deve essere eliminato o scollegato dopo l'eliminazione di VMSS Flex (questa funzionalità è disponibile solo per VMSS con OrchestrationMode flessibile).
Valori possibili:
Elimina Se si usa questo valore, il disco del sistema operativo viene eliminato quando viene eliminata la macchina virtuale VmSS Flex.
Scollegare Se si usa questo valore, il disco del sistema operativo viene mantenuto dopo l'eliminazione della macchina virtuale Flex di VMSS.
Il valore predefinito è impostato su Elimina. Per un disco del sistema operativo temporaneo, il valore predefinito è impostato su Elimina. L'utente non può modificare l'opzione di eliminazione per disco del sistema operativo temporaneo.
|
DiskEncryptionSetParameters
|
Descrive il parametro dell'ID risorsa del set di crittografia dischi gestiti dal cliente che può essere specificato per il disco.
Nota: L'ID risorsa del set di crittografia del disco può essere specificato solo per il disco gestito. Per altri dettagli, vedere https://aka.ms/mdssewithcmkoverview.
|
DomainNameLabelScopeTypes
|
Ambito dell'etichetta nome di dominio. La concatenazione dell'etichetta del nome di dominio con hash generata in base ai criteri dall'ambito dell'etichetta del nome di dominio e l'indice vm saranno le etichette dei nomi di dominio delle risorse PublicIPAddress che verranno create
|
EncryptionIdentity
|
Specifica l'identità gestita usata da ADE per ottenere il token di accesso per le operazioni dell'insieme di credenziali delle chiavi.
|
EventGridAndResourceGraph
|
Specifica le configurazioni correlate agli eventi pianificati correlate a eventGridAndResourceGraph.
|
ExtendedLocation
|
Tipo complesso della posizione estesa.
|
ExtendedLocationTypes
|
Tipo della posizione estesa.
|
ImageReference
|
Specifica le informazioni sull'immagine da usare. È possibile specificare informazioni sulle immagini della piattaforma, sulle immagini del marketplace o sulle immagini delle macchine virtuali. Questo elemento è obbligatorio quando si vuole usare un'immagine della piattaforma, un'immagine del marketplace o un'immagine di macchina virtuale, ma non viene usata in altre operazioni di creazione. NOTA: l'autore e l'offerta di riferimento delle immagini possono essere impostati solo quando si crea il set di scalabilità.
|
InnerError
|
Dettagli dell'errore interno.
|
IPVersion
|
Disponibile da Api-Version 2019-07-01 e versioni successive, indica se la configurazione ip specifica è IPv4 o IPv6. Il valore predefinito è IPv4. I valori possibili sono: 'IPv4' e 'IPv6'.
|
KeyVaultSecretReference
|
Descrive un riferimento al segreto dell'insieme di credenziali delle chiavi
|
LinuxConfiguration
|
Specifica le impostazioni del sistema operativo Linux nella macchina virtuale. Per un elenco delle distribuzioni Linux supportate, vedere Linux in distribuzioni Azure-Endorsed.
|
LinuxPatchAssessmentMode
|
Specifica la modalità di valutazione della patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
|
LinuxPatchSettings
|
Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Linux.
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
|
LinuxVMGuestPatchAutomaticByPlatformSettings
|
Specifica impostazioni aggiuntive da applicare quando la modalità patch AutomaticByPlatform è selezionata nelle impostazioni della patch linux.
|
LinuxVMGuestPatchMode
|
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
ImageDefault: viene usata la configurazione di applicazione di patch predefinita della macchina virtuale.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. La proprietà provisionVMAgent deve essere true
|
Mode
|
Specifica la modalità su cui Verrà eseguito ProxyAgent se la funzionalità è abilitata. ProxyAgent inizierà a controllare o monitorare ma non a imporre il controllo di accesso sulle richieste agli endpoint host in modalità di controllo, mentre in modalità di imposizione applichererà il controllo di accesso. Il valore predefinito è Imponi modalità.
|
NetworkApiVersion
|
specifica la versione dell'API Microsoft.Network usata durante la creazione di risorse di rete nelle configurazioni dell'interfaccia di rete per il set di scalabilità di macchine virtuali con modalità di orchestrazione "Flessibile"
|
NetworkInterfaceAuxiliaryMode
|
Specifica se la modalità ausiliaria è abilitata per la risorsa interfaccia di rete.
|
NetworkInterfaceAuxiliarySku
|
Specifica se lo SKU ausiliario è abilitato per la risorsa interfaccia di rete.
|
OperatingSystemTypes
|
Questa proprietà consente di specificare il tipo di sistema operativo incluso nel disco se si crea una macchina virtuale da un'immagine utente o un disco rigido virtuale specializzato. I valori possibili sono: Windows,Linux.
|
OrchestrationMode
|
Specifica la modalità di orchestrazione per il set di scalabilità di macchine virtuali.
|
OSImageNotificationProfile
|
|
PassNames
|
Nome del pass. Attualmente, l'unico valore consentito è OobeSystem.
|
PatchSettings
|
Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Windows.
|
Plan
|
Specifica informazioni sull'immagine del marketplace usata per creare la macchina virtuale. Questo elemento viene usato solo per le immagini del Marketplace. Prima di poter usare un'immagine del marketplace da un'API, è necessario abilitare l'immagine per l'uso a livello di codice. Nel portale di Azure individuare l'immagine del Marketplace che si vuole usare e quindi fare clic su Si vuole distribuire a livello di codice, Introduzione ->. Immettere le informazioni necessarie e quindi fare clic su Salva.
|
PriorityMixPolicy
|
Specifica le divisioni di destinazione per le macchine virtuali con priorità spot e regolare all'interno di un set di scalabilità con modalità di orchestrazione flessibile. Con questa proprietà, il cliente è in grado di specificare il numero di base di macchine virtuali con priorità regolare create quando l'istanza flex vmSS aumenta e la divisione tra macchine virtuali con priorità spot e regolare dopo il raggiungimento di questa destinazione di base.
|
ProtocolTypes
|
Specifica il protocollo del listener WinRM. I valori possibili sono: http,https.
|
ProxyAgentSettings
|
Specifica le impostazioni proxyAgent durante la creazione della macchina virtuale. Versione minima api: 2023-09-01.
|
PublicIPAddressSku
|
Descrive lo SKU dell'indirizzo IP pubblico. Può essere impostato solo con OrchestrationMode come flessibile.
|
PublicIPAddressSkuName
|
Specificare il nome dello SKU IP pubblico
|
PublicIPAddressSkuTier
|
Specificare il livello SKU DELL'INDIRIZZO IP pubblico
|
RepairAction
|
Tipo di azione di ripristino (sostituzione, riavvio, ricreazione immagine) che verrà usata per ripristinare macchine virtuali non integre nel set di scalabilità. Il valore predefinito è replace.
|
ResiliencyPolicy
|
Descrive un criterio di resilienza: resilientVMCreationPolicy e/o resilientVMDeletionPolicy.
|
ResilientVMCreationPolicy
|
I parametri di configurazione usati durante l'esecuzione della creazione di macchine virtuali resilienti.
|
ResilientVMDeletionPolicy
|
Parametri di configurazione usati durante l'esecuzione dell'eliminazione resiliente della macchina virtuale.
|
ResourceIdentityType
|
Tipo di identità usato per il set di scalabilità di macchine virtuali. Il tipo 'SystemAssigned, UserAssigned' include sia un'identità creata in modo implicito che un set di identità assegnate dall'utente. Il tipo "Nessuno" rimuoverà tutte le identità dal set di scalabilità di macchine virtuali.
|
RollingUpgradePolicy
|
Parametri di configurazione usati durante l'esecuzione di un aggiornamento in sequenza.
|
ScaleInPolicy
|
Descrive un criterio di scalabilità orizzontale per un set di scalabilità di macchine virtuali.
|
ScheduledEventsAdditionalPublishingTargets
|
|
ScheduledEventsPolicy
|
Specifica le configurazioni correlate a Redeploy, Reboot e ScheduledEventsAdditionalPublishingTargets Scheduled Event.
|
ScheduledEventsProfile
|
|
securityEncryptionTypes
|
Specifica encryptionType del disco gestito. È impostato su DiskWithVMGuestState per la crittografia del disco gestito insieme al BLOB VMGuestState, VMGuestStateOnly per la crittografia solo del BLOB VMGuestState e NonPersistedTPM per non rendere persistente lo stato del firmware nel BLOB VMGuestState.
Nota: può essere impostato solo per le macchine virtuali riservate.
|
SecurityPostureReference
|
Specifica il comportamento di sicurezza da usare nel set di scalabilità. Versione minima api: 2023-03-01
|
SecurityProfile
|
Specifica le impostazioni del profilo di sicurezza per la macchina virtuale o il set di scalabilità di macchine virtuali.
|
SecurityTypes
|
Specifica il Tipo di sicurezza della macchina virtuale. Deve essere impostato su qualsiasi valore specificato per abilitare UefiSettings. Il comportamento predefinito è: UefiSettings non verrà abilitato a meno che questa proprietà non sia impostata.
|
ServiceArtifactReference
|
Specifica l'ID di riferimento dell'artefatto del servizio usato per impostare la stessa versione dell'immagine per tutte le macchine virtuali nel set di scalabilità quando si usa la versione dell'immagine 'latest'. Versione minima api: 2022-11-01
|
SettingNames
|
Specifica il nome dell'impostazione a cui si applica il contenuto. I valori possibili sono: FirstLogonCommands e AutoLogon.
|
Sku
|
Descrive uno SKU del set di scalabilità di macchine virtuali. NOTA: se il nuovo SKU della macchina virtuale non è supportato nell'hardware in cui è attualmente attivo il set di scalabilità, è necessario deallocare le macchine virtuali nel set di scalabilità prima di modificare il nome dello SKU.
|
SkuProfile
|
Specifica il profilo sku per il set di scalabilità di macchine virtuali. Con questa proprietà il cliente è in grado di specificare un elenco di dimensioni delle macchine virtuali e una strategia di allocazione.
|
SkuProfileVMSize
|
Specifica le dimensioni della macchina virtuale.
|
SpotRestorePolicy
|
Specifica le proprietà spot-Try-Restore per il set di scalabilità di macchine virtuali. Con questa proprietà il cliente può abilitare o disabilitare il ripristino automatico delle istanze di macchine virtuali Spot VMSS rimosse in modo opportunistico in base alla disponibilità della capacità e al vincolo dei prezzi.
|
SshConfiguration
|
Configurazione SSH per macchine virtuali basate su Linux in esecuzione in Azure
|
SshPublicKey
|
Contiene informazioni sulla chiave pubblica del certificato SSH e sul percorso nella macchina virtuale Linux in cui viene inserita la chiave pubblica.
|
StorageAccountTypes
|
Specifica il tipo di account di archiviazione per il disco gestito. NOTA: UltraSSD_LRS può essere usato solo con dischi dati, non può essere usato con il disco del sistema operativo.
|
SubResource
|
|
TerminateNotificationProfile
|
|
UefiSettings
|
Specifica le impostazioni di sicurezza, ad esempio l'avvio protetto e vTPM usato durante la creazione della macchina virtuale. Versione minima api: 2020-12-01.
|
UpgradeMode
|
Specifica la modalità di un aggiornamento alle macchine virtuali nel set di scalabilità.
I valori possibili sono:
manuale: è possibile controllare l'applicazione degli aggiornamenti alle macchine virtuali nel set di scalabilità. A tale scopo, usare l'azione manualUpgrade.
automatico: tutte le macchine virtuali nel set di scalabilità vengono aggiornate automaticamente contemporaneamente.
|
UpgradePolicy
|
Descrive un criterio di aggiornamento: automatico, manuale o in sequenza.
|
UserAssignedIdentities
|
Elenco di identità utente associate alla macchina virtuale. I riferimenti alla chiave del dizionario delle identità utente saranno id risorsa ARM nel formato :'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
UserInitiatedReboot
|
Specifica le configurazioni correlate agli eventi pianificati correlati al riavvio.
|
UserInitiatedRedeploy
|
Specifica le configurazioni correlate all'evento pianificato correlate alla ridistribuitura.
|
VaultCertificate
|
Descrive un singolo riferimento al certificato in un insieme di credenziali delle chiavi e dove risiede il certificato nella macchina virtuale.
|
VaultSecretGroup
|
Descrive un set di certificati che si trovano tutti nello stesso insieme di credenziali delle chiavi.
|
VirtualHardDisk
|
Descrive l'URI di un disco.
|
VirtualMachineEvictionPolicyTypes
|
Specifica i criteri di rimozione per la macchina virtuale Spot di Azure e il set di scalabilità spot di Azure. Per le macchine virtuali Spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2019-03-01. Per i set di scalabilità spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2017-10-30-preview.
|
VirtualMachinePriorityTypes
|
Specifica la priorità per le macchine virtuali nel set di scalabilità. Versione minima api: 2017-10-30-preview.
|
VirtualMachineScaleSet
|
Descrive un set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetDataDisk
|
Descrive un disco dati del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetExtension
|
Descrive un'estensione del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetExtensionProfile
|
Descrive un profilo di estensione del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetHardwareProfile
|
Specifica le impostazioni hardware per il set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetIdentity
|
Identità per il set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetIPConfiguration
|
Descrive la configurazione IP di un profilo di rete del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetIpTag
|
Contiene il tag IP associato all'indirizzo IP pubblico.
|
VirtualMachineScaleSetManagedDiskParameters
|
Descrive i parametri di un disco gestito scaleset.
|
VirtualMachineScaleSetNetworkConfiguration
|
Descrive le configurazioni di rete del profilo di rete di un set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
Descrive le impostazioni DNS di una configurazione DNS dei set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetNetworkProfile
|
Descrive un profilo di rete del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetOSDisk
|
Descrive un disco del sistema operativo del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetOSProfile
|
Descrive un profilo del sistema operativo del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetPublicIPAddressConfiguration
|
Descrive la configurazione publicIPAddress di un set di scalabilità di macchine virtuali
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
|
Descrive le impostazioni DNS di una configurazione DNS dei set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetScaleInRules
|
Regole da seguire durante il ridimensionamento di un set di scalabilità di macchine virtuali.
I valori possibili sono:
Impostazione predefinita Quando viene ridimensionato un set di scalabilità di macchine virtuali, il set di scalabilità verrà prima bilanciato tra le zone se si tratta di un set di scalabilità di zona. Quindi, verrà bilanciato tra domini di errore il più possibile. All'interno di ogni dominio di errore, le macchine virtuali scelte per la rimozione saranno quelle più recenti che non sono protette dal ridimensionamento.
OldestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali meno recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali meno recenti che non sono protette per la rimozione.
NewestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali più recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali più recenti che non sono protette per la rimozione.
|
VirtualMachineScaleSetStorageProfile
|
Descrive un profilo di archiviazione del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetVMProfile
|
Descrive un profilo di macchina virtuale del set di scalabilità di macchine virtuali.
|
VMDiskSecurityProfile
|
Specifica le impostazioni del profilo di sicurezza per il disco gestito.
Nota: può essere impostato solo per le macchine virtuali riservate.
|
VMGalleryApplication
|
Specifica le informazioni necessarie per fare riferimento a una versione dell'applicazione della raccolta di calcolo
|
VMSizeProperties
|
Specifica le impostazioni delle proprietà dimensioni macchina virtuale nella macchina virtuale.
|
WindowsConfiguration
|
Specifica le impostazioni del sistema operativo Windows nella macchina virtuale.
|
WindowsPatchAssessmentMode
|
Specifica la modalità di valutazione delle patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
|
WindowsVMGuestPatchAutomaticByPlatformSettings
|
Specifica impostazioni aggiuntive da applicare quando la modalità patch AutomaticByPlatform è selezionata nelle impostazioni della patch di Windows.
|
WindowsVMGuestPatchMode
|
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
manuale: è possibile controllare l'applicazione di patch a una macchina virtuale. A tale scopo, applicare manualmente le patch all'interno della macchina virtuale. In questa modalità gli aggiornamenti automatici sono disabilitati; La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere false
AutomaticByOS: la macchina virtuale verrà aggiornata automaticamente dal sistema operativo. La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere true.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. Le proprietà provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devono essere true
|
WinRMConfiguration
|
Descrive la configurazione di Gestione remota Windows della macchina virtuale
|
WinRMListener
|
Descrive il protocollo e l'identificazione personale del listener di Gestione remota Windows
|
ZonalPlatformFaultDomainAlignMode
|
Specifica la modalità di allineamento tra il calcolo del set di scalabilità di macchine virtuali e il numero di domini di errore di archiviazione.
|
AdditionalCapabilities
Abilita o disabilita una funzionalità nella macchina virtuale o nel set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
hibernationEnabled
|
boolean
|
Flag che abilita o disabilita la funzionalità di ibernazione nella macchina virtuale.
|
ultraSSDEnabled
|
boolean
|
Flag che abilita o disabilita una funzionalità per avere uno o più dischi dati gestiti con UltraSSD_LRS tipo di account di archiviazione nella macchina virtuale o nel set di scalabilità di macchine virtuali. I dischi gestiti con tipo di account di archiviazione UltraSSD_LRS possono essere aggiunti a una macchina virtuale o a un set di scalabilità di macchine virtuali solo se questa proprietà è abilitata.
|
AdditionalUnattendContent
Specifica informazioni aggiuntive in formato XML che possono essere incluse nel file Unattend.xml, utilizzato dal programma di installazione di Windows. Il contenuto viene definito impostando il nome, il nome del componente e il passaggio in cui viene applicato il contenuto.
Nome |
Tipo |
Descrizione |
componentName
|
ComponentNames
|
Nome del componente. Attualmente, l'unico valore consentito è Microsoft-Windows-Shell-Setup.
|
content
|
string
|
Specifica il contenuto in formato XML aggiunto al file unattend.xml per il percorso e il componente specificati. Il codice XML deve essere minore di 4 KB e deve includere l'elemento radice per l'impostazione o la funzionalità da inserire.
|
passName
|
PassNames
|
Nome del pass. Attualmente, l'unico valore consentito è OobeSystem.
|
settingName
|
SettingNames
|
Specifica il nome dell'impostazione a cui si applica il contenuto. I valori possibili sono: FirstLogonCommands e AutoLogon.
|
AllocationStrategy
Specifica la strategia di allocazione per il set di scalabilità di macchine virtuali in base alla quale verranno allocate le macchine virtuali.
Nome |
Tipo |
Descrizione |
CapacityOptimized
|
string
|
|
LowestPrice
|
string
|
|
ApiEntityReference
Informazioni di riferimento sulle entità API.
Nome |
Tipo |
Descrizione |
id
|
string
|
ID risorsa ARM sotto forma di /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
|
ApiError
Errore dell'API.
Nome |
Tipo |
Descrizione |
code
|
string
|
Codice di errore.
|
details
|
ApiErrorBase[]
|
Dettagli dell'errore dell'API
|
innererror
|
InnerError
|
Errore interno dell'API
|
message
|
string
|
Messaggio di errore.
|
target
|
string
|
Destinazione dell'errore specifico.
|
ApiErrorBase
Base degli errori api.
Nome |
Tipo |
Descrizione |
code
|
string
|
Codice di errore.
|
message
|
string
|
Messaggio di errore.
|
target
|
string
|
Destinazione dell'errore specifico.
|
ApplicationProfile
Contiene l'elenco delle applicazioni della raccolta che devono essere rese disponibili per la macchina virtuale/set di scalabilità di macchine virtuali
Nome |
Tipo |
Descrizione |
galleryApplications
|
VMGalleryApplication[]
|
Specifica le applicazioni della raccolta che devono essere rese disponibili per la macchina virtuale/set di scalabilità di macchine virtuali
|
AutomaticOSUpgradePolicy
Parametri di configurazione usati per eseguire l'aggiornamento automatico del sistema operativo.
Nome |
Tipo |
Descrizione |
disableAutomaticRollback
|
boolean
|
Indica se la funzionalità di rollback dell'immagine del sistema operativo deve essere disabilitata. Il valore predefinito è false.
|
enableAutomaticOSUpgrade
|
boolean
|
Indica se gli aggiornamenti del sistema operativo devono essere applicati automaticamente alle istanze del set di scalabilità in sequenza quando diventa disponibile una versione più recente dell'immagine del sistema operativo. Il valore predefinito è false. Se è impostato su true per i set di scalabilità basati su Windows, enableAutomaticUpdates viene impostato automaticamente su false e non può essere impostato su true.
|
osRollingUpgradeDeferral
|
boolean
|
Indica se l'aggiornamento automatico del sistema operativo deve essere sottoposto a rinvio. Gli aggiornamenti posticipati del sistema operativo invieranno notifiche avanzate per ogni macchina virtuale che un aggiornamento del sistema operativo dagli aggiornamenti in sequenza è in ingresso, tramite il tag IMDS 'Platform.PendingOSUpgrade'. L'aggiornamento quindi rinvia fino a quando l'aggiornamento non viene approvato tramite una chiamata ApproveRollingUpgrade.
|
useRollingUpgradePolicy
|
boolean
|
Indica se i criteri di aggiornamento in sequenza devono essere usati durante l'aggiornamento automatico del sistema operativo. Il valore predefinito è false. L'aggiornamento automatico del sistema operativo eseguirà il fallback ai criteri predefiniti se non sono definiti criteri nel set di scalabilità di macchine virtuali.
|
AutomaticRepairsPolicy
Specifica i parametri di configurazione per le riparazioni automatiche nel set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Specifica se le riparazioni automatiche devono essere abilitate nel set di scalabilità di macchine virtuali. Il valore predefinito è false.
|
gracePeriod
|
string
|
Periodo di tempo per il quale le riparazioni automatiche vengono sospese a causa di una modifica dello stato nella macchina virtuale. Il tempo di tolleranza inizia dopo il completamento della modifica dello stato. Ciò consente di evitare riparazioni premature o accidentali. La durata dell'ora deve essere specificata nel formato ISO 8601. Il periodo di tolleranza minimo consentito è 10 minuti (PT10M), che è anche il valore predefinito. Il periodo di tolleranza massimo consentito è 90 minuti (PT90M).
|
repairAction
|
RepairAction
|
Tipo di azione di ripristino (sostituzione, riavvio, ricreazione immagine) che verrà usata per ripristinare macchine virtuali non integre nel set di scalabilità. Il valore predefinito è replace.
|
BillingProfile
Specifica i dettagli relativi alla fatturazione di una macchina virtuale spot di Azure o del set di scalabilità di macchine virtuali. Versione minima api: 2019-03-01.
Nome |
Tipo |
Descrizione |
maxPrice
|
number
|
Specifica il prezzo massimo che si vuole pagare per una macchina virtuale/set di scalabilità di macchine virtuali spot di Azure. Questo prezzo è in dollari USA.
Questo prezzo verrà confrontato con il prezzo corrente di Azure Spot per le dimensioni della macchina virtuale. Inoltre, i prezzi vengono confrontati al momento della creazione/aggiornamento di macchine virtuali spot di Azure/SET di scalabilità di macchine virtuali e l'operazione avrà esito positivo solo se il prezzo maxPrice è maggiore del prezzo corrente di Azure Spot.
MaxPrice verrà usato anche per rimuovere una macchina virtuale/set di scalabilità di macchine virtuali spot di Azure se il prezzo corrente di Azure Spot supera il valore maxPrice dopo la creazione di macchine virtuali/set di scalabilità di macchine virtuali.
I valori possibili sono:
- Qualsiasi valore decimale maggiore di zero. Esempio: 0.01538
-1 : indica il prezzo predefinito da up-to su richiesta.
È possibile impostare maxPrice su -1 per indicare che la macchina virtuale/set di scalabilità di macchine virtuali spot di Azure non deve essere eliminata per motivi di prezzo. Inoltre, il prezzo massimo predefinito è -1 se non è fornito dall'utente.
Versione minima api: 2019-03-01.
|
BootDiagnostics
Diagnostica di avvio è una funzionalità di debug che consente di visualizzare l'output e lo screenshot della console per diagnosticare lo stato della macchina virtuale. È possibile visualizzare facilmente l'output del log della console. Azure consente anche di visualizzare uno screenshot della macchina virtuale dall'hypervisor.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Indica se la diagnostica di avvio deve essere abilitata nella macchina virtuale.
|
storageUri
|
string
|
URI dell'account di archiviazione da usare per inserire l'output e lo screenshot della console. Se storageUri non viene specificato durante l'abilitazione della diagnostica di avvio, verrà usata l'archiviazione gestita.
|
CachingTypes
Specifica i requisiti di memorizzazione nella cache. I valori possibili sono: None,ReadOnly,ReadWrite. I valori predefiniti sono: Nessuno per l'archiviazione Standard. ReadOnly per l'archiviazione Premium.
Nome |
Tipo |
Descrizione |
None
|
string
|
|
ReadOnly
|
string
|
|
ReadWrite
|
string
|
|
CapacityReservationProfile
Parametri di un profilo di prenotazione della capacità.
Nome |
Tipo |
Descrizione |
capacityReservationGroup
|
SubResource
|
Specifica l'ID risorsa del gruppo di prenotazioni di capacità che deve essere usato per allocare la macchina virtuale o le istanze di vm del set di scalabilità a condizione che sia stata riservata una capacità sufficiente. Per altri dettagli, vedere https://aka.ms/CapacityReservation.
|
CloudError
Risposta di errore dal servizio di calcolo.
Nome |
Tipo |
Descrizione |
error
|
ApiError
|
Errore dell'API.
|
ComponentNames
Nome del componente. Attualmente, l'unico valore consentito è Microsoft-Windows-Shell-Setup.
Nome |
Tipo |
Descrizione |
Microsoft-Windows-Shell-Setup
|
string
|
|
DeleteOptions
Specificare cosa accade all'indirizzo IP pubblico quando la macchina virtuale viene eliminata
Nome |
Tipo |
Descrizione |
Delete
|
string
|
|
Detach
|
string
|
|
DiagnosticsProfile
Specifica lo stato delle impostazioni di diagnostica di avvio. Versione minima api: 2015-06-15.
Nome |
Tipo |
Descrizione |
bootDiagnostics
|
BootDiagnostics
|
Diagnostica di avvio è una funzionalità di debug che consente di visualizzare l'output e lo screenshot della console per diagnosticare lo stato della macchina virtuale.
NOTA: se si specifica storageUri, assicurarsi che l'account di archiviazione si trova nella stessa area e nella stessa sottoscrizione della macchina virtuale. È possibile visualizzare facilmente l'output del log della console. Azure consente anche di visualizzare uno screenshot della macchina virtuale dall'hypervisor.
|
DiffDiskOptions
Specifica le impostazioni temporanee del disco per il disco del sistema operativo.
Nome |
Tipo |
Descrizione |
Local
|
string
|
|
DiffDiskPlacement
Specifica il posizionamento temporaneo del disco per il disco del sistema operativo. Questa proprietà può essere usata dall'utente nella richiesta per scegliere il percorso, ad esempio il disco della cache, il disco delle risorse o lo spazio su disco nvme per il provisioning temporaneo del disco del sistema operativo. Per altre informazioni sui requisiti delle dimensioni del disco del sistema operativo temporaneo, vedere Requisiti delle dimensioni del disco del sistema operativo temporaneo per la macchina virtuale Windows in https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements e macchina virtuale Linux all'indirizzo https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. Versione minima api per NvmeDisk: 2024-03-01.
Nome |
Tipo |
Descrizione |
CacheDisk
|
string
|
|
NvmeDisk
|
string
|
|
ResourceDisk
|
string
|
|
DiffDiskSettings
Descrive i parametri delle impostazioni temporanee del disco che possono essere specificate per il disco del sistema operativo.
Nota: Le impostazioni temporanee del disco possono essere specificate solo per il disco gestito.
Nome |
Tipo |
Descrizione |
option
|
DiffDiskOptions
|
Specifica le impostazioni temporanee del disco per il disco del sistema operativo.
|
placement
|
DiffDiskPlacement
|
Specifica il posizionamento temporaneo del disco per il disco del sistema operativo. I valori possibili sono: CacheDisk,ResourceDisk,NvmeDisk. Il comportamento predefinito è: cacheDisk se ne è configurato uno per le dimensioni della macchina virtuale in caso contrario viene usato ResourceDisk o NvmeDisk. Vedere la documentazione relativa alle dimensioni della macchina virtuale Windows in https://docs.microsoft.com/azure/virtual-machines/windows/sizes e alla macchina virtuale Linux in https://docs.microsoft.com/azure/virtual-machines/linux/sizes per verificare le dimensioni delle macchine virtuali che espongono un disco della cache. Versione minima api per NvmeDisk: 2024-03-01.
|
DiskControllerTypes
Nome |
Tipo |
Descrizione |
NVMe
|
string
|
|
SCSI
|
string
|
|
DiskCreateOptionTypes
Specifica la modalità di creazione delle macchine virtuali nel set di scalabilità. L'unico valore consentito è: FromImage. Questo valore viene usato quando si usa un'immagine per creare la macchina virtuale. Se si usa un'immagine della piattaforma, si usa anche l'elemento imageReference descritto in precedenza. Se si usa un'immagine del marketplace, si usa anche l'elemento di piano descritto in precedenza.
Nome |
Tipo |
Descrizione |
Attach
|
string
|
|
Copy
|
string
|
|
Empty
|
string
|
|
FromImage
|
string
|
|
Restore
|
string
|
|
DiskDeleteOptionTypes
Specifica se il disco del sistema operativo deve essere eliminato o scollegato dopo l'eliminazione di VMSS Flex (questa funzionalità è disponibile solo per VMSS con OrchestrationMode flessibile).
Valori possibili:
Elimina Se si usa questo valore, il disco del sistema operativo viene eliminato quando viene eliminata la macchina virtuale VmSS Flex.
Scollegare Se si usa questo valore, il disco del sistema operativo viene mantenuto dopo l'eliminazione della macchina virtuale Flex di VMSS.
Il valore predefinito è impostato su Elimina. Per un disco del sistema operativo temporaneo, il valore predefinito è impostato su Elimina. L'utente non può modificare l'opzione di eliminazione per disco del sistema operativo temporaneo.
Nome |
Tipo |
Descrizione |
Delete
|
string
|
|
Detach
|
string
|
|
DiskEncryptionSetParameters
Descrive il parametro dell'ID risorsa del set di crittografia dischi gestiti dal cliente che può essere specificato per il disco.
Nota: L'ID risorsa del set di crittografia del disco può essere specificato solo per il disco gestito. Per altri dettagli, vedere https://aka.ms/mdssewithcmkoverview.
Nome |
Tipo |
Descrizione |
id
|
string
|
ID risorsa
|
DomainNameLabelScopeTypes
Ambito dell'etichetta nome di dominio. La concatenazione dell'etichetta del nome di dominio con hash generata in base ai criteri dall'ambito dell'etichetta del nome di dominio e l'indice vm saranno le etichette dei nomi di dominio delle risorse PublicIPAddress che verranno create
Nome |
Tipo |
Descrizione |
NoReuse
|
string
|
|
ResourceGroupReuse
|
string
|
|
SubscriptionReuse
|
string
|
|
TenantReuse
|
string
|
|
EncryptionIdentity
Specifica l'identità gestita usata da ADE per ottenere il token di accesso per le operazioni dell'insieme di credenziali delle chiavi.
Nome |
Tipo |
Descrizione |
userAssignedIdentityResourceId
|
string
|
Specifica l'ID risorsa ARM di una delle identità utente associate alla macchina virtuale.
|
EventGridAndResourceGraph
Specifica le configurazioni correlate agli eventi pianificati correlate a eventGridAndResourceGraph.
Nome |
Tipo |
Descrizione |
enable
|
boolean
|
Specifica se griglia di eventi e grafico delle risorse è abilitato per le configurazioni correlate agli eventi pianificati.
|
ExtendedLocation
Tipo complesso della posizione estesa.
Nome |
Tipo |
Descrizione |
name
|
string
|
Nome della posizione estesa.
|
type
|
ExtendedLocationTypes
|
Tipo della posizione estesa.
|
ExtendedLocationTypes
Tipo della posizione estesa.
Nome |
Tipo |
Descrizione |
EdgeZone
|
string
|
|
ImageReference
Specifica le informazioni sull'immagine da usare. È possibile specificare informazioni sulle immagini della piattaforma, sulle immagini del marketplace o sulle immagini delle macchine virtuali. Questo elemento è obbligatorio quando si vuole usare un'immagine della piattaforma, un'immagine del marketplace o un'immagine di macchina virtuale, ma non viene usata in altre operazioni di creazione. NOTA: l'autore e l'offerta di riferimento delle immagini possono essere impostati solo quando si crea il set di scalabilità.
Nome |
Tipo |
Descrizione |
communityGalleryImageId
|
string
|
È stato specificato l'ID univoco dell'immagine della raccolta della community per la distribuzione di macchine virtuali. Questa operazione può essere recuperata dalla chiamata GET dell'immagine della raccolta della community.
|
exactVersion
|
string
|
Specifica in numeri decimali la versione dell'immagine della piattaforma o dell'immagine del marketplace usata per creare la macchina virtuale. Questo campo di sola lettura è diverso da 'version', solo se il valore specificato nel campo 'version' è 'latest'.
|
id
|
string
|
ID risorsa
|
offer
|
string
|
Specifica l'offerta dell'immagine della piattaforma o dell'immagine del marketplace usata per creare la macchina virtuale.
|
publisher
|
string
|
Autore dell'immagine.
|
sharedGalleryImageId
|
string
|
È stato specificato l'ID univoco dell'immagine della raccolta condivisa per la distribuzione della macchina virtuale. Questa operazione può essere recuperata dalla chiamata GET dell'immagine della raccolta condivisa.
|
sku
|
string
|
SKU dell'immagine.
|
version
|
string
|
Specifica la versione dell'immagine della piattaforma o dell'immagine del marketplace usata per creare la macchina virtuale. I formati consentiti sono Major.Minor.Build o 'latest'. Major, Minor e Build sono numeri decimali. Specificare 'latest' per usare la versione più recente di un'immagine disponibile in fase di distribuzione. Anche se si usa 'latest', l'immagine della macchina virtuale non verrà aggiornata automaticamente dopo la distribuzione anche se diventa disponibile una nuova versione. Non usare il campo 'version' per la distribuzione di immagini della raccolta, l'immagine della raccolta deve usare sempre il campo 'id' per la distribuzione, per usare la versione più recente dell'immagine della raccolta, è sufficiente impostare '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' nel campo 'id' senza input della versione.
|
InnerError
Dettagli dell'errore interno.
Nome |
Tipo |
Descrizione |
errordetail
|
string
|
Messaggio di errore interno o dump delle eccezioni.
|
exceptiontype
|
string
|
Tipo di eccezione.
|
IPVersion
Disponibile da Api-Version 2019-07-01 e versioni successive, indica se la configurazione ip specifica è IPv4 o IPv6. Il valore predefinito è IPv4. I valori possibili sono: 'IPv4' e 'IPv6'.
Nome |
Tipo |
Descrizione |
IPv4
|
string
|
|
IPv6
|
string
|
|
KeyVaultSecretReference
Descrive un riferimento al segreto dell'insieme di credenziali delle chiavi
Nome |
Tipo |
Descrizione |
secretUrl
|
string
|
URL che fa riferimento a un segreto in un insieme di credenziali delle chiavi.
|
sourceVault
|
SubResource
|
URL relativo dell'insieme di credenziali delle chiavi contenente il segreto.
|
LinuxConfiguration
Specifica le impostazioni del sistema operativo Linux nella macchina virtuale. Per un elenco delle distribuzioni Linux supportate, vedere Linux in distribuzioni Azure-Endorsed.
Nome |
Tipo |
Descrizione |
disablePasswordAuthentication
|
boolean
|
Specifica se l'autenticazione della password deve essere disabilitata.
|
enableVMAgentPlatformUpdates
|
boolean
|
Indica se gli aggiornamenti della piattaforma VMAgent sono abilitati per la macchina virtuale Linux. Il valore predefinito è false.
|
patchSettings
|
LinuxPatchSettings
|
[Funzionalità di anteprima] Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Linux.
|
provisionVMAgent
|
boolean
|
Indica se è necessario eseguire il provisioning dell'agente di macchine virtuali nella macchina virtuale. Quando questa proprietà non viene specificata nel corpo della richiesta, il comportamento predefinito consiste nell'impostarlo su true. In questo modo si garantisce che l'agente di macchine virtuali sia installato nella macchina virtuale in modo che le estensioni possano essere aggiunte alla macchina virtuale in un secondo momento.
|
ssh
|
SshConfiguration
|
Specifica la configurazione della chiave SSH per un sistema operativo Linux.
|
LinuxPatchAssessmentMode
Specifica la modalità di valutazione della patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
Nome |
Tipo |
Descrizione |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
LinuxPatchSettings
Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Linux.
Nome |
Tipo |
Descrizione |
assessmentMode
|
LinuxPatchAssessmentMode
|
Specifica la modalità di valutazione della patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
|
automaticByPlatformSettings
|
LinuxVMGuestPatchAutomaticByPlatformSettings
|
Specifica impostazioni aggiuntive per la modalità patch AutomaticByPlatform nell'applicazione di patch guest alle macchine virtuali in Linux.
|
patchMode
|
LinuxVMGuestPatchMode
|
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
ImageDefault: viene usata la configurazione di applicazione di patch predefinita della macchina virtuale.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. La proprietà provisionVMAgent deve essere true
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
Nome |
Tipo |
Descrizione |
Always
|
string
|
|
IfRequired
|
string
|
|
Never
|
string
|
|
Unknown
|
string
|
|
Specifica impostazioni aggiuntive da applicare quando la modalità patch AutomaticByPlatform è selezionata nelle impostazioni della patch linux.
Nome |
Tipo |
Descrizione |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Consente al cliente di pianificare l'applicazione di patch senza aggiornamenti accidentali
|
rebootSetting
|
LinuxVMGuestPatchAutomaticByPlatformRebootSetting
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
|
LinuxVMGuestPatchMode
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
ImageDefault: viene usata la configurazione di applicazione di patch predefinita della macchina virtuale.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. La proprietà provisionVMAgent deve essere true
Nome |
Tipo |
Descrizione |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Mode
Specifica la modalità su cui Verrà eseguito ProxyAgent se la funzionalità è abilitata. ProxyAgent inizierà a controllare o monitorare ma non a imporre il controllo di accesso sulle richieste agli endpoint host in modalità di controllo, mentre in modalità di imposizione applichererà il controllo di accesso. Il valore predefinito è Imponi modalità.
Nome |
Tipo |
Descrizione |
Audit
|
string
|
|
Enforce
|
string
|
|
NetworkApiVersion
specifica la versione dell'API Microsoft.Network usata durante la creazione di risorse di rete nelle configurazioni dell'interfaccia di rete per il set di scalabilità di macchine virtuali con modalità di orchestrazione "Flessibile"
Nome |
Tipo |
Descrizione |
2020-11-01
|
string
|
|
NetworkInterfaceAuxiliaryMode
Specifica se la modalità ausiliaria è abilitata per la risorsa interfaccia di rete.
Nome |
Tipo |
Descrizione |
AcceleratedConnections
|
string
|
|
Floating
|
string
|
|
None
|
string
|
|
NetworkInterfaceAuxiliarySku
Specifica se lo SKU ausiliario è abilitato per la risorsa interfaccia di rete.
Nome |
Tipo |
Descrizione |
A1
|
string
|
|
A2
|
string
|
|
A4
|
string
|
|
A8
|
string
|
|
None
|
string
|
|
OperatingSystemTypes
Questa proprietà consente di specificare il tipo di sistema operativo incluso nel disco se si crea una macchina virtuale da un'immagine utente o un disco rigido virtuale specializzato. I valori possibili sono: Windows,Linux.
Nome |
Tipo |
Descrizione |
Linux
|
string
|
|
Windows
|
string
|
|
OrchestrationMode
Specifica la modalità di orchestrazione per il set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
Flexible
|
string
|
|
Uniform
|
string
|
|
OSImageNotificationProfile
Nome |
Tipo |
Descrizione |
enable
|
boolean
|
Specifica se l'evento Pianificato immagine del sistema operativo è abilitato o disabilitato.
|
notBeforeTimeout
|
string
|
Tempo durante la ricreazione dell'immagine di una macchina virtuale o l'aggiornamento del sistema operativo dovrà potenzialmente approvare l'evento pianificato dell'immagine del sistema operativo prima dell'approvazione automatica dell'evento (timeout). La configurazione viene specificata in formato ISO 8601 e il valore deve essere 15 minuti (PT15M)
|
PassNames
Nome del pass. Attualmente, l'unico valore consentito è OobeSystem.
Nome |
Tipo |
Descrizione |
OobeSystem
|
string
|
|
PatchSettings
Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Windows.
Nome |
Tipo |
Descrizione |
assessmentMode
|
WindowsPatchAssessmentMode
|
Specifica la modalità di valutazione delle patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
|
automaticByPlatformSettings
|
WindowsVMGuestPatchAutomaticByPlatformSettings
|
Specifica impostazioni aggiuntive per la modalità patch AutomaticByPlatform nell'applicazione di patch guest alle macchine virtuali in Windows.
|
enableHotpatching
|
boolean
|
Consente ai clienti di applicare patch alle macchine virtuali di Azure senza richiedere un riavvio. Per enableHotpatching, 'provisionVMAgent' deve essere impostato su true e 'patchMode' deve essere impostato su 'AutomaticByPlatform'.
|
patchMode
|
WindowsVMGuestPatchMode
|
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
manuale: è possibile controllare l'applicazione di patch a una macchina virtuale. A tale scopo, applicare manualmente le patch all'interno della macchina virtuale. In questa modalità gli aggiornamenti automatici sono disabilitati; La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere false
AutomaticByOS: la macchina virtuale verrà aggiornata automaticamente dal sistema operativo. La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere true.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. Le proprietà provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devono essere true
|
Plan
Specifica informazioni sull'immagine del marketplace usata per creare la macchina virtuale. Questo elemento viene usato solo per le immagini del Marketplace. Prima di poter usare un'immagine del marketplace da un'API, è necessario abilitare l'immagine per l'uso a livello di codice. Nel portale di Azure individuare l'immagine del Marketplace che si vuole usare e quindi fare clic su Si vuole distribuire a livello di codice, Introduzione ->. Immettere le informazioni necessarie e quindi fare clic su Salva.
Nome |
Tipo |
Descrizione |
name
|
string
|
ID del piano.
|
product
|
string
|
Specifica il prodotto dell'immagine dal marketplace. Si tratta dello stesso valore di Offer nell'elemento imageReference.
|
promotionCode
|
string
|
Codice promozionale.
|
publisher
|
string
|
ID editore.
|
PriorityMixPolicy
Specifica le divisioni di destinazione per le macchine virtuali con priorità spot e regolare all'interno di un set di scalabilità con modalità di orchestrazione flessibile. Con questa proprietà, il cliente è in grado di specificare il numero di base di macchine virtuali con priorità regolare create quando l'istanza flex vmSS aumenta e la divisione tra macchine virtuali con priorità spot e regolare dopo il raggiungimento di questa destinazione di base.
Nome |
Tipo |
Descrizione |
baseRegularPriorityCount
|
integer
|
Numero di base di macchine virtuali con priorità regolare che verranno create in questo set di scalabilità man mano che aumenta il numero di istanze.
|
regularPriorityPercentageAboveBase
|
integer
|
Percentuale di istanze di macchina virtuale, dopo che è stato raggiunto il numero di priorità regolare di base, che si prevede di usare la priorità regolare.
|
ProtocolTypes
Specifica il protocollo del listener WinRM. I valori possibili sono: http,https.
Nome |
Tipo |
Descrizione |
Http
|
string
|
|
Https
|
string
|
|
ProxyAgentSettings
Specifica le impostazioni proxyAgent durante la creazione della macchina virtuale. Versione minima api: 2023-09-01.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Specifica se la funzionalità ProxyAgent deve essere abilitata nella macchina virtuale o nel set di scalabilità di macchine virtuali.
|
keyIncarnationId
|
integer
|
Aumentare il valore di questa proprietà consente all'utente di reimpostare la chiave usata per proteggere il canale di comunicazione tra guest e host.
|
mode
|
Mode
|
Specifica la modalità su cui Verrà eseguito ProxyAgent se la funzionalità è abilitata. ProxyAgent inizierà a controllare o monitorare ma non a imporre il controllo di accesso sulle richieste agli endpoint host in modalità di controllo, mentre in modalità di imposizione applichererà il controllo di accesso. Il valore predefinito è Imponi modalità.
|
PublicIPAddressSku
Descrive lo SKU dell'indirizzo IP pubblico. Può essere impostato solo con OrchestrationMode come flessibile.
PublicIPAddressSkuName
Specificare il nome dello SKU IP pubblico
Nome |
Tipo |
Descrizione |
Basic
|
string
|
|
Standard
|
string
|
|
PublicIPAddressSkuTier
Specificare il livello SKU DELL'INDIRIZZO IP pubblico
Nome |
Tipo |
Descrizione |
Global
|
string
|
|
Regional
|
string
|
|
RepairAction
Tipo di azione di ripristino (sostituzione, riavvio, ricreazione immagine) che verrà usata per ripristinare macchine virtuali non integre nel set di scalabilità. Il valore predefinito è replace.
Nome |
Tipo |
Descrizione |
Reimage
|
string
|
|
Replace
|
string
|
|
Restart
|
string
|
|
ResiliencyPolicy
Descrive un criterio di resilienza: resilientVMCreationPolicy e/o resilientVMDeletionPolicy.
Nome |
Tipo |
Descrizione |
resilientVMCreationPolicy
|
ResilientVMCreationPolicy
|
I parametri di configurazione usati durante l'esecuzione della creazione di macchine virtuali resilienti.
|
resilientVMDeletionPolicy
|
ResilientVMDeletionPolicy
|
Parametri di configurazione usati durante l'esecuzione dell'eliminazione resiliente della macchina virtuale.
|
ResilientVMCreationPolicy
I parametri di configurazione usati durante l'esecuzione della creazione di macchine virtuali resilienti.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Specifica se la creazione di macchine virtuali resilienti deve essere abilitata nel set di scalabilità di macchine virtuali. Il valore predefinito è false.
|
ResilientVMDeletionPolicy
Parametri di configurazione usati durante l'esecuzione dell'eliminazione resiliente della macchina virtuale.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Specifica se l'eliminazione resiliente della macchina virtuale deve essere abilitata nel set di scalabilità di macchine virtuali. Il valore predefinito è false.
|
ResourceIdentityType
Tipo di identità usato per il set di scalabilità di macchine virtuali. Il tipo 'SystemAssigned, UserAssigned' include sia un'identità creata in modo implicito che un set di identità assegnate dall'utente. Il tipo "Nessuno" rimuoverà tutte le identità dal set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
None
|
string
|
|
SystemAssigned
|
string
|
|
SystemAssigned, UserAssigned
|
string
|
|
UserAssigned
|
string
|
|
RollingUpgradePolicy
Parametri di configurazione usati durante l'esecuzione di un aggiornamento in sequenza.
Nome |
Tipo |
Descrizione |
enableCrossZoneUpgrade
|
boolean
|
Consentire al set di scalabilità di macchine virtuali di ignorare i limiti az durante la creazione di batch di aggiornamento. Prendere in considerazione il dominio di aggiornamento e maxBatchInstancePercent per determinare le dimensioni del batch.
|
maxBatchInstancePercent
|
integer
|
Percentuale massima delle istanze totali di macchine virtuali che verranno aggiornate contemporaneamente dall'aggiornamento in sequenza in un unico batch. Poiché si tratta di un valore massimo, le istanze non integre nei batch precedenti o futuri possono causare la diminuzione della percentuale di istanze in un batch per garantire una maggiore affidabilità. Il valore predefinito per questo parametro è 20%.
|
maxSurge
|
boolean
|
Creare nuove macchine virtuali per aggiornare il set di scalabilità anziché aggiornare le macchine virtuali esistenti. Le macchine virtuali esistenti verranno eliminate dopo la creazione delle nuove macchine virtuali per ogni batch.
|
maxUnhealthyInstancePercent
|
integer
|
Percentuale massima delle istanze totali della macchina virtuale nel set di scalabilità che possono essere contemporaneamente non integre, in seguito all'aggiornamento o rilevate in uno stato non integro dai controlli di integrità della macchina virtuale prima dell'interruzione dell'aggiornamento in sequenza. Questo vincolo verrà controllato prima di avviare qualsiasi batch. Il valore predefinito per questo parametro è 20%.
|
maxUnhealthyUpgradedInstancePercent
|
integer
|
Percentuale massima di istanze di macchina virtuale aggiornate che possono essere trovate in uno stato non integro. Questo controllo verrà eseguito dopo l'aggiornamento di ogni batch. Se questa percentuale viene mai superata, l'aggiornamento in sequenza viene interrotto. Il valore predefinito per questo parametro è 20%.
|
pauseTimeBetweenBatches
|
string
|
Tempo di attesa tra il completamento dell'aggiornamento per tutte le macchine virtuali in un batch e l'avvio del batch successivo. La durata dell'ora deve essere specificata nel formato ISO 8601. Il valore predefinito è 0 secondi (PT0S).
|
prioritizeUnhealthyInstances
|
boolean
|
Aggiornare tutte le istanze non integre in un set di scalabilità prima di qualsiasi istanza integra.
|
rollbackFailedInstancesOnPolicyBreach
|
boolean
|
Il rollback delle istanze non riuscite nel modello precedente se i criteri di aggiornamento in sequenza vengono violati.
|
ScaleInPolicy
Descrive un criterio di scalabilità orizzontale per un set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
forceDeletion
|
boolean
|
Questa proprietà consente di specificare se le macchine virtuali scelte per la rimozione devono essere forzate quando viene ridimensionato un set di scalabilità di macchine virtuali. (Funzionalità in anteprima)
|
rules
|
VirtualMachineScaleSetScaleInRules[]
|
Regole da seguire durante il ridimensionamento di un set di scalabilità di macchine virtuali.
I valori possibili sono:
Impostazione predefinita Quando viene ridimensionato un set di scalabilità di macchine virtuali, il set di scalabilità verrà prima bilanciato tra le zone se si tratta di un set di scalabilità di zona. Quindi, verrà bilanciato tra domini di errore il più possibile. All'interno di ogni dominio di errore, le macchine virtuali scelte per la rimozione saranno quelle più recenti che non sono protette dal ridimensionamento.
OldestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali meno recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali meno recenti che non sono protette per la rimozione.
NewestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali più recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali più recenti che non sono protette per la rimozione.
|
ScheduledEventsAdditionalPublishingTargets
Nome |
Tipo |
Descrizione |
eventGridAndResourceGraph
|
EventGridAndResourceGraph
|
I parametri di configurazione usati durante la creazione dell'impostazione eventGridAndResourceGraph Scheduled Event.
|
ScheduledEventsPolicy
Specifica le configurazioni correlate a Redeploy, Reboot e ScheduledEventsAdditionalPublishingTargets Scheduled Event.
Nome |
Tipo |
Descrizione |
scheduledEventsAdditionalPublishingTargets
|
ScheduledEventsAdditionalPublishingTargets
|
Parametri di configurazione usati durante la pubblicazione scheduledEventsAdditionalPublishingTargets.
|
userInitiatedReboot
|
UserInitiatedReboot
|
I parametri di configurazione usati durante la creazione di un'impostazione evento pianificata userInitiatedReboot.
|
userInitiatedRedeploy
|
UserInitiatedRedeploy
|
I parametri di configurazione usati durante la creazione dell'impostazione dell'evento pianificata userInitiatedRedeploy.
|
ScheduledEventsProfile
Nome |
Tipo |
Descrizione |
osImageNotificationProfile
|
OSImageNotificationProfile
|
Specifica le configurazioni correlate all'evento pianificato dell'immagine del sistema operativo.
|
terminateNotificationProfile
|
TerminateNotificationProfile
|
Specifica le configurazioni correlate all'evento pianificato Terminate.
|
securityEncryptionTypes
Specifica encryptionType del disco gestito. È impostato su DiskWithVMGuestState per la crittografia del disco gestito insieme al BLOB VMGuestState, VMGuestStateOnly per la crittografia solo del BLOB VMGuestState e NonPersistedTPM per non rendere persistente lo stato del firmware nel BLOB VMGuestState.
Nota: può essere impostato solo per le macchine virtuali riservate.
Nome |
Tipo |
Descrizione |
DiskWithVMGuestState
|
string
|
|
NonPersistedTPM
|
string
|
|
VMGuestStateOnly
|
string
|
|
SecurityPostureReference
Specifica il comportamento di sicurezza da usare nel set di scalabilità. Versione minima api: 2023-03-01
Nome |
Tipo |
Descrizione |
excludeExtensions
|
string[]
|
Elenco dei nomi di estensione della macchina virtuale da escludere quando si applica il comportamento di sicurezza.
|
id
|
string
|
ID riferimento al comportamento di sicurezza sotto forma di /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest
|
isOverridable
|
boolean
|
Indica se il comportamento di sicurezza può essere sottoposto a override dall'utente.
|
SecurityProfile
Specifica le impostazioni del profilo di sicurezza per la macchina virtuale o il set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
encryptionAtHost
|
boolean
|
Questa proprietà può essere usata dall'utente nella richiesta per abilitare o disabilitare la crittografia host per la macchina virtuale o il set di scalabilità di macchine virtuali. In questo modo verrà abilitata la crittografia per tutti i dischi, incluso il disco Resource/Temp nell'host stesso. Il comportamento predefinito è: la crittografia dell'host verrà disabilitata a meno che questa proprietà non sia impostata su true per la risorsa.
|
encryptionIdentity
|
EncryptionIdentity
|
Specifica l'identità gestita usata da ADE per ottenere il token di accesso per le operazioni dell'insieme di credenziali delle chiavi.
|
proxyAgentSettings
|
ProxyAgentSettings
|
Specifica le impostazioni proxyAgent durante la creazione della macchina virtuale. Versione minima api: 2023-09-01.
|
securityType
|
SecurityTypes
|
Specifica il Tipo di sicurezza della macchina virtuale. Deve essere impostato su qualsiasi valore specificato per abilitare UefiSettings. Il comportamento predefinito è: UefiSettings non verrà abilitato a meno che questa proprietà non sia impostata.
|
uefiSettings
|
UefiSettings
|
Specifica le impostazioni di sicurezza, ad esempio l'avvio protetto e vTPM usato durante la creazione della macchina virtuale. Versione minima api: 2020-12-01.
|
SecurityTypes
Specifica il Tipo di sicurezza della macchina virtuale. Deve essere impostato su qualsiasi valore specificato per abilitare UefiSettings. Il comportamento predefinito è: UefiSettings non verrà abilitato a meno che questa proprietà non sia impostata.
Nome |
Tipo |
Descrizione |
ConfidentialVM
|
string
|
|
TrustedLaunch
|
string
|
|
ServiceArtifactReference
Specifica l'ID di riferimento dell'artefatto del servizio usato per impostare la stessa versione dell'immagine per tutte le macchine virtuali nel set di scalabilità quando si usa la versione dell'immagine 'latest'. Versione minima api: 2022-11-01
Nome |
Tipo |
Descrizione |
id
|
string
|
ID riferimento dell'artefatto del servizio sotto forma di /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}
|
SettingNames
Specifica il nome dell'impostazione a cui si applica il contenuto. I valori possibili sono: FirstLogonCommands e AutoLogon.
Nome |
Tipo |
Descrizione |
AutoLogon
|
string
|
|
FirstLogonCommands
|
string
|
|
Sku
Descrive uno SKU del set di scalabilità di macchine virtuali. NOTA: se il nuovo SKU della macchina virtuale non è supportato nell'hardware in cui è attualmente attivo il set di scalabilità, è necessario deallocare le macchine virtuali nel set di scalabilità prima di modificare il nome dello SKU.
Nome |
Tipo |
Descrizione |
capacity
|
integer
|
Specifica il numero di macchine virtuali nel set di scalabilità.
|
name
|
string
|
Nome sku.
|
tier
|
string
|
Specifica il livello di macchine virtuali in un set di scalabilità.
Valori possibili:
standard
Basic
|
SkuProfile
Specifica il profilo sku per il set di scalabilità di macchine virtuali. Con questa proprietà il cliente è in grado di specificare un elenco di dimensioni delle macchine virtuali e una strategia di allocazione.
Nome |
Tipo |
Descrizione |
allocationStrategy
|
AllocationStrategy
|
Specifica la strategia di allocazione per il set di scalabilità di macchine virtuali in base alla quale verranno allocate le macchine virtuali.
|
vmSizes
|
SkuProfileVMSize[]
|
Specifica le dimensioni delle macchine virtuali per il set di scalabilità di macchine virtuali.
|
SkuProfileVMSize
Specifica le dimensioni della macchina virtuale.
Nome |
Tipo |
Descrizione |
name
|
string
|
Specifica il nome delle dimensioni della macchina virtuale.
|
SpotRestorePolicy
Specifica le proprietà spot-Try-Restore per il set di scalabilità di macchine virtuali. Con questa proprietà il cliente può abilitare o disabilitare il ripristino automatico delle istanze di macchine virtuali Spot VMSS rimosse in modo opportunistico in base alla disponibilità della capacità e al vincolo dei prezzi.
Nome |
Tipo |
Descrizione |
enabled
|
boolean
|
Abilita la funzionalità Spot-Try-Restore in cui verranno tentate le istanze SPOT di VMSS rimosse in modo opportunistico in base ai vincoli di disponibilità e prezzi della capacità
|
restoreTimeout
|
string
|
Valore di timeout espresso come durata ISO 8601 dopo la quale la piattaforma non tenterà di ripristinare le istanze SPOT di VMSS
|
SshConfiguration
Configurazione SSH per macchine virtuali basate su Linux in esecuzione in Azure
Nome |
Tipo |
Descrizione |
publicKeys
|
SshPublicKey[]
|
Elenco di chiavi pubbliche SSH usate per l'autenticazione con macchine virtuali basate su Linux.
|
SshPublicKey
Contiene informazioni sulla chiave pubblica del certificato SSH e sul percorso nella macchina virtuale Linux in cui viene inserita la chiave pubblica.
Nome |
Tipo |
Descrizione |
keyData
|
string
|
Certificato di chiave pubblica SSH usato per l'autenticazione con la macchina virtuale tramite ssh. La chiave deve essere almeno a 2048 bit e in formato ssh-rsa. Per la creazione di chiavi SSH, vedere [Creare chiavi SSH in Linux e Mac per macchine virtuali Linux in Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed).
|
path
|
string
|
Specifica il percorso completo nella macchina virtuale creata in cui è archiviata la chiave pubblica SSH. Se il file esiste già, la chiave specificata viene aggiunta al file. Esempio: /home/user/.ssh/authorized_keys
|
StorageAccountTypes
Specifica il tipo di account di archiviazione per il disco gestito. NOTA: UltraSSD_LRS può essere usato solo con dischi dati, non può essere usato con il disco del sistema operativo.
Nome |
Tipo |
Descrizione |
PremiumV2_LRS
|
string
|
|
Premium_LRS
|
string
|
|
Premium_ZRS
|
string
|
|
StandardSSD_LRS
|
string
|
|
StandardSSD_ZRS
|
string
|
|
Standard_LRS
|
string
|
|
UltraSSD_LRS
|
string
|
|
SubResource
Nome |
Tipo |
Descrizione |
id
|
string
|
ID risorsa
|
TerminateNotificationProfile
Nome |
Tipo |
Descrizione |
enable
|
boolean
|
Specifica se l'evento Terminate Scheduled è abilitato o disabilitato.
|
notBeforeTimeout
|
string
|
La durata configurabile dell'eliminazione di una macchina virtuale dovrà potenzialmente approvare l'evento pianificato terminate prima che l'evento venga approvato automaticamente (timeout). La configurazione deve essere specificata in formato ISO 8601, il valore predefinito è 5 minuti (PT5M)
|
UefiSettings
Specifica le impostazioni di sicurezza, ad esempio l'avvio protetto e vTPM usato durante la creazione della macchina virtuale. Versione minima api: 2020-12-01.
Nome |
Tipo |
Descrizione |
secureBootEnabled
|
boolean
|
Specifica se l'avvio protetto deve essere abilitato nella macchina virtuale. Versione minima api: 2020-12-01.
|
vTpmEnabled
|
boolean
|
Specifica se vTPM deve essere abilitato nella macchina virtuale. Versione minima api: 2020-12-01.
|
UpgradeMode
Specifica la modalità di un aggiornamento alle macchine virtuali nel set di scalabilità.
I valori possibili sono:
manuale: è possibile controllare l'applicazione degli aggiornamenti alle macchine virtuali nel set di scalabilità. A tale scopo, usare l'azione manualUpgrade.
automatico: tutte le macchine virtuali nel set di scalabilità vengono aggiornate automaticamente contemporaneamente.
Nome |
Tipo |
Descrizione |
Automatic
|
string
|
|
Manual
|
string
|
|
Rolling
|
string
|
|
UpgradePolicy
Descrive un criterio di aggiornamento: automatico, manuale o in sequenza.
Nome |
Tipo |
Descrizione |
automaticOSUpgradePolicy
|
AutomaticOSUpgradePolicy
|
Parametri di configurazione usati per eseguire l'aggiornamento automatico del sistema operativo.
|
mode
|
UpgradeMode
|
Specifica la modalità di un aggiornamento alle macchine virtuali nel set di scalabilità.
I valori possibili sono:
manuale: è possibile controllare l'applicazione degli aggiornamenti alle macchine virtuali nel set di scalabilità. A tale scopo, usare l'azione manualUpgrade.
automatico: tutte le macchine virtuali nel set di scalabilità vengono aggiornate automaticamente contemporaneamente.
|
rollingUpgradePolicy
|
RollingUpgradePolicy
|
Parametri di configurazione usati durante l'esecuzione di un aggiornamento in sequenza.
|
UserAssignedIdentities
Elenco di identità utente associate alla macchina virtuale. I riferimenti alla chiave del dizionario delle identità utente saranno id risorsa ARM nel formato :'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
UserInitiatedReboot
Specifica le configurazioni correlate agli eventi pianificati correlati al riavvio.
Nome |
Tipo |
Descrizione |
automaticallyApprove
|
boolean
|
Specifica le configurazioni correlate all'evento pianificato per il riavvio.
|
UserInitiatedRedeploy
Specifica le configurazioni correlate all'evento pianificato correlate alla ridistribuitura.
Nome |
Tipo |
Descrizione |
automaticallyApprove
|
boolean
|
Specifica le configurazioni correlate all'evento pianificato ridistribuire.
|
VaultCertificate
Descrive un singolo riferimento al certificato in un insieme di credenziali delle chiavi e dove risiede il certificato nella macchina virtuale.
Nome |
Tipo |
Descrizione |
certificateStore
|
string
|
Per le macchine virtuali Windows, specifica l'archivio certificati nella macchina virtuale a cui aggiungere il certificato. L'archivio certificati specificato è in modo implicito nell'account LocalMachine. Per le macchine virtuali Linux, il file di certificato viene inserito nella directory /var/lib/waagent, con il nome file <UppercaseThumbprint>.crt per il file di certificato X509 e <UppercaseThumbprint>.prv per la chiave privata. Entrambi questi file sono formattati con estensione pem.
|
certificateUrl
|
string
|
Si tratta dell'URL di un certificato caricato in Key Vault come segreto. Per aggiungere un segreto all'insieme di credenziali delle chiavi, vedere Aggiungere una chiave o un segreto all'insieme di credenziali delle chiavi. In questo caso, il certificato deve essere La codifica Base64 dell'oggetto JSON seguente codificato in UTF-8:
{ "data":"", "dataType":"pfx", "password":"" } Per installare i certificati in una macchina virtuale, è consigliabile usare l'estensione macchina virtuale di Azure Key Vault per Linux o l'estensione macchina virtuale di Azure Key Vault per Windows.
|
VaultSecretGroup
Descrive un set di certificati che si trovano tutti nello stesso insieme di credenziali delle chiavi.
Nome |
Tipo |
Descrizione |
sourceVault
|
SubResource
|
URL relativo dell'insieme di credenziali delle chiavi contenente tutti i certificati in VaultCertificates.
|
vaultCertificates
|
VaultCertificate[]
|
Elenco di riferimenti all'insieme di credenziali delle chiavi in SourceVault che contengono certificati.
|
VirtualHardDisk
Descrive l'URI di un disco.
Nome |
Tipo |
Descrizione |
uri
|
string
|
Specifica l'URI del disco rigido virtuale.
|
VirtualMachineEvictionPolicyTypes
Specifica i criteri di rimozione per la macchina virtuale Spot di Azure e il set di scalabilità spot di Azure. Per le macchine virtuali Spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2019-03-01. Per i set di scalabilità spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2017-10-30-preview.
Nome |
Tipo |
Descrizione |
Deallocate
|
string
|
|
Delete
|
string
|
|
VirtualMachinePriorityTypes
Specifica la priorità per le macchine virtuali nel set di scalabilità. Versione minima api: 2017-10-30-preview.
Nome |
Tipo |
Descrizione |
Low
|
string
|
|
Regular
|
string
|
|
Spot
|
string
|
|
VirtualMachineScaleSet
Descrive un set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
etag
|
string
|
Etag è la proprietà restituita nella risposta Create/Update/Get del set di scalabilità di macchine virtuali, in modo che il cliente possa fornirlo nell'intestazione per garantire gli aggiornamenti ottimistici
|
extendedLocation
|
ExtendedLocation
|
Posizione estesa del set di scalabilità di macchine virtuali.
|
id
|
string
|
ID risorsa
|
identity
|
VirtualMachineScaleSetIdentity
|
Identità del set di scalabilità di macchine virtuali, se configurata.
|
location
|
string
|
Percorso risorsa
|
name
|
string
|
Nome risorsa
|
plan
|
Plan
|
Specifica informazioni sull'immagine del marketplace usata per creare la macchina virtuale. Questo elemento viene usato solo per le immagini del Marketplace. Prima di poter usare un'immagine del marketplace da un'API, è necessario abilitare l'immagine per l'uso a livello di codice. Nel portale di Azure individuare l'immagine del Marketplace che si vuole usare e quindi fare clic su Si vuole distribuire a livello di codice, Introduzione ->. Immettere le informazioni necessarie e quindi fare clic su Salva.
|
properties.additionalCapabilities
|
AdditionalCapabilities
|
Specifica funzionalità aggiuntive abilitate o disabilitate nelle macchine virtuali nel set di scalabilità di macchine virtuali. Ad esempio, se le macchine virtuali hanno la possibilità di supportare il collegamento di dischi dati gestiti con UltraSSD_LRS tipo di account di archiviazione.
|
properties.automaticRepairsPolicy
|
AutomaticRepairsPolicy
|
Criteri per le riparazioni automatiche.
|
properties.constrainedMaximumCapacity
|
boolean
|
Proprietà facoltativa che deve essere impostata su True o omessa.
|
properties.doNotRunExtensionsOnOverprovisionedVMs
|
boolean
|
Quando l'overprovision è abilitato, le estensioni vengono avviate solo sul numero richiesto di macchine virtuali che vengono infine mantenute. Questa proprietà garantisce quindi che le estensioni non vengano eseguite nelle macchine virtuali con provisioning eccessivo aggiuntivo.
|
properties.hostGroup
|
SubResource
|
Specifica informazioni sul gruppo host dedicato in cui risiede il set di scalabilità di macchine virtuali. Versione minima api: 2020-06-01.
|
properties.orchestrationMode
|
OrchestrationMode
|
Specifica la modalità di orchestrazione per il set di scalabilità di macchine virtuali.
|
properties.overprovision
|
boolean
|
Specifica se il set di scalabilità di macchine virtuali deve essere sottoposto a provisioning eccessivo.
|
properties.platformFaultDomainCount
|
integer
|
Numero di domini di errore per ogni gruppo di posizionamento.
|
properties.priorityMixPolicy
|
PriorityMixPolicy
|
Specifica le destinazioni desiderate per combinare macchine virtuali con priorità spot e regolare all'interno della stessa istanza di VMSS Flex.
|
properties.provisioningState
|
string
|
Stato di provisioning, visualizzato solo nella risposta.
|
properties.proximityPlacementGroup
|
SubResource
|
Specifica informazioni sul gruppo di posizionamento di prossimità a cui deve essere assegnato il set di scalabilità di macchine virtuali. Versione minima api: 2018-04-01.
|
properties.resiliencyPolicy
|
ResiliencyPolicy
|
Criteri per la resilienza
|
properties.scaleInPolicy
|
ScaleInPolicy
|
Specifica i criteri applicati durante il ridimensionamento nelle macchine virtuali nel set di scalabilità di macchine virtuali.
|
properties.scheduledEventsPolicy
|
ScheduledEventsPolicy
|
The ScheduledEventsPolicy.
|
properties.singlePlacementGroup
|
boolean
|
Se true, questo limita il set di scalabilità a un singolo gruppo di posizionamento, con dimensioni massime di 100 macchine virtuali. NOTA: se singlePlacementGroup è true, può essere modificato in false. Tuttavia, se singlePlacementGroup è false, potrebbe non essere modificato in true.
|
properties.skuProfile
|
SkuProfile
|
Specifica il profilo sku per il set di scalabilità di macchine virtuali.
|
properties.spotRestorePolicy
|
SpotRestorePolicy
|
Specifica le proprietà di ripristino spot per il set di scalabilità di macchine virtuali.
|
properties.timeCreated
|
string
|
Specifica l'ora di creazione della risorsa del set di scalabilità di macchine virtuali. Versione minima api: 2021-11-01.
|
properties.uniqueId
|
string
|
Specifica l'ID che identifica in modo univoco un set di scalabilità di macchine virtuali.
|
properties.upgradePolicy
|
UpgradePolicy
|
Criteri di aggiornamento.
|
properties.virtualMachineProfile
|
VirtualMachineScaleSetVMProfile
|
Profilo della macchina virtuale.
|
properties.zonalPlatformFaultDomainAlignMode
|
ZonalPlatformFaultDomainAlignMode
|
Specifica la modalità di allineamento tra il calcolo del set di scalabilità di macchine virtuali e il numero di domini di errore di archiviazione.
|
properties.zoneBalance
|
boolean
|
Se forzare rigorosamente anche la distribuzione di macchine virtuali tra zone x in caso di interruzione della zona. La proprietà zoneBalance può essere impostata solo se la proprietà zone del set di scalabilità contiene più di una zona. Se non sono specificate zone o una sola zona, la proprietà zoneBalance non deve essere impostata.
|
sku
|
Sku
|
SKU del set di scalabilità di macchine virtuali.
|
tags
|
object
|
Tag delle risorse
|
type
|
string
|
Tipo di risorsa
|
zones
|
string[]
|
Zone del set di scalabilità di macchine virtuali.
|
VirtualMachineScaleSetDataDisk
Descrive un disco dati del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
caching
|
CachingTypes
|
Specifica i requisiti di memorizzazione nella cache. I valori possibili sono: None,ReadOnly,ReadWrite. I valori predefiniti sono: Nessuno per l'archiviazione Standard. ReadOnly per l'archiviazione Premium.
|
createOption
|
DiskCreateOptionTypes
|
Opzione di creazione.
|
deleteOption
|
DiskDeleteOptionTypes
|
Specifica se il disco dati deve essere eliminato o scollegato dopo l'eliminazione di VMSS Flex (questa funzionalità è disponibile solo per VMSS con Flexible OrchestrationMode).
Valori possibili:
Elimina Se si usa questo valore, il disco dati viene eliminato quando viene eliminata la macchina virtuale VMSS Flex.
Scollegare Se si usa questo valore, il disco dati viene mantenuto dopo l'eliminazione della macchina virtuale VMSS Flex.
Il valore predefinito è impostato su Elimina.
|
diskIOPSReadWrite
|
integer
|
Specifica il Read-Write operazioni di I/O al secondo per il disco gestito. Deve essere usato solo quando StorageAccountType è UltraSSD_LRS. Se non specificato, viene assegnato un valore predefinito in base a diskSizeGB.
|
diskMBpsReadWrite
|
integer
|
Specifica la larghezza di banda in MB al secondo per il disco gestito. Deve essere usato solo quando StorageAccountType è UltraSSD_LRS. Se non specificato, viene assegnato un valore predefinito in base a diskSizeGB.
|
diskSizeGB
|
integer
|
Specifica le dimensioni di un disco dati vuoto in gigabyte. Questo elemento può essere usato per sovrascrivere le dimensioni del disco in un'immagine di macchina virtuale. La proprietà diskSizeGB è il numero di byte x 1024^3 per il disco e il valore non può essere maggiore di 1023.
|
lun
|
integer
|
Specifica il numero di unità logica del disco dati. Questo valore viene usato per identificare i dischi dati all'interno della macchina virtuale e pertanto deve essere univoco per ogni disco dati collegato a una macchina virtuale.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Parametri del disco gestito.
|
name
|
string
|
Nome del disco.
|
writeAcceleratorEnabled
|
boolean
|
Specifica se writeAccelerator deve essere abilitato o disabilitato sul disco.
|
VirtualMachineScaleSetExtension
Descrive un'estensione del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
id
|
string
|
ID risorsa
|
name
|
string
|
Nome dell'estensione.
|
properties.autoUpgradeMinorVersion
|
boolean
|
Indica se l'estensione deve usare una versione secondaria più recente, se disponibile in fase di distribuzione. Dopo la distribuzione, tuttavia, l'estensione non aggiornerà le versioni secondarie a meno che non venga ridistribuibile, anche con questa proprietà impostata su true.
|
properties.enableAutomaticUpgrade
|
boolean
|
Indica se l'estensione deve essere aggiornata automaticamente dalla piattaforma se è disponibile una versione più recente dell'estensione.
|
properties.forceUpdateTag
|
string
|
Se viene specificato un valore ed è diverso dal valore precedente, il gestore dell'estensione verrà forzato ad aggiornare anche se la configurazione dell'estensione non è stata modificata.
|
properties.protectedSettings
|
object
|
L'estensione può contenere protectedSettings o protectedSettingsFromKeyVault o nessuna impostazione protetta.
|
properties.protectedSettingsFromKeyVault
|
KeyVaultSecretReference
|
Impostazioni protette delle estensioni passate per riferimento e utilizzate dall'insieme di credenziali delle chiavi
|
properties.provisionAfterExtensions
|
string[]
|
Raccolta di nomi di estensione dopo i quali è necessario effettuare il provisioning di questa estensione.
|
properties.provisioningState
|
string
|
Stato di provisioning, visualizzato solo nella risposta.
|
properties.publisher
|
string
|
Nome del server di pubblicazione del gestore dell'estensione.
|
properties.settings
|
object
|
Impostazioni pubbliche in formato JSON per l'estensione.
|
properties.suppressFailures
|
boolean
|
Indica se gli errori derivanti dall'estensione verranno eliminati (gli errori operativi, ad esempio la mancata connessione alla macchina virtuale, non verranno eliminati indipendentemente da questo valore). Il valore predefinito è false.
|
properties.type
|
string
|
Specifica il tipo di estensione; un esempio è "CustomScriptExtension".
|
properties.typeHandlerVersion
|
string
|
Specifica la versione del gestore di script.
|
type
|
string
|
Tipo di risorsa
|
VirtualMachineScaleSetExtensionProfile
Descrive un profilo di estensione del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
extensions
|
VirtualMachineScaleSetExtension[]
|
Risorse dell'estensione figlio del set di scalabilità di macchine virtuali.
|
extensionsTimeBudget
|
string
|
Specifica il tempo assegnato per l'avvio di tutte le estensioni. La durata deve essere compresa tra 15 minuti e 120 minuti (inclusi) e deve essere specificata in formato ISO 8601. Il valore predefinito è 90 minuti (PT1H30M). Versione minima api: 2020-06-01.
|
VirtualMachineScaleSetHardwareProfile
Specifica le impostazioni hardware per il set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
vmSizeProperties
|
VMSizeProperties
|
Specifica le proprietà per la personalizzazione delle dimensioni della macchina virtuale. Versione minima api: 2021-11-01. Per altri dettagli, seguire le istruzioni riportate in di personalizzazione della macchina virtuale.
|
VirtualMachineScaleSetIdentity
Identità per il set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
principalId
|
string
|
ID principale dell'identità del set di scalabilità di macchine virtuali. Questa proprietà verrà fornita solo per un'identità assegnata dal sistema.
|
tenantId
|
string
|
ID tenant associato al set di scalabilità di macchine virtuali. Questa proprietà verrà fornita solo per un'identità assegnata dal sistema.
|
type
|
ResourceIdentityType
|
Tipo di identità usato per il set di scalabilità di macchine virtuali. Il tipo 'SystemAssigned, UserAssigned' include sia un'identità creata in modo implicito che un set di identità assegnate dall'utente. Il tipo "Nessuno" rimuoverà tutte le identità dal set di scalabilità di macchine virtuali.
|
userAssignedIdentities
|
UserAssignedIdentities
|
Elenco delle identità utente associate al set di scalabilità di macchine virtuali. I riferimenti alla chiave del dizionario delle identità utente saranno id risorsa ARM nel formato :'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
VirtualMachineScaleSetIPConfiguration
Descrive la configurazione IP di un profilo di rete del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
name
|
string
|
Nome della configurazione IP.
|
properties.applicationGatewayBackendAddressPools
|
SubResource[]
|
Specifica una matrice di riferimenti ai pool di indirizzi back-end dei gateway applicazione. Un set di scalabilità può fare riferimento a pool di indirizzi back-end di più gateway applicazione. Più set di scalabilità non possono usare lo stesso gateway applicazione.
|
properties.applicationSecurityGroups
|
SubResource[]
|
Specifica una matrice di riferimenti al gruppo di sicurezza delle applicazioni.
|
properties.loadBalancerBackendAddressPools
|
SubResource[]
|
Specifica una matrice di riferimenti ai pool di indirizzi back-end dei servizi di bilanciamento del carico. Un set di scalabilità può fare riferimento a pool di indirizzi back-end di un servizio di bilanciamento del carico pubblico e interno. Più set di scalabilità non possono usare lo stesso servizio di bilanciamento del carico sku basic.
|
properties.loadBalancerInboundNatPools
|
SubResource[]
|
Specifica una matrice di riferimenti ai pool Nat in ingresso dei servizi di bilanciamento del carico. Un set di scalabilità può fare riferimento a pool NAT in ingresso di un pool pubblico e di un servizio di bilanciamento del carico interno. Più set di scalabilità non possono usare lo stesso servizio di bilanciamento del carico sku basic.
|
properties.primary
|
boolean
|
Specifica l'interfaccia di rete primaria nel caso in cui la macchina virtuale abbia più di 1 interfaccia di rete.
|
properties.privateIPAddressVersion
|
IPVersion
|
Disponibile da Api-Version 2017-03-30 e versioni successive, indica se la specifica ipconfiguration è IPv4 o IPv6. Il valore predefinito è IPv4. I valori possibili sono: 'IPv4' e 'IPv6'.
|
properties.publicIPAddressConfiguration
|
VirtualMachineScaleSetPublicIPAddressConfiguration
|
PublicIPAddressConfiguration.
|
properties.subnet
|
ApiEntityReference
|
Specifica l'identificatore della subnet.
|
VirtualMachineScaleSetIpTag
Contiene il tag IP associato all'indirizzo IP pubblico.
Nome |
Tipo |
Descrizione |
ipTagType
|
string
|
Tipo di tag IP. Esempio: FirstPartyUsage.
|
tag
|
string
|
Tag IP associato all'indirizzo IP pubblico. Esempio: SQL, Archiviazione e così via.
|
VirtualMachineScaleSetManagedDiskParameters
Descrive i parametri di un disco gestito scaleset.
Nome |
Tipo |
Descrizione |
diskEncryptionSet
|
DiskEncryptionSetParameters
|
Specifica l'ID risorsa del set di crittografia dischi gestiti dal cliente per il disco gestito.
|
securityProfile
|
VMDiskSecurityProfile
|
Specifica il profilo di sicurezza per il disco gestito.
|
storageAccountType
|
StorageAccountTypes
|
Specifica il tipo di account di archiviazione per il disco gestito. NOTA: UltraSSD_LRS può essere usato solo con dischi dati, non può essere usato con il disco del sistema operativo.
|
VirtualMachineScaleSetNetworkConfiguration
Descrive le configurazioni di rete del profilo di rete di un set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
name
|
string
|
Nome della configurazione di rete.
|
properties.auxiliaryMode
|
NetworkInterfaceAuxiliaryMode
|
Specifica se la modalità ausiliaria è abilitata per la risorsa interfaccia di rete.
|
properties.auxiliarySku
|
NetworkInterfaceAuxiliarySku
|
Specifica se lo SKU ausiliario è abilitato per la risorsa interfaccia di rete.
|
properties.deleteOption
|
DeleteOptions
|
Specificare cosa accade all'interfaccia di rete quando la macchina virtuale viene eliminata
|
properties.disableTcpStateTracking
|
boolean
|
Specifica se l'interfaccia di rete è disabilitata per il rilevamento dello stato TCP.
|
properties.dnsSettings
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
|
Impostazioni DNS da applicare alle interfacce di rete.
|
properties.enableAcceleratedNetworking
|
boolean
|
Specifica se l'interfaccia di rete è abilitata per la rete accelerata.
|
properties.enableFpga
|
boolean
|
Specifica se l'interfaccia di rete è abilitata per la rete FPGA.
|
properties.enableIPForwarding
|
boolean
|
Indica se l'inoltro IP è abilitato in questa scheda di interfaccia di rete.
|
properties.ipConfigurations
|
VirtualMachineScaleSetIPConfiguration[]
|
Specifica le configurazioni IP dell'interfaccia di rete.
|
properties.networkSecurityGroup
|
SubResource
|
Gruppo di sicurezza di rete.
|
properties.primary
|
boolean
|
Specifica l'interfaccia di rete primaria nel caso in cui la macchina virtuale abbia più di 1 interfaccia di rete.
|
VirtualMachineScaleSetNetworkConfigurationDnsSettings
Descrive le impostazioni DNS di una configurazione DNS dei set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
dnsServers
|
string[]
|
Elenco di indirizzi IP dei server DNS
|
VirtualMachineScaleSetNetworkProfile
Descrive un profilo di rete del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
healthProbe
|
ApiEntityReference
|
Riferimento a un probe del servizio di bilanciamento del carico usato per determinare l'integrità di un'istanza nel set di scalabilità di macchine virtuali. Il riferimento sarà nel formato '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'.
|
networkApiVersion
|
NetworkApiVersion
|
specifica la versione dell'API Microsoft.Network usata durante la creazione di risorse di rete nelle configurazioni dell'interfaccia di rete per il set di scalabilità di macchine virtuali con modalità di orchestrazione "Flessibile"
|
networkInterfaceConfigurations
|
VirtualMachineScaleSetNetworkConfiguration[]
|
Elenco delle configurazioni di rete.
|
VirtualMachineScaleSetOSDisk
Descrive un disco del sistema operativo del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
caching
|
CachingTypes
|
Specifica i requisiti di memorizzazione nella cache. I valori possibili sono: None,ReadOnly,ReadWrite. I valori predefiniti sono: Nessuno per l'archiviazione Standard. ReadOnly per l'archiviazione Premium.
|
createOption
|
DiskCreateOptionTypes
|
Specifica la modalità di creazione delle macchine virtuali nel set di scalabilità. L'unico valore consentito è: FromImage. Questo valore viene usato quando si usa un'immagine per creare la macchina virtuale. Se si usa un'immagine della piattaforma, si usa anche l'elemento imageReference descritto in precedenza. Se si usa un'immagine del marketplace, si usa anche l'elemento di piano descritto in precedenza.
|
deleteOption
|
DiskDeleteOptionTypes
|
Specifica se il disco del sistema operativo deve essere eliminato o scollegato dopo l'eliminazione di VMSS Flex (questa funzionalità è disponibile solo per VMSS con OrchestrationMode flessibile).
Valori possibili:
Elimina Se si usa questo valore, il disco del sistema operativo viene eliminato quando viene eliminata la macchina virtuale VmSS Flex.
Scollegare Se si usa questo valore, il disco del sistema operativo viene mantenuto dopo l'eliminazione della macchina virtuale Flex di VMSS.
Il valore predefinito è impostato su Elimina. Per un disco del sistema operativo temporaneo, il valore predefinito è impostato su Elimina. L'utente non può modificare l'opzione di eliminazione per disco del sistema operativo temporaneo.
|
diffDiskSettings
|
DiffDiskSettings
|
Specifica le impostazioni temporanee del disco per il disco del sistema operativo usato dal set di scalabilità di macchine virtuali.
|
diskSizeGB
|
integer
|
Specifica le dimensioni di un disco dati vuoto in gigabyte. Questo elemento può essere usato per sovrascrivere le dimensioni del disco in un'immagine di macchina virtuale. La proprietà 'diskSizeGB' è il numero di byte x 1024^3 per il disco e il valore non può essere maggiore di 1023.
|
image
|
VirtualHardDisk
|
Specifica informazioni sull'immagine utente non gestita su cui basare il set di scalabilità.
|
managedDisk
|
VirtualMachineScaleSetManagedDiskParameters
|
Parametri del disco gestito.
|
name
|
string
|
Nome del disco.
|
osType
|
OperatingSystemTypes
|
Questa proprietà consente di specificare il tipo di sistema operativo incluso nel disco se si crea una macchina virtuale da un'immagine utente o un disco rigido virtuale specializzato. I valori possibili sono: Windows,Linux.
|
vhdContainers
|
string[]
|
Specifica gli URL del contenitore usati per archiviare i dischi del sistema operativo per il set di scalabilità.
|
writeAcceleratorEnabled
|
boolean
|
Specifica se writeAccelerator deve essere abilitato o disabilitato sul disco.
|
VirtualMachineScaleSetOSProfile
Descrive un profilo del sistema operativo del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
adminPassword
|
string
|
Specifica la password dell'account amministratore.
Lunghezza minima (Windows): 8 caratteri
Lunghezza minima (Linux): 6 caratteri
Lunghezza massima (Windows): 123 caratteri
Lunghezza massima (Linux): 72 caratteri
requisiti di complessità: è necessario soddisfare 3 su 4 condizioni seguenti Ha caratteri inferiori Ha caratteri superiori Ha una cifra Ha un carattere speciale (corrispondenza regex [\W_])
Valori non consentiti: "abc@123", "P@$$w 0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
Per reimpostare la password, vedere Come reimpostare il servizio Desktop remoto o la relativa password di accesso in una macchina virtuale Windows
Per reimpostare la password radice, vedere Gestire utenti, SSH e controllare o ripristinare i dischi in macchine virtuali Linux di Azure usando l'estensione VMAccess
|
adminUsername
|
string
|
Specifica il nome dell'account amministratore.
restrizione solo Windows: Non è possibile terminare in "."
Valori non consentiti: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm, "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5".
lunghezza minima (Linux): 1 carattere
Lunghezza massima (Linux): 64 caratteri
Lunghezza massima (Windows): 20 caratteri
|
allowExtensionOperations
|
boolean
|
Specifica se le operazioni di estensione devono essere consentite nel set di scalabilità di macchine virtuali. Questa impostazione può essere impostata su False solo quando non sono presenti estensioni nel set di scalabilità di macchine virtuali.
|
computerNamePrefix
|
string
|
Specifica il prefisso del nome computer per tutte le macchine virtuali nel set di scalabilità. I prefissi dei nomi computer devono essere lunghi da 1 a 15 caratteri.
|
customData
|
string
|
Specifica una stringa con codifica base 64 di dati personalizzati. La stringa con codifica base 64 viene decodificata in una matrice binaria salvata come file nella macchina virtuale. La lunghezza massima della matrice binaria è di 65535 byte. Per l'uso di cloud-init per la macchina virtuale, vedere Uso di cloud-init per personalizzare una macchina virtuale Linux durante la creazione
|
linuxConfiguration
|
LinuxConfiguration
|
Specifica le impostazioni del sistema operativo Linux nella macchina virtuale. Per un elenco delle distribuzioni Linux supportate, vedere Linux in distribuzioni Azure-Endorsed.
|
requireGuestProvisionSignal
|
boolean
|
Proprietà facoltativa che deve essere impostata su True o omessa.
|
secrets
|
VaultSecretGroup[]
|
Specifica il set di certificati che devono essere installati nelle macchine virtuali nel set di scalabilità. Per installare i certificati in una macchina virtuale, è consigliabile usare l'estensione macchina virtuale di Azure Key Vault per Linux o l'estensione macchina virtuale di Azure Key Vault per Windows.
|
windowsConfiguration
|
WindowsConfiguration
|
Specifica le impostazioni del sistema operativo Windows nella macchina virtuale.
|
VirtualMachineScaleSetPublicIPAddressConfiguration
Descrive la configurazione publicIPAddress di un set di scalabilità di macchine virtuali
Nome |
Tipo |
Descrizione |
name
|
string
|
Nome di configurazione dell'indirizzo publicIP.
|
properties.deleteOption
|
DeleteOptions
|
Specificare cosa accade all'indirizzo IP pubblico quando la macchina virtuale viene eliminata
|
properties.dnsSettings
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
|
Impostazioni DNS da applicare agli indirizzi publicIP.
|
properties.idleTimeoutInMinutes
|
integer
|
Timeout di inattività dell'indirizzo IP pubblico.
|
properties.ipTags
|
VirtualMachineScaleSetIpTag[]
|
Elenco di tag IP associati all'indirizzo IP pubblico.
|
properties.publicIPAddressVersion
|
IPVersion
|
Disponibile da Api-Version 2019-07-01 e versioni successive, indica se la configurazione ip specifica è IPv4 o IPv6. Il valore predefinito è IPv4. I valori possibili sono: 'IPv4' e 'IPv6'.
|
properties.publicIPPrefix
|
SubResource
|
PublicIPPrefix da cui allocare indirizzi publicIP.
|
sku
|
PublicIPAddressSku
|
Descrive lo SKU dell'indirizzo IP pubblico. Può essere impostato solo con OrchestrationMode come flessibile.
|
VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings
Descrive le impostazioni DNS di una configurazione DNS dei set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
domainNameLabel
|
string
|
Etichetta Nome di dominio. La concatenazione dell'etichetta del nome di dominio e dell'indice vm sarà costituita dalle etichette dei nomi di dominio delle risorse PublicIPAddress che verranno create
|
domainNameLabelScope
|
DomainNameLabelScopeTypes
|
Ambito dell'etichetta nome di dominio. La concatenazione dell'etichetta del nome di dominio con hash generata in base ai criteri dall'ambito dell'etichetta del nome di dominio e l'indice vm saranno le etichette dei nomi di dominio delle risorse PublicIPAddress che verranno create
|
VirtualMachineScaleSetScaleInRules
Regole da seguire durante il ridimensionamento di un set di scalabilità di macchine virtuali.
I valori possibili sono:
Impostazione predefinita Quando viene ridimensionato un set di scalabilità di macchine virtuali, il set di scalabilità verrà prima bilanciato tra le zone se si tratta di un set di scalabilità di zona. Quindi, verrà bilanciato tra domini di errore il più possibile. All'interno di ogni dominio di errore, le macchine virtuali scelte per la rimozione saranno quelle più recenti che non sono protette dal ridimensionamento.
OldestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali meno recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali meno recenti che non sono protette per la rimozione.
NewestVM Quando viene ridimensionato un set di scalabilità di macchine virtuali, verranno scelte le macchine virtuali più recenti non protette dal ridimensionamento per la rimozione. Per i set di scalabilità di macchine virtuali di zona, il set di scalabilità verrà prima bilanciato tra le zone. All'interno di ogni zona, verranno scelte le macchine virtuali più recenti che non sono protette per la rimozione.
Nome |
Tipo |
Descrizione |
Default
|
string
|
|
NewestVM
|
string
|
|
OldestVM
|
string
|
|
VirtualMachineScaleSetStorageProfile
Descrive un profilo di archiviazione del set di scalabilità di macchine virtuali.
VirtualMachineScaleSetVMProfile
Descrive un profilo di macchina virtuale del set di scalabilità di macchine virtuali.
Nome |
Tipo |
Descrizione |
applicationProfile
|
ApplicationProfile
|
Specifica le applicazioni della raccolta che devono essere rese disponibili per la macchina virtuale/set di scalabilità di macchine virtuali
|
billingProfile
|
BillingProfile
|
Specifica i dettagli relativi alla fatturazione di un set di scalabilità di macchine virtuali spot di Azure. Versione minima api: 2019-03-01.
|
capacityReservation
|
CapacityReservationProfile
|
Specifica i dettagli correlati alla prenotazione della capacità di un set di scalabilità. Versione minima api: 2021-04-01.
|
diagnosticsProfile
|
DiagnosticsProfile
|
Specifica lo stato delle impostazioni di diagnostica di avvio. Versione minima api: 2015-06-15.
|
evictionPolicy
|
VirtualMachineEvictionPolicyTypes
|
Specifica i criteri di rimozione per la macchina virtuale Spot di Azure e il set di scalabilità spot di Azure. Per le macchine virtuali Spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2019-03-01. Per i set di scalabilità spot di Azure, sono supportati sia 'Deallocate' che 'Delete' e la versione minima api-version è 2017-10-30-preview.
|
extensionProfile
|
VirtualMachineScaleSetExtensionProfile
|
Specifica una raccolta di impostazioni per le estensioni installate nelle macchine virtuali nel set di scalabilità.
|
hardwareProfile
|
VirtualMachineScaleSetHardwareProfile
|
Specifica i dettagli correlati al profilo hardware di un set di scalabilità. Versione minima api: 2021-11-01.
|
licenseType
|
string
|
Specifica che l'immagine o il disco usato è stato concesso in licenza in locale.
I valori possibili per il sistema operativo Windows Server sono:
Windows_Client
Windows_Server
I valori possibili per il sistema operativo Linux Server sono:
RHEL_BYOS (per RHEL)
SLES_BYOS (per SUSE)
Per altre informazioni, vedere Vantaggio Azure Hybrid Use per Windows Server
Vantaggio Azure Hybrid Use per Linux Server
Versione minima api: 2015-06-15
|
networkProfile
|
VirtualMachineScaleSetNetworkProfile
|
Specifica le proprietà delle interfacce di rete delle macchine virtuali nel set di scalabilità.
|
osProfile
|
VirtualMachineScaleSetOSProfile
|
Specifica le impostazioni del sistema operativo per le macchine virtuali nel set di scalabilità.
|
priority
|
VirtualMachinePriorityTypes
|
Specifica la priorità per le macchine virtuali nel set di scalabilità. Versione minima api: 2017-10-30-preview.
|
scheduledEventsProfile
|
ScheduledEventsProfile
|
Specifica le configurazioni correlate agli eventi pianificati.
|
securityPostureReference
|
SecurityPostureReference
|
Specifica il comportamento di sicurezza da usare nel set di scalabilità. Versione minima api: 2023-03-01
|
securityProfile
|
SecurityProfile
|
Specifica le impostazioni del profilo correlato alla sicurezza per le macchine virtuali nel set di scalabilità.
|
serviceArtifactReference
|
ServiceArtifactReference
|
Specifica l'ID di riferimento dell'artefatto del servizio usato per impostare la stessa versione dell'immagine per tutte le macchine virtuali nel set di scalabilità quando si usa la versione dell'immagine 'latest'. Versione minima api: 2022-11-01
|
storageProfile
|
VirtualMachineScaleSetStorageProfile
|
Specifica le impostazioni di archiviazione per i dischi delle macchine virtuali.
|
timeCreated
|
string
|
Specifica l'ora di creazione del profilo di macchina virtuale per il set di scalabilità di macchine virtuali. Questo valore verrà aggiunto ai tag VMSS Flex durante la creazione o l'aggiornamento del profilo di macchina virtuale VMSS. La versione minima dell'API per questa proprietà è 2023-09-01.
|
userData
|
string
|
UserData per le macchine virtuali nel set di scalabilità, che deve essere codificato in base 64. Il cliente non deve passare segreti qui. Versione minima api: 2021-03-01.
|
VMDiskSecurityProfile
Specifica le impostazioni del profilo di sicurezza per il disco gestito.
Nota: può essere impostato solo per le macchine virtuali riservate.
Nome |
Tipo |
Descrizione |
diskEncryptionSet
|
DiskEncryptionSetParameters
|
Specifica l'ID risorsa del set di crittografia dischi gestiti dal cliente per il disco gestito usato per il disco del sistema operativo ConfidentialVM crittografato con chiave gestita dal cliente e il BLOB VMGuest.
|
securityEncryptionType
|
securityEncryptionTypes
|
Specifica encryptionType del disco gestito. È impostato su DiskWithVMGuestState per la crittografia del disco gestito insieme al BLOB VMGuestState, VMGuestStateOnly per la crittografia solo del BLOB VMGuestState e NonPersistedTPM per non rendere persistente lo stato del firmware nel BLOB VMGuestState.
Nota: può essere impostato solo per le macchine virtuali riservate.
|
VMGalleryApplication
Specifica le informazioni necessarie per fare riferimento a una versione dell'applicazione della raccolta di calcolo
Nome |
Tipo |
Descrizione |
configurationReference
|
string
|
Facoltativo, specifica l'URI di un BLOB di Azure che sostituirà la configurazione predefinita per il pacchetto, se specificato
|
enableAutomaticUpgrade
|
boolean
|
Se impostato su true, quando è disponibile una nuova versione dell'applicazione della raccolta in PIR/SIG, verrà aggiornata automaticamente per la macchina virtuale/set di scalabilità di macchine virtuali
|
order
|
integer
|
Facoltativo, specifica l'ordine in cui devono essere installati i pacchetti
|
packageReferenceId
|
string
|
Specifica l'ID risorsa GalleryApplicationVersion nel formato /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}
|
tags
|
string
|
Facoltativo, specifica un valore pass-through per un contesto più generico.
|
treatFailureAsDeploymentFailure
|
boolean
|
Facoltativo, se true, eventuali errori per qualsiasi operazione in VmApplication avranno esito negativo nella distribuzione
|
VMSizeProperties
Specifica le impostazioni delle proprietà dimensioni macchina virtuale nella macchina virtuale.
Nome |
Tipo |
Descrizione |
vCPUsAvailable
|
integer
|
Specifica il numero di vCPU disponibili per la macchina virtuale. Quando questa proprietà non viene specificata nel corpo della richiesta, il comportamento predefinito consiste nell'impostarlo sul valore delle vCPU disponibili per le dimensioni della macchina virtuale esposte in risposta api di Elencare tutte le dimensioni delle macchine virtuali disponibili in un'area.
|
vCPUsPerCore
|
integer
|
Specifica il rapporto tra vCPU e core fisici. Quando questa proprietà non viene specificata nel corpo della richiesta, il comportamento predefinito è impostato sul valore di vCPUsPerCore per le dimensioni della macchina virtuale esposte in risposta api di Elencare tutte le dimensioni delle macchine virtuali disponibili in un'area.
L'impostazione di questa proprietà su 1 indica anche che l'hyper-threading è disabilitato.
|
WindowsConfiguration
Specifica le impostazioni del sistema operativo Windows nella macchina virtuale.
Nome |
Tipo |
Descrizione |
additionalUnattendContent
|
AdditionalUnattendContent[]
|
Specifica ulteriori informazioni in formato XML con codifica Base 64 che possono essere incluse nel file Unattend.xml, che viene utilizzato dal programma di installazione di Windows.
|
enableAutomaticUpdates
|
boolean
|
Indica se gli aggiornamenti automatici sono abilitati per la macchina virtuale Windows. Il valore predefinito è true. Per i set di scalabilità di macchine virtuali, questa proprietà può essere aggiornata e gli aggiornamenti avranno effetto sul reprovisioning del sistema operativo.
|
enableVMAgentPlatformUpdates
|
boolean
|
Indica se gli aggiornamenti della piattaforma VMAgent sono abilitati per la macchina virtuale Windows.
|
patchSettings
|
PatchSettings
|
[Funzionalità di anteprima] Specifica le impostazioni correlate all'applicazione di patch guest della macchina virtuale in Windows.
|
provisionVMAgent
|
boolean
|
Indica se è necessario eseguire il provisioning dell'agente di macchine virtuali nella macchina virtuale. Quando questa proprietà non viene specificata nel corpo della richiesta, viene impostata su true per impostazione predefinita. In questo modo si garantisce che l'agente di macchine virtuali sia installato nella macchina virtuale in modo che le estensioni possano essere aggiunte alla macchina virtuale in un secondo momento.
|
timeZone
|
string
|
Specifica il fuso orario della macchina virtuale. ad esempio "Ora solare pacifico". I valori possibili possono essere TimeZoneInfo.Id valore dai fusi orari restituiti da TimeZoneInfo.GetSystemTimeZones.
|
winRM
|
WinRMConfiguration
|
Specifica i listener di Gestione remota Windows. In questo modo si abilita Windows PowerShell remoto.
|
WindowsPatchAssessmentMode
Specifica la modalità di valutazione delle patch guest della macchina virtuale per la macchina virtuale IaaS.
I valori possibili sono:
ImageDefault: è possibile controllare la tempistica delle valutazioni delle patch in una macchina virtuale.
AutomaticByPlatform: la piattaforma attiverà valutazioni periodiche delle patch. La proprietà provisionVMAgent deve essere true.
Nome |
Tipo |
Descrizione |
AutomaticByPlatform
|
string
|
|
ImageDefault
|
string
|
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
Nome |
Tipo |
Descrizione |
Always
|
string
|
|
IfRequired
|
string
|
|
Never
|
string
|
|
Unknown
|
string
|
|
Specifica impostazioni aggiuntive da applicare quando la modalità patch AutomaticByPlatform è selezionata nelle impostazioni della patch di Windows.
Nome |
Tipo |
Descrizione |
bypassPlatformSafetyChecksOnUserSchedule
|
boolean
|
Consente al cliente di pianificare l'applicazione di patch senza aggiornamenti accidentali
|
rebootSetting
|
WindowsVMGuestPatchAutomaticByPlatformRebootSetting
|
Specifica l'impostazione di riavvio per tutte le operazioni di installazione delle patch AutomaticByPlatform.
|
WindowsVMGuestPatchMode
Specifica la modalità di applicazione di patch guest alle macchine virtuali IaaS o alle macchine virtuali associate al set di scalabilità di macchine virtuali con OrchestrationMode come flessibile.
I valori possibili sono:
manuale: è possibile controllare l'applicazione di patch a una macchina virtuale. A tale scopo, applicare manualmente le patch all'interno della macchina virtuale. In questa modalità gli aggiornamenti automatici sono disabilitati; La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere false
AutomaticByOS: la macchina virtuale verrà aggiornata automaticamente dal sistema operativo. La proprietà WindowsConfiguration.enableAutomaticUpdates deve essere true.
AutomaticByPlatform: la macchina virtuale verrà aggiornata automaticamente dalla piattaforma. Le proprietà provisionVMAgent e WindowsConfiguration.enableAutomaticUpdates devono essere true
Nome |
Tipo |
Descrizione |
AutomaticByOS
|
string
|
|
AutomaticByPlatform
|
string
|
|
Manual
|
string
|
|
WinRMConfiguration
Descrive la configurazione di Gestione remota Windows della macchina virtuale
Nome |
Tipo |
Descrizione |
listeners
|
WinRMListener[]
|
Elenco di listener di Gestione remota Windows
|
WinRMListener
Descrive il protocollo e l'identificazione personale del listener di Gestione remota Windows
Nome |
Tipo |
Descrizione |
certificateUrl
|
string
|
Si tratta dell'URL di un certificato caricato in Key Vault come segreto. Per aggiungere un segreto all'insieme di credenziali delle chiavi, vedere Aggiungere una chiave o un segreto all'insieme di credenziali delle chiavi. In questo caso, il certificato deve essere la codifica Base64 dell'oggetto JSON seguente, codificato in UTF-8:
{ "data":"", "dataType":"pfx", "password":"" } Per installare i certificati in una macchina virtuale, è consigliabile usare l'estensione macchina virtuale di Azure Key Vault per Linux o l'estensione macchina virtuale di Azure Key Vault per Windows.
|
protocol
|
ProtocolTypes
|
Specifica il protocollo del listener WinRM. I valori possibili sono: http,https.
|
ZonalPlatformFaultDomainAlignMode
Specifica la modalità di allineamento tra il calcolo del set di scalabilità di macchine virtuali e il numero di domini di errore di archiviazione.
Nome |
Tipo |
Descrizione |
Aligned
|
string
|
|
Unaligned
|
string
|
|