📖 Scenario: You are working as a cloud assistant helping a small company understand different Azure Virtual Machine (VM) pricing models. The company wants to compare pay-as-you-go and reserved instance pricing for specific VM types.
🎯 Goal: Build a simple data structure to hold VM pricing information, add a configuration for the pricing model, calculate the monthly cost based on the model, and finalize the configuration for deployment.
📋 What You'll Learn
Create a dictionary with VM types and their pay-as-you-go hourly prices
Add a variable to select the pricing model ('payg' or 'reserved')
Calculate the monthly cost for each VM type based on 730 hours per month
Add a final configuration key to indicate the pricing model used
💡 Why This Matters
🌍 Real World
Cloud architects and cost analysts often compare VM pricing models to optimize cloud spending.
💼 Career
Understanding VM pricing helps in budgeting, cost optimization, and advising clients or teams on cloud infrastructure choices.
Progress0 / 4 steps
1
Create VM pricing dictionary
Create a dictionary called vm_prices with these exact entries: 'Standard_B1s': 0.012, 'Standard_D2s_v3': 0.096, 'Standard_F4s': 0.169. These represent the pay-as-you-go hourly prices in USD.
Azure
Hint
Use curly braces to create a dictionary with the exact keys and values.
2
Add pricing model configuration
Add a variable called pricing_model and set it to the string 'payg' to represent the pay-as-you-go pricing model.
Azure
Hint
Assign the string 'payg' to the variable pricing_model.
3
Calculate monthly VM costs
Create a new dictionary called monthly_costs that calculates the monthly cost for each VM type by multiplying the hourly price from vm_prices by 730 hours. Use a dictionary comprehension with vm and price as variables.
Azure
Hint
Use a dictionary comprehension with for vm, price in vm_prices.items() and multiply price by 730.
4
Add final pricing model key
Add a new key 'pricing_model' to the monthly_costs dictionary and set its value to the pricing_model variable.
Azure
Hint
Assign the pricing_model variable to the 'pricing_model' key in monthly_costs.
Practice
(1/5)
1. Which Azure VM pricing model allows you to pay only for the time you use without any long-term commitment?
easy
A. Spot VMs
B. Reserved Instances
C. Hybrid Benefit
D. Pay-as-you-go
Solution
Step 1: Understand Pay-as-you-go model
This model charges you based on actual usage with no upfront commitment.
Step 2: Compare with other models
Reserved Instances require upfront commitment, Spot VMs can be interrupted, Hybrid Benefit is a discount on licenses.
Final Answer:
Pay-as-you-go -> Option D
Quick Check:
Flexible payment without commitment = Pay-as-you-go [OK]
Hint: Pay only for what you use with no upfront cost [OK]
Common Mistakes:
Confusing Reserved Instances with Pay-as-you-go
Thinking Spot VMs are always available
Mixing Hybrid Benefit with pricing models
2. Which of the following is the correct description of Spot VMs in Azure?
easy
A. VMs that offer the lowest price but can be evicted anytime
B. VMs with a fixed monthly cost and no interruptions
C. VMs reserved for one year with upfront payment
D. VMs that use existing licenses for cost savings
Solution
Step 1: Identify Spot VMs characteristics
Spot VMs provide the lowest price but can be interrupted or evicted when Azure needs capacity.
Step 2: Eliminate other options
Fixed monthly cost applies to Reserved Instances, upfront payment is for Reserved Instances, license reuse is Hybrid Benefit.
Final Answer:
VMs that offer the lowest price but can be evicted anytime -> Option A
Quick Check:
Lowest cost but interruptible = Spot VMs [OK]
Hint: Spot VMs are cheap but can be stopped anytime [OK]
Common Mistakes:
Assuming Spot VMs have fixed pricing
Confusing Spot VMs with Reserved Instances
Thinking Hybrid Benefit applies to Spot VMs
3. Consider you have a workload that runs continuously for 3 years. Which pricing model will most likely save you the most money?
medium
A. Pay-as-you-go
B. Reserved Instances
C. Hybrid Benefit
D. Spot VMs
Solution
Step 1: Analyze workload duration
A continuous 3-year workload benefits from long-term commitment discounts.
Step 2: Match pricing model to workload
Reserved Instances offer significant savings for long-term use compared to Pay-as-you-go or Spot VMs.
Final Answer:
Reserved Instances -> Option B
Quick Check:
Long-term continuous use = Reserved Instances [OK]