Skip to content

Practical Microsoft Azure Interview Questions

45 questions with answers. Hands-on questions where you write code, a query, a formula or concrete steps.

How to approach these questions

Talk while you work: say your approach first, write the simplest correct version, then improve it and mention edge cases.

Solved — practicalStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

How do Azure SLAs work and how do you calculate a composite SLA?

Save to ▾
Show answer
An SLA is Microsoft's uptime commitment per service, with service credits if it is missed. When services depend on each other in series, multiply their SLAs. An App Service at 99.95% calling Azure SQL at 99.99% gives about 0.9995 x 0.9999 = 99.94%. Adding redundancy, such as a second region behind Front Door, raises the combined figure because both paths must fail together.
02

What are tags and how are they used in real projects?

Save to ▾
Show answer
Tags are name-value pairs such as env=prod, owner=payments, costcenter=CC101 applied to resources, groups and subscriptions. They help filter cost reports, automate shutdown scripts and track ownership. Tags are not inherited by default, so teams use Azure Policy with modify or append effects to inherit tags from the resource group or require them at creation. A resource can carry up to 50 tags.
03

How do you create a resource group and list resources using Azure CLI?

Save to ▾
Show answer
Log in, select the subscription, create the group with tags, then list its resources in a table: az login az account set --subscription 'Prod-Sub' az group create --name rg-shop-prod --location centralindia --tags env=prod owner=shop az resource list --resource-group rg-shop-prod --output table The --query flag with JMESPath filters output, for example --query '[].name'.
04

Write an Azure PowerShell command to find all VMs without an env tag.

Save to ▾
Show answer
Filter Get-AzVM output on the Tags hashtable and export the result for review: Connect-AzAccount Get-AzVM | Where-Object { -not $_.Tags -or -not $_.Tags.ContainsKey('env') } | Select-Object Name, ResourceGroupName, Location | Export-Csv untagged-vms.csv -NoTypeInformation For large estates, Azure Resource Graph queries are faster across many subscriptions.
05

Explain Azure VM series and how you pick a size.

Save to ▾
Show answer
Series are optimised for workload type: B for burstable low-cost, D for general purpose, E for memory heavy like SQL Server, F for compute intensive, L for storage throughput, N for GPU and M for very large memory such as SAP HANA. Start from CPU, memory, disk IOPS and network needs, test with real load, then right-size using Azure Advisor recommendations after a few weeks of metrics.
06

Create a Linux VM with Azure CLI using SSH keys and no public IP.

Save to ▾
Show answer
Create the VM in an existing subnet with an empty public IP and generated SSH keys, then connect through Bastion: az vm create \ --resource-group rg-app-dev \ --name vm-api-01 \ --image Ubuntu2204 \ --size Standard_D2s_v5 \ --vnet-name vnet-dev --subnet snet-app \ --public-ip-address '' \ --admin-username azureuser \ --generate-ssh-keys \ --zone 1
07

Write a simple HTTP-triggered Azure Function in Python (v2 programming model).

Save to ▾
Show answer
The v2 model uses decorators in function_app.py, so no function.json is needed: import azure.functions as func app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION) @app.route(route='hello', methods=['GET']) def hello(req: func.HttpRequest) -> func.HttpResponse: name = req.params.get('name', 'world') return func.HttpResponse(f'Hello, {name}', status_code=200) Callers pass the function key in the code query parameter or x-functions-key header.
08

How do you configure autoscale for an App Service plan?

Save to ▾
Show answer
In the plan's Scale out settings, choose rules-based autoscale or automatic scaling. A typical rule set: scale out by 1 instance when average CPU exceeds 70% for 10 minutes, scale in by 1 when below 30% for 10 minutes, minimum 2 and maximum 10 instances. Always pair scale-out with a scale-in rule and a cool-down period so the plan does not flap between sizes.
09

Write the commands to create an AKS cluster with a system and a user node pool.

Save to ▾
Show answer
Create the cluster with Azure CNI overlay and the system pool across zones, then add a user pool for apps: az aks create -g rg-aks-prod -n aks-prod \ --network-plugin azure --network-plugin-mode overlay \ --nodepool-name system --node-count 3 --zones 1 2 3 \ --enable-managed-identity --attach-acr acrshopprod \ --generate-ssh-keys az aks nodepool add -g rg-aks-prod --cluster-name aks-prod \ -n apps --mode User --node-count 3 --zones 1 2 3 \ --enable-cluster-autoscaler --min-count 3 --max-count 10
10

