The article walks through how to deploy a scale set using Instance Mix.
It takes a few moments for the feature to register. Verify the registration status by using the az feature show command:
- Go to Virtual machine scale sets.
- Select the Create button to go to the Create a virtual machine scale set view.
- In the Basics tab, fill out the required fields. If the field isn't called out in the next sections, you can set the fields to what works best for your scale set.
- Ensure that you select a region that Instance Mix is supported in.
- Be sure Orchestration mode is set to Flexible.
- In the Size section, click Select up to 5 sizes (preview) and the Select a VM size page appears.
- Use the size picker to select up to five VM sizes. Once you've selected your VM sizes, click the Select button at the bottom of the page to return to the scale set Basics tab.
- In the Allocation strategy (preview) field, select your allocation strategy.
- When using the
Prioritized
allocation strategy, the Rank size section appears below the Allocation strategy section. Clicking on the bottom Rank priority brings up the prioritization blade, where you can adjust the priority of your VM sizes.
- You can specify other properties in subsequent tabs, or you can go to Review + create and select the Create button at the bottom of the page to start your Instance Mix scale set deployment.
You can use the following basic command to create a scale set using Instance Mix using the following command, which will default to using the lowestPrice
allocation strategy:
az vmss create \
--name {myVMSS} \
--resource-group {myResourceGroup} \
--image ubuntu2204 \
--vm-sku Mix \
--skuprofile-vmsizes Standard_DS1_v2 Standard_D2s_v4
To specify the allocation strategy, use the --skuprofile-allocation-strategy
parameter, like the following:
az vmss create \
--name {myVMSS} \
--resource-group {myResourceGroup} \
--image ubuntu2204 \
--vm-sku Mix \
--skuprofile-vmsizes Standard_DS1_v2 Standard_D2s_v4 \
--skuprofile-allocation-strategy CapacityOptimized
You can use the following basic command to create a scale set using Instance Mix using the following command, which will default to using the lowestPrice
allocation strategy:
New-AzVmss `
-ResourceGroupName $resourceGroupName `
-Credential $credentials `
-VMScaleSetName $vmssName `
-DomainNameLabel $domainNameLabel1 `
-VMSize "Mix" `
-SkuProfileVmSize @("Standard_D4s_v3", "Standard_D4s_v4");
To specify the allocation strategy, use the SkuProfileAllocationStrategy
parameter, like the following:
New-AzVmss `
-ResourceGroupName $resourceGroupName `
-Credential $credentials `
-VMScaleSetName $vmssName `
-DomainNameLabel $domainNameLabel1 `
-SkuProfileVmSize @("Standard_D4s_v3", "Standard_D4s_v4") `
-SkuProfileAllocationStrategy "CapacityOptimized";
To create a scale set using a scale set configuration object utilizing Instance Mix, use the following command:
$vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -UpgradePolicyMode 'Manual' -EncryptionAtHost -SecurityType $stnd -SkuProfileVmSize @("Standard_D4s_v3", "Standard_D4s_v4") -SkuProfileAllocationStrategy "CapacityOptimized"`
| Add-AzVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg `
| Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
| Set-AzVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion 'latest' `
-ImageReferencePublisher $imgRef.PublisherName;
$vmssResult = New-AzVmss -ResourceGroupName $resourceGroupName -Name $vmssName -VirtualMachineScaleSet $vmss
To deploy an Instance Mix scale set through REST API, use a PUT
call to and include the following sections in your request body:
PUT https://management.azure.com/subscriptions/{YourSubscriptionId}/resourceGroups/{YourResourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{youScaleSetName}?api-version=2023-09-01
In the request body, ensure sku.name
is set to Mix:
"sku": {
"name": "Mix",
"capacity": {TotalNumberVMs}
},
Ensure you reference your existing subnet:
"subnet": {
"id": "/subscriptions/{YourSubscriptionId}/resourceGroups/{YourResourceGroupName}/providers/Microsoft.Network/virtualNetworks/{YourVnetName}/subnets/default"
},
Lastly, be sure to specify the skuProfile
with up to five VM sizes. This sample uses three:
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5"
},
{
"name": "Standard_E16s_v5"
},
{
"name": "Standard_D2s_v5"
}
],
"allocationStrategy": "lowestPrice"
},
When using the prioritized
allocation strategy, you can specify the priority ranking of the vmSizes
specified:
"skuProfile": {
"vmSizes": [
{
"name": "Standard_D8s_v5", "rank": 1
},
{
"name": "Standard_E16s_v5", "rank": 2
},
{
"name": "Standard_D2s_v5", "rank": 1
}
],
"allocationStrategy": "Prioritized"
},