Bird
Raised Fist0
Azurecloud~10 mins

Right-sizing resources in Azure - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the VM size for right-sizing.

Azure
vm = compute_client.virtual_machines.create_or_update(resource_group_name, vm_name, {"hardware_profile": {"vm_size": "[1]"}})
Drag options to blanks, or click blank then click option'
AStandard_F16s_v2
BBasic_A0
CStandard_DS1_v2
DPremium_LRS
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing storage types instead of VM sizes.
Picking very large VM sizes unnecessarily.
2fill in blank
medium

Complete the code to set the SKU for an Azure SQL Database to optimize cost.

Azure
sql_db = sql_client.databases.create_or_update(resource_group_name, server_name, database_name, {"sku": {"name": "[1]"}})
Drag options to blanks, or click blank then click option'
ABasic
BPremium
CBusinessCritical
DHyperscale
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting high-performance SKUs for low-demand workloads.
Confusing SKU names with service tiers.
3fill in blank
hard

Fix the error in the code to resize an Azure VM to a smaller size for cost savings.

Azure
vm_update = compute_client.virtual_machines.begin_update(resource_group_name, vm_name, {"hardware_profile": {"vm_size": "[1]"}})
Drag options to blanks, or click blank then click option'
AUltraSSD_LRS
BStandard_F32s_v2
CStandard_D64s_v3
DStandard_B1s
Attempts:
3 left
💡 Hint
Common Mistakes
Using storage types instead of VM sizes.
Selecting larger VM sizes when downsizing.
4fill in blank
hard

Fill both blanks to configure an Azure App Service plan with a cost-effective SKU and region.

Azure
app_service_plan = web_client.app_service_plans.begin_create_or_update(resource_group_name, plan_name, {"location": "[1]", "sku": {"name": "[2]"}})
Drag options to blanks, or click blank then click option'
Aeastus
Bwestus2
CB1
DP1v2
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting premium SKUs for simple apps.
Choosing regions with higher pricing.
5fill in blank
hard

Fill all three blanks to create a storage account with right-sized performance and redundancy.

Azure
storage_account = storage_client.storage_accounts.begin_create(resource_group_name, account_name, {"location": "[1]", "sku": {"name": "[2]"}, "kind": "[3]"})
Drag options to blanks, or click blank then click option'
Aeastus2
BStandard_LRS
CStorageV2
DPremium_ZRS
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing premium SKUs unnecessarily.
Using older storage kinds that lack features.

Practice

(1/5)
1. What does right-sizing mean in Azure cloud resource management?
easy
A. Buying the largest possible resources to avoid any performance issues
B. Choosing the best size for your cloud resources to save cost and improve performance
C. Using only free-tier resources regardless of workload needs
D. Deleting unused resources without checking their usage

Solution

  1. Step 1: Understand the term 'right-sizing'

    Right-sizing means selecting the most appropriate size of cloud resources based on actual workload needs.
  2. Step 2: Identify the benefits of right-sizing

    It helps save money by avoiding over-provisioning and improves performance by matching resources to demand.
  3. Final Answer:

    Choosing the best size for your cloud resources to save cost and improve performance -> Option B
  4. Quick Check:

    Right-sizing = Best size choice [OK]
Hint: Right-sizing means matching resource size to workload needs [OK]
Common Mistakes:
  • Thinking bigger is always better
  • Ignoring cost savings
  • Confusing right-sizing with deleting resources
2. Which Azure CLI command sequence correctly resizes a virtual machine named myVM to size Standard_DS2_v2?
easy
A. az vm stop --name myVM && az vm resize --name myVM --size Standard_DS2_v2 && az vm start --name myVM
B. az vm resize --name myVM --size Standard_DS2_v2 && az vm stop --name myVM && az vm start --name myVM
C. az vm start --name myVM && az vm resize --name myVM --size Standard_DS2_v2 && az vm stop --name myVM
D. az vm start --name myVM && az vm stop --name myVM && az vm resize --name myVM --size Standard_DS2_v2

Solution

  1. Step 1: Stop the VM before resizing

    Azure requires the VM to be stopped before changing its size to avoid errors.
  2. Step 2: Resize and then start the VM

    After stopping, resize the VM, then start it again to apply changes.
  3. Final Answer:

    az vm stop --name myVM && az vm resize --name myVM --size Standard_DS2_v2 && az vm start --name myVM -> Option A
  4. Quick Check:

    Stop, resize, start = correct order [OK]
Hint: Always stop VM before resizing, then start it [OK]
Common Mistakes:
  • Trying to resize while VM is running
  • Starting VM before resizing
  • Wrong command order causing errors
3. Given this Azure CLI snippet, what will be the output status of the VM after execution?
az vm stop --name testVM && az vm resize --name testVM --size Standard_B1s && az vm start --name testVM && az vm show --name testVM --query "powerState" -o tsv
medium
A. VM will be running
B. VM will be stopped
C. VM will be deallocated
D. Command will fail due to wrong order

Solution

  1. Step 1: Analyze command sequence

    The VM is stopped, resized, then started, and finally its power state is queried.
  2. Step 2: Determine VM state after commands

    Since the VM is started before querying, the power state will show as running.
  3. Final Answer:

    VM will be running -> Option A
  4. Quick Check:

    Stop, resize, start, then check = running [OK]
Hint: Last command starts VM before checking state [OK]
Common Mistakes:
  • Assuming VM stays stopped after start command
  • Confusing deallocated with stopped
  • Ignoring command order effects
4. You tried to resize an Azure VM using:
az vm resize --name myVM --size Standard_DS3_v2

but got an error. What is the most likely cause?
medium
A. You need to start the VM before resizing
B. The VM name is incorrect
C. The size Standard_DS3_v2 does not exist
D. The VM is currently running and must be stopped before resizing

Solution

  1. Step 1: Understand Azure VM resize requirements

    Azure requires the VM to be stopped before resizing to avoid conflicts.
  2. Step 2: Identify common error causes

    If the VM is running, resize commands fail with an error prompting to stop the VM first.
  3. Final Answer:

    The VM is currently running and must be stopped before resizing -> Option D
  4. Quick Check:

    VM must be stopped before resize [OK]
Hint: Stop VM before resizing to avoid errors [OK]
Common Mistakes:
  • Trying to resize running VM
  • Assuming VM name typo without checking
  • Believing VM must be started before resize
5. You have a VM running with size Standard_DS4_v2 but your monitoring shows only 20% CPU usage consistently. Which is the best right-sizing approach to reduce costs without impacting performance?
hard
A. Resize the VM to Standard_DS1_v2 while it is running
B. Keep the current size since resizing may cause downtime
C. Resize the VM to Standard_DS2_v2 after stopping it, then start it again
D. Delete the VM and create a new smaller VM

Solution

  1. Step 1: Analyze CPU usage and sizing

    Low CPU usage (20%) suggests the VM is over-provisioned and can be downsized safely.
  2. Step 2: Choose a smaller size and follow correct resize steps

    Resizing to Standard_DS2_v2 reduces cost and maintains performance. Stop VM before resizing, then start it.
  3. Final Answer:

    Resize the VM to Standard_DS2_v2 after stopping it, then start it again -> Option C
  4. Quick Check:

    Stop, resize smaller, start = cost saving [OK]
Hint: Downsize VM after stopping to save cost safely [OK]
Common Mistakes:
  • Resizing while VM is running
  • Ignoring low CPU usage signals
  • Deleting VM unnecessarily