How do you secure access to a storage account?

Save to ▾
Show answer
Disable shared key access where possible and use Entra ID with RBAC roles like Storage Blob Data Reader. Use managed identities for apps. Disable public blob access, require TLS 1.2, restrict the firewall to selected VNets, or use private endpoints and disable public network access. Enable soft delete, versioning and Defender for Storage, and keep keys, if any, in Key Vault with rotation.
11

Upload a folder to Blob Storage with AzCopy using Entra ID login.

Save to ▾
Show answer
Log in with AzCopy and copy recursively; the user needs the Storage Blob Data Contributor role: azcopy login --tenant-id <tenant-guid> azcopy copy './reports' \ 'https://stshopprod.blob.core.windows.net/reports' \ --recursive --overwrite ifSourceNewer AzCopy runs transfers in parallel and can resume failed jobs with azcopy jobs resume.
12

Write a lifecycle management rule to tier and delete log blobs.

Save to ▾
Show answer
The JSON policy moves blobs under logs/ to Cool after 30 days, Archive after 90 and deletes after 365: { "rules": [{ "name": "logs-tiering", "enabled": true, "type": "Lifecycle", "definition": { "filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["logs/"]}, "actions": {"baseBlob": { "tierToCool": {"daysAfterModificationGreaterThan": 30}, "tierToArchive": {"daysAfterModificationGreaterThan": 90}, "delete": {"daysAfterModificationGreaterThan": 365}}} }}] }
13

Read a blob in Python using DefaultAzureCredential.

Save to ▾
Show answer
DefaultAzureCredential uses a managed identity in Azure and your CLI login locally, so no keys are stored: from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient url = 'https://stshopprod.blob.core.windows.net' client = BlobServiceClient(url, credential=DefaultAzureCredential()) blob = client.get_blob_client('invoices', '2026/inv-1001.pdf') data = blob.download_blob().readall() print(len(data))
14

Generate a user delegation SAS for one blob with Azure CLI.

Save to ▾
Show answer
Log in with Entra ID, then create a short-lived read-only SAS signed with your identity: az storage blob generate-sas \ --account-name stshopprod --container-name invoices \ --name inv-1001.pdf --permissions r \ --expiry 2026-11-12T18:00Z --https-only \ --auth-mode login --as-user --full-uri The caller needs a role that allows generating user delegation keys.
15

How do you create a private endpoint for a storage account?

Save to ▾
Show answer
Create the private endpoint in the app subnet for the blob sub-resource, link the private DNS zone privatelink.blob.core.windows.net to the VNet, and disable public network access on the account: az network private-endpoint create -g rg-net -n pe-st-blob \ --vnet-name vnet-hub --subnet snet-pe \ --private-connection-resource-id <storage-id> \ --group-id blob --connection-name st-blob Then test that the name resolves to a 10.x address.
16

Create a VNet with two subnets and an NSG rule using Azure CLI.

Save to ▾
Show answer
Create the VNet, add subnets, then an NSG that allows HTTPS and attach it: az network vnet create -g rg-net -n vnet-app \ --address-prefixes 10.20.0.0/16 \ --subnet-name snet-web --subnet-prefixes 10.20.1.0/24 az network vnet subnet create -g rg-net --vnet-name vnet-app \ -n snet-db --address-prefixes 10.20.2.0/24 az network nsg create -g rg-net -n nsg-web az network nsg rule create -g rg-net --nsg-name nsg-web -n allow-https \ --priority 100 --direction Inbound --access Allow \ --protocol Tcp --destination-port-ranges 443 az network vnet subnet update -g rg-net --vnet-name vnet-app \ -n snet-web --network-security-group nsg-web
17

Peer two VNets in both directions with Azure CLI.

Save to ▾
Show answer
Peering must be created from each side. Allow forwarded traffic if a hub firewall routes it: az network vnet peering create -g rg-net -n hub-to-spoke1 \ --vnet-name vnet-hub --remote-vnet vnet-spoke1 \ --allow-vnet-access --allow-forwarded-traffic --allow-gateway-transit az network vnet peering create -g rg-net -n spoke1-to-hub \ --vnet-name vnet-spoke1 --remote-vnet vnet-hub \ --allow-vnet-access --allow-forwarded-traffic --use-remote-gateways
18

Create a route table that sends internet traffic to Azure Firewall.

Save to ▾
Show answer
Add a default route with next hop Virtual appliance pointing to the firewall private IP, then attach it to the spoke subnet: az network route-table create -g rg-net -n rt-spoke1 az network route-table route create -g rg-net \ --route-table-name rt-spoke1 -n default-to-fw \ --address-prefix 0.0.0.0/0 \ --next-hop-type VirtualAppliance --next-hop-ip-address 10.0.1.4 az network vnet subnet update -g rg-net --vnet-name vnet-spoke1 \ -n snet-app --route-table rt-spoke1
19

How do you plan IP address space for VNets in an enterprise?

Save to ▾
Show answer
Allocate from a central IP plan that does not overlap with on-premises, other clouds or future acquisitions, because overlapping ranges cannot be peered or routed. Give each region a large block, for example 10.10.0.0/14, then carve /22 or /24 spokes. Size subnets for growth and remember AKS, App Gateway and private endpoints consume many IPs. Document allocations in an IPAM tool such as Azure Virtual Network Manager IPAM.
20

Which Network Watcher tools do you use to troubleshoot connectivity?

Save to ▾
Show answer
IP flow verify tells you if an NSG rule allows or denies a specific packet and which rule matched. Next hop shows where routing sends traffic. Connection troubleshoot tests reachability from a VM to an endpoint. Effective security rules and effective routes show the combined result on a NIC. VNet flow logs record traffic for analysis with Traffic Analytics. Packet capture records traffic on a VM.
21

You are setting up Azure DNS for a new domain. What are the steps?

Save to ▾
Show answer
Create a public DNS zone in Azure DNS for the domain, note the four Azure name servers it shows, and update the NS records at your domain registrar to those servers. Add records such as an A alias record pointing to the Front Door or public IP and CNAME for www. Verify with nslookup. Apply a lock on the zone so records cannot be deleted accidentally.
22

Assign a role to a group at resource group scope with Azure CLI.

Save to ▾
Show answer
Look up the group object ID, then create the role assignment with the narrowest scope: GROUP_ID=$(az ad group show --group 'grp-shop-devs' --query id -o tsv) az role assignment create \ --assignee-object-id $GROUP_ID \ --assignee-principal-type Group \ --role Contributor \ --scope /subscriptions/<sub-id>/resourceGroups/rg-shop-dev Assigning to groups instead of users keeps access easy to audit.
23

Store and read a secret from Key Vault using Azure CLI.

Save to ▾
Show answer
Create an RBAC-enabled vault, grant yourself Key Vault Secrets Officer, then set and read the secret: az keyvault create -g rg-sec -n kv-shop-prod \ --location centralindia --enable-rbac-authorization true az keyvault secret set --vault-name kv-shop-prod \ --name SqlPassword --value 'S3cure#Pass' az keyvault secret show --vault-name kv-shop-prod \ --name SqlPassword --query value -o tsv
24

Write a Bicep snippet for a custom Azure Policy that denies resources outside India regions.

Save to ▾
Show answer
Define the rule with an allowed list and a deny effect, then assign it at a management group: resource pol 'Microsoft.Authorization/policyDefinitions@2023-04-01' = { name: 'allowed-india-regions' properties: { policyType: 'Custom' mode: 'Indexed' policyRule: { if: { field: 'location' notIn: ['centralindia', 'southindia', 'westindia'] } then: { effect: 'deny' } } } }
25

How do you reference Key Vault secrets in App Service app settings?

Save to ▾
Show answer
Enable a managed identity on the app, grant it Key Vault Secrets User on the vault, then set the app setting value to a Key Vault reference: @Microsoft.KeyVault(SecretUri=https://kv-shop-prod.vault.azure.net/secrets/SqlPassword/). The app reads it as a normal environment variable. Omitting the version makes App Service pick up rotated secrets automatically within about a day, or on restart.
26

How do you create a custom RBAC role?

Save to ▾
Show answer
Export a similar built-in role as JSON, keep only needed Actions and DataActions, set AssignableScopes and create it: az role definition list --name 'Virtual Machine Contributor' > vm-op.json # edit: Name 'VM Operator', Actions: # Microsoft.Compute/virtualMachines/read # Microsoft.Compute/virtualMachines/start/action # Microsoft.Compute/virtualMachines/restart/action # Microsoft.Compute/virtualMachines/deallocate/action az role definition create --role-definition vm-op.json
27

How do you choose a partition key in Cosmos DB?

Save to ▾
Show answer
Pick a property with high cardinality that spreads requests and storage evenly and that most queries filter on, such as userId or tenantId. Each logical partition is limited to 20 GB, so avoid keys like country or status that create hot partitions. If no single property works, use a synthetic key or hierarchical partition keys. The partition key cannot be changed later without migrating data.
28

Create an Azure SQL Database with Entra-only authentication using Azure CLI.

Save to ▾
Show answer
Create the logical server with an Entra admin group and no SQL logins, then the database: az sql server create -g rg-data -n sql-shop-prod -l centralindia \ --enable-ad-only-auth \ --external-admin-principal-type Group \ --external-admin-name grp-sql-admins \ --external-admin-sid <group-object-id> az sql db create -g rg-data -s sql-shop-prod -n shopdb \ --edition GeneralPurpose --family Gen5 --capacity 2 \ --zone-redundant true --backup-storage-redundancy Zone
29

How do you let an App Service connect to Azure SQL using its managed identity?

Save to ▾
Show answer
Enable the app's managed identity, then in the database, connected as an Entra admin, create a user for it and grant roles: CREATE USER [app-shop-prod] FROM EXTERNAL PROVIDER; ALTER ROLE db_datareader ADD MEMBER [app-shop-prod]; ALTER ROLE db_datawriter ADD MEMBER [app-shop-prod]; Use a connection string with Authentication=Active Directory Default, so no password is stored anywhere.
30

Write a Cosmos DB NoSQL query to get a customer's orders above 5000 rupees.

Save to ▾
Show answer
Filter on the partition key so the query hits one partition and stays cheap: SELECT c.id, c.orderDate, c.total FROM c WHERE c.customerId = @customerId AND c.total > 5000 ORDER BY c.orderDate DESC ORDER BY on orderDate needs a range index, which the default indexing policy includes. Check the RU charge in the response headers.
31

How do you migrate an on-premises SQL Server database to Azure SQL Managed Instance?

Save to ▾
Show answer
Assess with Azure Migrate or the Azure SQL migration extension in Azure Data Studio to find compatibility issues and size the target. For minimal downtime, use the Managed Instance link or Log Replay Service to continuously replicate, then cut over in minutes. For smaller databases, an offline native backup to Blob Storage and RESTORE FROM URL works. Test application connectivity and performance before switching.
32

How do you find and fix slow queries in Azure SQL Database?

Save to ▾
Show answer
Open Query Performance Insight or Query Store to find the top queries by CPU, duration and IO. Check execution plans for scans, missing indexes and parameter sniffing. Review automatic tuning recommendations to create indexes or force the last good plan. Query DMVs like sys.dm_exec_query_stats and sys.dm_db_resource_stats. If resources are maxed after tuning, scale up or add read replicas.
33

How do you manage Terraform state securely on Azure?

Save to ▾
Show answer
Store state in an Azure Storage backend with a dedicated container per environment. Blob leases provide state locking so two runs cannot write at once. Use Entra ID authentication instead of access keys, enable versioning and soft delete to recover from corruption, restrict access to the pipeline identity, and use private endpoints. Never commit state files, because they can contain secrets in plain text.
34

Write a Bicep file that creates a storage account with parameters.

Save to ▾
Show answer
Parameters keep the template reusable across environments: param location string = resourceGroup().location @minLength(3) @maxLength(24) param name string @allowed(['Standard_LRS', 'Standard_ZRS']) param sku string = 'Standard_ZRS' resource st 'Microsoft.Storage/storageAccounts@2023-05-01' = { name: name location: location sku: { name: sku } kind: 'StorageV2' properties: { minimumTlsVersion: 'TLS1_2' allowBlobPublicAccess: false supportsHttpsTrafficOnly: true } } output blobEndpoint string = st.properties.primaryEndpoints.blob
35

Deploy a Bicep file and preview changes with Azure CLI.

Save to ▾
Show answer
Run what-if first, then deploy with a parameters file: az deployment group what-if \ --resource-group rg-shop-dev \ --template-file main.bicep \ --parameters main.dev.bicepparam az deployment group create \ --resource-group rg-shop-dev \ --template-file main.bicep \ --parameters main.dev.bicepparam Use az deployment sub create for subscription-scope templates.
36

Write an Azure Pipelines YAML that builds a .NET app and deploys it to App Service.

Save to ▾
Show answer
Build and publish an artifact, then deploy in a stage tied to an environment with approvals: trigger: branches: { include: [main] } pool: { vmImage: ubuntu-latest } stages: - stage: Build jobs: - job: build steps: - script: dotnet publish -c Release -o $(Build.ArtifactStagingDirectory) - publish: $(Build.ArtifactStagingDirectory) artifact: app - stage: Deploy jobs: - deployment: web environment: prod strategy: runOnce: deploy: steps: - task: AzureWebApp@1 inputs: azureSubscription: sc-shop-prod appName: app-shop-prod package: $(Pipeline.Workspace)/app
37

Write a GitHub Actions job that logs in to Azure with OIDC.

Save to ▾
Show answer
Grant id-token write permission and use a federated credential on the app registration, so no secret is stored: permissions: id-token: write contents: read jobs: deploy: runs-on: ubuntu-latest environment: prod steps: - uses: actions/checkout@v4 - uses: azure/login@v2 with: client-id: ${{ vars.AZURE_CLIENT_ID }} tenant-id: ${{ vars.AZURE_TENANT_ID }} subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} - run: az group list -o table
38

Write a basic Terraform configuration for a resource group and VNet with remote state.

Save to ▾
Show answer
Configure the azurerm backend and provider, then resources: terraform { backend "azurerm" { resource_group_name = "rg-tfstate" storage_account_name = "sttfstateprod" container_name = "state" key = "network.tfstate" use_azuread_auth = true } } provider "azurerm" { features {} } resource "azurerm_resource_group" "net" { name = "rg-net-prod" location = "centralindia" } resource "azurerm_virtual_network" "hub" { name = "vnet-hub" location = azurerm_resource_group.net.location resource_group_name = azurerm_resource_group.net.name address_space = ["10.0.0.0/16"] }
39

How do you build and push a container image to ACR without Docker installed?

Save to ▾
Show answer
Use ACR Tasks to build in the cloud from your source folder: az acr build --registry acrshopprod \ --image shop-api:$(git rev-parse --short HEAD) . ACR Tasks can also rebuild automatically on a Git commit or when the base image is updated, which helps patch OS vulnerabilities without manual work.
40

Write a KQL query for the top 10 slowest requests in Application Insights over the last day.

Save to ▾
Show answer
Query the requests table, summarise duration and sort: requests | where timestamp > ago(1d) | summarize count(), avgDuration = avg(duration), p95 = percentile(duration, 95) by name | top 10 by p95 desc In a workspace-based resource, the table is AppRequests with TimeGenerated and DurationMs columns instead.
41

Write a KQL query to find who deleted resources in the last 7 days.

Save to ▾
Show answer
Use the AzureActivity table, filtering on successful delete operations: AzureActivity | where TimeGenerated > ago(7d) | where OperationNameValue endswith '/DELETE' | where ActivityStatusValue == 'Success' | project TimeGenerated, Caller, OperationNameValue, ResourceGroup, _ResourceId | order by TimeGenerated desc
42

Write a KQL query to find VMs with average CPU above 80% in the last hour.

Save to ▾
Show answer
Query the Perf table collected by the Azure Monitor Agent, or InsightsMetrics with VM Insights: Perf | where TimeGenerated > ago(1h) | where ObjectName == 'Processor' and CounterName == '% Processor Time' | where InstanceName == '_Total' | summarize avgCpu = avg(CounterValue) by Computer | where avgCpu > 80 | order by avgCpu desc
43

Write a Resource Graph query to list unattached managed disks.

Save to ▾
Show answer
Unattached disks keep billing, so this is a common cost check: Resources | where type =~ 'microsoft.compute/disks' | where properties.diskState =~ 'Unattached' | project name, resourceGroup, subscriptionId, sku = sku.name, sizeGb = properties.diskSizeGB Run it with az graph query -q or in the Resource Graph Explorer.
44

How do you create a budget with alerts for a subscription?

Save to ▾
Show answer
In Cost Management, choose Budgets, set the scope to the subscription or a resource group, a monthly amount and alert conditions such as 50%, 80% and 100% of actual cost and 100% of forecast. Add email recipients and an action group that can notify Teams or run an automation. Budgets do not stop spending on their own, so pair them with automation or policy if needed.
45

How do you enable diagnostic settings at scale for all resources?

Save to ▾
Show answer
Use Azure Policy with deployIfNotExists definitions, such as the built-in initiatives for enabling resource logs to a Log Analytics workspace by category group. Assign them at the management group, create a remediation task for existing resources and let new resources be configured automatically. This avoids teams forgetting to enable logs, which is common when resources are created outside the pipeline.

Frequently asked questions

Why are practical questions important?

Most technical rounds include at least one live task. Practising the exact typing and reasoning makes you calm and fast in the real round.

How should I answer them?

Talk while you work: say your approach first, write the simplest correct version, then improve it and mention edge cases.