Introduction to Azure Compute Options

Watch the video to deepen your understanding.
SubscribeComplete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
Lesson: Introduction to Azure Compute Options
Introduction
In cloud architecture, "compute" refers to the hosting model that executes your application code. Choosing the right compute service is a foundational decision that impacts your application’s scalability, cost, management overhead, and performance.
Azure offers a diverse spectrum of compute services, ranging from "IaaS" (Infrastructure as a Service), where you manage the operating system, to "Serverless" (FaaS), where you focus solely on code and let Azure handle the infrastructure. Understanding these options is critical for designing infrastructure solutions that meet specific business requirements.
The Compute Spectrum
To choose the right tool, you must understand where a service falls on the spectrum of control versus convenience.
1. Virtual Machines (IaaS)
Azure Virtual Machines (VMs) provide the most control. You are responsible for patching, updating, and configuring the OS.
- Best for: Legacy applications, custom configurations, or scenarios requiring specific OS-level access.
- Example: Migrating an on-premises SQL Server instance that requires a specific OS version or proprietary drivers.
2. Azure App Service (PaaS)
App Service is a fully managed platform for building, deploying, and scaling web apps. You provide the code, and Azure handles the underlying infrastructure, OS patching, and load balancing.
- Best for: Web applications, REST APIs, and mobile backends.
- Example: Hosting a .NET, Java, or Node.js web application without managing servers.
3. Azure Container Instances (ACI) & Azure Kubernetes Service (AKS)
Containers allow you to package code and dependencies together.
- ACI: The fastest way to run a container in Azure without managing a cluster. Great for short-lived tasks.
- AKS: A managed Kubernetes service for orchestrating complex, multi-container applications.
- Best for: Microservices architectures and portable applications.
4. Azure Functions (Serverless)
Azure Functions allows you to run code triggered by events without provisioning any infrastructure. You pay only for the execution time.
- Best for: Event-driven tasks, data processing, and background jobs.
- Example: Triggering a process every time a file is uploaded to Azure Blob Storage.
Practical Examples & Code Snippets
Deploying a Simple Azure Function (Python)
Azure Functions are ideal for event-driven logic. Below is a simple HTTP-triggered function:
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
name = req.params.get('name')
if name:
return func.HttpResponse(f"Hello, {name}!")
else:
return func.HttpResponse("Please pass a name in the query string.", status_code=400)
Infrastructure as Code (Bicep snippet for a VM)
When designing infrastructure, you should define your compute resources using IaC. Here is a snippet to define a basic VM in Azure Bicep:
resource vm 'Microsoft.Compute/virtualMachines@2022-03-01' = {
name: 'myLinuxVM'
location: 'eastus'
properties: {
hardwareProfile: { vmSize: 'Standard_B1s' }
osProfile: {
computerName: 'linux-box'
adminUsername: 'azureuser'
}
}
}
Best Practices
- Start with PaaS/Serverless: Always evaluate if your application can run on App Service or Azure Functions before resorting to VMs. Reducing "server management" lowers your operational burden.
- Use Autoscale: Regardless of the compute type, configure scaling rules. Use Scale Out (adding more instances) rather than Scale Up (making the instance bigger) whenever possible for better reliability.
- Right-Size Resources: Use Azure Advisor to monitor VM utilization. If your CPU usage is consistently under 5%, you are overpaying—downsize the instance.
- Implement Security: For VMs, use Azure Bastion instead of exposing RDP/SSH ports to the public internet. For containers, store sensitive configuration in Azure Key Vault.
⚠️ Common Pitfalls
- "Lifting and Shifting" without modification: Simply moving a VM to the cloud without refactoring often leads to higher costs and missed opportunities for cloud-native performance.
- Ignoring Cold Starts: In Serverless (Azure Functions), an idle function may experience a "cold start" delay. If your application requires sub-millisecond latency, consider a dedicated App Service plan instead.
- Over-provisioning: Setting up large clusters or high-spec VMs "just in case" leads to significant budget waste. Start small and scale based on actual metrics.
Key Takeaways
- Understand the Control Trade-off: More control (VMs) equals more management responsibility. Less control (Functions/App Service) equals higher developer productivity.
- Match the Compute to the Workload: Use containers for microservices, Functions for event-driven tasks, App Service for web apps, and VMs for legacy/system-level needs.
- Prioritize Automation: Use Infrastructure as Code (Bicep/Terraform) to deploy compute resources. This ensures consistency, repeatability, and version control for your infrastructure.
- Monitor and Optimize: Compute costs are usually the largest part of an Azure bill. Use Azure Monitor and Advisor to ensure your compute footprint is efficient and secure.
By mastering these compute options, you can design infrastructure that is not only functional but also resilient, scalable, and cost-effective.
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons