It sounds like you want a repeatable sandbox solution where customized Azure VMs are deployed automatically, scaled according to demand, monitored, repaired, and updated without configuring each VM manually.
For a new implementation, use an Azure Virtual Machine Scale Set with Flexible orchestration. Flexible orchestration supports standard Azure VM management APIs, availability zones or fault domains, metrics-based autoscaling, instance protection, standby pools, and upgrade policies.
A practical design would be:
Define the infrastructure as code.
Use Bicep or Terraform to deploy the resource group, virtual network, subnet, NSG, managed identity, load balancer or Application Gateway, VM Scale Set, autoscale settings, Log Analytics workspace, alerts, and RBAC assignments. Store sandbox-specific values such as VM size and maximum instance count in a separate parameter or .tfvars file.
Create a repeatable VM configuration.
Build a hardened base image containing the operating system, agents, dependencies, and stable application components. Publish versioned images to Azure Compute Gallery and reference a specific image version from the scale set. This prevents newly scaled instances from receiving an unexpected image version. Use cloud-init, custom data, or a VM extension only for environment-specific configuration.
Configure scaling.
Set minimum, default, and maximum instance counts. For example, a sandbox might use minimum=1, default=1, and maximum=3. Add scale-out and scale-in rules based on CPU, memory, queue length, request count, or an application metric. Azure Autoscale can add or remove instances when the configured metric remains above or below its threshold.
Add health management.
Expose an application health endpoint such as /health and configure the Application Health extension. Enable automatic instance repairs so Azure replaces unhealthy instances rather than leaving failed servers in service. Configure only one VMSS health source: either the Application Health extension or a load-balancer health probe.
Manage updates safely.
Publish a new image version, update the VMSS model, run a smoke test, and then roll the change through the scale set in batches. Rolling upgrades preserve available capacity while instances are updated. With Flexible orchestration, the Application Health extension is required for rolling upgrades.
The deployment pipeline should follow this sequence:
validate → plan/what-if → deploy network and identity → deploy/update VMSS → health test → enable autoscale → monitor
Treat every scale-set instance as replaceable. Store persistent data, user sessions, and application state outside the VMs in services such as Azure SQL, Storage, Azure Files, or another suitable data platform. Avoid manually changing individual VM instances because those changes will be lost when an instance is repaired, reimaged, or scaled in.
For a sandbox, also use small VM sizes, budgets, expiration tags, Azure Policy, restricted RBAC, network isolation, and an automated resource-group deletion process. Microsoft explicitly states that Azure sandbox environments are for testing rather than production and recommends budgets, isolation, auditing, and automatic decommissioning.
If “sandbox” refers specifically to the former Microsoft Learn sandbox, those environments are no longer available; an Azure subscription is now required for the exercises