Azure
Azure
Introduction to Azure
Azure Global Infrastructure
● Region: A geographical area (like East US, West Europe) containing at least one
datacenter.
● Availability Zone: Physically separate locations within a region, each with independent
power, cooling, and networking — ensures high availability (HA).
● Paired Regions: Each Azure region is paired with another within the same geography to
support disaster recovery (e.g., East US ↔ West US).
Component Description
Use Case: Deploying a web app in multiple zones ensures zero downtime even if a zone fails.
● Subscription: Unit of billing and resource access. One tenant can have many
subscriptions.
● Management Group: Container for managing access, policies, and compliance across
multiple subscriptions.
Resource Groups
Best Practice: Group related resources by lifecycle (dev/test/prod) for better manageability.
● 12 Months Free: Includes limited free usage of VMs, SQL DB, Blob Storage.
● Always Free: 25+ services including Azure Functions, Cosmos DB (1 GB), App
Services (F1), etc.
DB SQL DB 250 GB
2. Compute Services
Virtual Machines (VMs)
● Use Availability Sets, Scale Sets, and Managed Disks for HA and scalability.
# Create VM (Linux)
az vm create \
--name demoVM \
--resource-group demo-rg \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
Best Practice: Use Azure Reserved Instances (RIs) for cost savings (up to 72%).
Use Case: Ideal for developers who don’t want to manage infrastructure.
Triggers:
● HTTP (API)
● Blob/File Change
● Queue/Service Bus
az container create \
--name demo-container \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--resource-group demo-rg \
--dns-name-label demo-container \
--ports 80
Use Case: Rapidly spin up isolated containers for testing, batch jobs.
Azure Kubernetes Service (AKS)
az aks create \
--resource-group demo-rg \
--name demo-aks \
--node-count 2 \
--enable-addons monitoring \
--generate-ssh-keys
Best Practice: Use Azure CNI for advanced networking and Managed Identity for secure
resource access.
Components:
● Tiers:
Azure Files
● Two generations:
○ Gen1 (legacy)
Use Case: Store data for processing with Azure Synapse, Databricks, or HDInsight.
Import/Export
Azure Backup
Archive Storage
4. Networking
Virtual Networks (VNets)
● Types:
● Provides:
○ SSL offloading
○ Caching
○ Global routing
Use Case: Serve static + dynamic web apps with low latency worldwide.
○ Performance
○ Geographic
○ Weighted
○ Priority
ExpressRoute
● Bypasses the public internet, ensuring low latency and high security.
VPN Gateway
VNet Peering
● Intra-region or cross-region
5. Databases
Azure SQL Database
● Modes:
○ Serverless (auto-pause/resume)
● T-SQL compatible.
Azure Cosmos DB
● Multiple APIs:
● Low-cost, schema-less.
Use Case: Unified login for Office 365, Azure Portal, and third-party apps.
● Common roles:
○ Owner
○ Contributor
○ Reader
○ Custom roles
az role assignment create --assignee [email protected] --role Contributor
--resource-group demo-rg
Conditional Access
○ User location
○ Device compliance
○ Risk level
● Used with MFA, block legacy auth, require app protection policies.
Managed Identities
● Provide Azure services (like VMs, Functions) with an identity to access other Azure
resources securely.
Types:
● Supports:
○ Custom UI
○ Self-service registration
● Guest users are managed just like internal users but with limited scope.
● Centralized platform to collect, analyze, and act on telemetry from cloud and on-prem
resources.
Application Insights
○ Failures
○ Dependency tracking
○ Exception traces
Log Analytics
● Pulls data from Azure Monitor and Application Insights into Log Analytics Workspace.
Example:
Heartbeat
| summarize LastSeen=max(TimeGenerated) by Computer
Alerts and Metrics
○ Log queries
Network Watcher
● Helps monitor, diagnose, view metrics, and enable logging for network resources.
● Tools:
○ Connection Monitor
○ IP Flow Verify
○ Packet Capture
○ Topology Viewer
● Components:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello World
displayName: 'Run a one-line script'
● Use prebuilt Azure Login, Web App Deploy, and Container Actions.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
Azure CLI
Azure PowerShell
● Extensions for:
○ Azure Functions
○ App Service
○ ARM/Bicep Tools
○ Azure CLI
○ Cosmos DB
{
"$schema": "...",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {}
}
]
}
Bicep
{
"if": {
"field":
"Microsoft.Network/publicIPAddresses/publicIPAllocationMethod",
"equals": "Static"
},
"then": {
"effect": "deny"
}
}
Example use:
● Ensure every new subscription has a standard networking setup, RBAC roles,
policies, and resource groups.
Key features:
Azure Lighthouse
Example:
● A partner manages multiple clients' Azure environments securely and centrally using
Lighthouse.
Locks:
● Two types:
○ CanNotDelete
○ ReadOnly
Tags:
○ Drag-and-drop (low-code)
● Integration with:
Cognitive Services
Vision
Speech
Language
Decision
● Integrates with:
○ Microsoft Teams
○ Facebook Messenger
○ Slack
○ Webchat
Architecture:
Bot → Bot Framework → Cognitive Services (LUIS, QnA Maker) → Channels
OpenAI on Azure
● Provides access to GPT models (like ChatGPT, GPT-4) via REST API.
○ Text summarization
Example:
import openai
openai.api_base = "https://<your-resource-name>.openai.azure.com/"
openai.api_key = "<your-key>"
response = openai.ChatCompletion.create(
engine="gpt-35-turbo",
messages=[{"role": "user", "content": "Explain Azure Functions"}]
)
● Key Capabilities:
○ Secure Score
○ Just-in-Time VM Access
Defender for Cloud integrates with Microsoft Sentinel and Microsoft Defender for
Endpoint.
● Features:
● Used to safeguard:
○ SSL/TLS certificates
● Two tiers:
Features:
● Provides:
○ Workbooks (dashboards)
○ Region
○ Usage parameters
● URL: https://azure.microsoft.com/en-us/pricing/calculator/
Azure Budgets
Example:
● Notify team when 75% of the monthly budget for App Services is reached.
Cost Analysis
○ Resource group
○ Service
○ Tags
○ Time
Reservations
● Applies to:
○ VMs
○ SQL DB
○ Cosmos DB
● Bring your existing on-prem Windows Server or SQL Server licenses to Azure.
Key Features:
Example Commands:
# Login to Azure
az login
Common Commands:
Install module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
●
Examples:
# Connect to Azure
Connect-AzAccount
●
Azure provides comprehensive SDKs to integrate cloud resources into your apps.
conn_str = "<connection_string>"
client = BlobServiceClient.from_connection_string(conn_str)
container = client.get_container_client("data")
container.upload_blob("test.txt", b"Hello Azure!")
Install-Package Azure.Identity
Install-Package Azure.Storage.Blobs
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.0</version>
</dependency>
Use case:
Plan a secure migration of legacy VMs to Azure with governance and identity
guardrails.
Reference Architectures
Link: https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/
Best Practices:
Example:
Deploy a 3-tier app across East US and Central US, with Front Door routing traffic
and Cosmos DB in multi-region write mode.