App Service: plans, scaling, custom domains, TLS, backups and networking
Azure App Service runs web apps and APIs from code or a container without any VM you can see: you choose a runtime (Node, Python, .NET, Java, PHP) or an image, push your code, and get https://<name>.azurewebsites.net with TLS, logging and deployments handled. It is still the most common way companies run plain web workloads on Azure, and the source of a whole class of tickets: the custom domain that will not verify, the certificate that expired, the app that cannot reach the private database, the plan nobody remembers paying for. AZ-104 gives it a skill group of its own.
Need to know: the App Service plan is the compute - region, OS, tier, instance size and instance count - and every app in a plan runs on all of its instances. Tiers: Free/Shared (no custom domain TLS, no scale out), Basic (dedicated, up to 3 instances, custom domains and TLS, manual scale only), Standard (up to 10 instances, autoscale, deployment slots), Premium v3 (up to 30, more slots, zone redundancy), Isolated v2 (an App Service Environment in your VNet). Scale up = a bigger tier/size; scale out = more instances. A custom domain is proved with a TXT record asuid.<host> holding the app's verification ID plus a CNAME (subdomain) or A record (apex). Managed certificates are free and renew themselves. Access restrictions and private endpoints control traffic into the app; VNet integration carries traffic out of it.
Plans and tiers
$ az appservice plan create -g rg-az5-web -n plan-shop --sku B1 --is-linux -o table
ElasticScaleEnabled GeoRegion HyperV IsSpot IsXenon Kind Location MaximumElasticWorkerCount MaximumNumberOfWorkers Name NumberOfSites NumberOfWorkers PerSiteScaling ProvisioningState Reserved ResourceGroup Status Subscription TargetWorkerCount TargetWorkerSizeId ZoneRedundant
------------------- ----------- ------ ------ ------- ----- ---------- ------------------------- ---------------------- --------- ------------- --------------- -------------- ----------------- -------- ------------- ------ ------------------------------------ ----------------- ------------------ -------------
False West Europe False False False linux westeurope 1 3 plan-shop 0 1 False Succeeded True rg-az5-web Ready 00000000-1111-2222-3333-444444444444 0 0 False
$ az webapp create -g rg-az5-web -n shop-az5-01 -p plan-shop --runtime NODE:22-lts --query "{host:defaultHostName, state:state, https:httpsOnly}" -o json
{
"host": "shop-az5-01.azurewebsites.net",
"https": false,
"state": "Running"
}
$ curl -sI https://shop-az5-01.azurewebsites.net/ | head -1
HTTP/1.1 200 OK
The plan is what you pay for (per instance per hour, whether its apps are busy or not); the app is free inside it. Five small apps in one plan cost one plan. Use separate plans for apps that need their own scaling, their own tier, or must not be taken down by a noisy neighbour. A plan's OS is fixed (--is-linux), its region is fixed, and the app name is a global DNS name.
| tier | instances (max) | custom domain + TLS | autoscale | slots | notes |
|---|---|---|---|---|---|
| Free F1 | shared | - | - | - | 60 CPU minutes a day, for tests |
| Basic B1-B3 | 3 | yes | - (manual scale out) | - | dedicated VMs, Always On |
| Standard S1-S3 | 10 | yes | yes | 5 | daily backups, the production minimum |
| Premium v3 | 30 | yes | yes | 20 | faster hardware, zone redundancy |
| Isolated v2 | 100 | yes | yes | 20 | single-tenant App Service Environment in your VNet |
The limits are enforced, and the errors are useful:
$ az appservice plan update -g rg-az5-web -n plan-shop --number-of-workers 4
ERROR: (BadRequest) (simulator) The Basic tier allows at most 3 instances per App Service plan; 4 were requested. Scale up to a higher tier for more.
Code: BadRequest
Message: (simulator) The Basic tier allows at most 3 instances per App Service plan; 4 were requested. Scale up to a higher tier for more.
$ az webapp deployment slot create -g rg-az5-web -n shop-az5-01 --slot staging
ERROR: (Conflict) There was a conflict. The site shop-az5-01 does not allow deployment slots: its App Service plan plan-shop is in the Basic tier. Scale up to Standard or Premium to use slots.
Code: Conflict
Message: There was a conflict. The site shop-az5-01 does not allow deployment slots: its App Service plan plan-shop is in the Basic tier. Scale up to Standard or Premium to use slots.
Scaling up and out
Scale up changes the tier or size - for features (slots, autoscale) or bigger instances. The apps restart onto the new hardware, a short blip:
$ az appservice plan update -g rg-az5-web -n plan-shop --sku S1 --query "{tier:sku.tier, size:sku.name, instances:sku.capacity}" -o json
{
"instances": 1,
"size": "S1",
"tier": "Standard"
}
Scale out adds instances, either by hand (--number-of-workers) or with autoscale, which works exactly like the scale set's: an autoscale setting on the plan, rules on its metrics (CpuPercentage, MemoryPercentage, HttpQueueLength), min/max/default, cooldown:
$ az appservice plan update -g rg-az5-web -n plan-shop --number-of-workers 2 --query sku.capacity
2
$ az monitor autoscale create -g rg-az5-web --resource plan-shop --resource-type Microsoft.Web/serverfarms -n as-shop --min-count 2 --max-count 6 --count 2 -o none
$ az monitor autoscale rule create -g rg-az5-web --autoscale-name as-shop --condition "CpuPercentage > 70 avg 10m" --scale out 1 -o none
$ az monitor autoscale rule create -g rg-az5-web --autoscale-name as-shop --condition "CpuPercentage < 30 avg 20m" --scale in 1 -o none
$ az monitor autoscale rule list -g rg-az5-web --autoscale-name as-shop -o table
ID Metric Operator Threshold Aggregation Time Window Direction Value Cooldown
-- ------------- ----------- --------- ----------- ----------- --------- ----- --------
0 CpuPercentage GreaterThan 70 Average PT10M Increase 1 PT5M
1 CpuPercentage LessThan 30 Average PT20M Decrease 1 PT5M
All apps in the plan run on every instance (unless per-app scaling pins one to fewer). An app that keeps state in memory or on local disk behaves differently on 2 instances than on 1: requests land on either (ARR affinity, a cookie, keeps a browser on one - turn it off for stateless APIs).
A custom domain, proved
shop-az5.example is the shop's domain, hosted in an Azure DNS zone (the DNS part of this chapter explains zones and delegation). To serve www.shop-az5.example from the app, App Service must see proof that you control the name:
$ az network dns zone create -g rg-az5-web -n shop-az5.example -o none
$ az webapp config hostname add -g rg-az5-web --webapp-name shop-az5-01 --hostname www.shop-az5.example
ERROR: (BadRequest) A TXT record pointing from asuid.www.shop-az5.example to C2DB3814BF5C4DD38E7C233745D7F5E973162D3F30014135B46DAAD020F030D9 was not found.
Code: BadRequest
Message: A TXT record pointing from asuid.www.shop-az5.example to C2DB3814BF5C4DD38E7C233745D7F5E973162D3F30014135B46DAAD020F030D9 was not found.
The error says exactly what is missing: a TXT record asuid.www whose value is the app's custom domain verification ID (one per subscription, the same for all your apps). Then the CNAME that sends traffic:
$ VID=$(az webapp show -g rg-az5-web -n shop-az5-01 --query customDomainVerificationId -o tsv)
$ az network dns record-set txt add-record -g rg-az5-web -z shop-az5.example -n asuid.www -v $VID -o none
$ az network dns record-set cname set-record -g rg-az5-web -z shop-az5.example -n www -c shop-az5-01.azurewebsites.net -o none
$ dig +short www.shop-az5.example
shop-az5-01.azurewebsites.net.
waws-prod-am2-507.sip.azurewebsites.windows.net.
20.105.31.80
$ az webapp config hostname add -g rg-az5-web --webapp-name shop-az5-01 --hostname www.shop-az5.example -o table
AzureResourceName AzureResourceType CustomHostNameDnsRecordType HostNameType Name ResourceGroup SiteName SslState
----------------- ----------------- --------------------------- ------------ -------------------------------- ------------- ----------- --------
shop-az5-01 Website CName Verified shop-az5-01/www.shop-az5.example rg-az5-web shop-az5-01 Disabled
For the apex (shop-az5.example itself) a CNAME is not allowed by DNS: use an A record to the app's inbound IP (az webapp config hostname get-external-ip) - or an Azure DNS alias record - plus asuid.shop-az5.example. The TXT record also lets you add the name before switching the CNAME, so a migration has no gap.
TLS: certificates and bindings
The name is bound, but HTTPS on it is not:
$ curl -sv https://www.shop-az5.example/ 2>&1 | grep -E "subject:|no alternative"
* subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; CN=*.azurewebsites.net
* SSL: no alternative certificate subject name matches target host name 'www.shop-az5.example'
* SSL: no alternative certificate subject name matches target host name 'www.shop-az5.example'
App Service answered with its *.azurewebsites.net certificate, which does not cover your name. Every custom hostname needs a certificate bound to it. Options:
- an App Service managed certificate: free, issued and renewed by Azure, Basic tier and up; not for wildcards, not exportable;
- a certificate you upload (PFX) or import from Key Vault (renewal is yours; Key Vault can automate it with a supported CA);
- an App Service certificate you buy through Azure (stored in Key Vault).
The binding type: SNI SSL (the normal one; the client sends the hostname in the handshake) or IP based SSL (a dedicated IP address, for very old clients; Standard and up, costs extra).
$ az webapp config ssl create -g rg-az5-web -n shop-az5-01 --hostname www.shop-az5.example --query "{subject:subjectName, expires:expirationDate}" -o json
{
"expires": "2027-03-21T20:00:17.400Z",
"subject": "www.shop-az5.example"
}
$ THUMB=$(az webapp config ssl list -g rg-az5-web --query "[?subjectName=='www.shop-az5.example'].thumbprint | [0]" -o tsv)
$ az webapp config ssl bind -g rg-az5-web -n shop-az5-01 --certificate-thumbprint $THUMB --ssl-type SNI -o none
$ az webapp config hostname list -g rg-az5-web --webapp-name shop-az5-01 -o table
Name ResourceGroup Thumbprint SslState
----------------------------- ------------- ---------------------------------------- ----------
shop-az5-01.azurewebsites.net rg-az5-web
www.shop-az5.example rg-az5-web A2992F1C1A59479796022D221F8000F7AAAAAAAA SniEnabled
$ curl -sv https://www.shop-az5.example/ 2>&1 | grep -E "subject:|HTTP/1.1 [0-9]"
* subject: CN=www.shop-az5.example
< HTTP/1.1 200 OK
Two settings every production app should have, and the exam's favourites:
$ az webapp update -g rg-az5-web -n shop-az5-01 --https-only true --query httpsOnly
true
$ az webapp config set -g rg-az5-web -n shop-az5-01 --min-tls-version 1.2 --query minTlsVersion
"1.2"
$ curl -sI http://www.shop-az5.example/ | head -2
HTTP/1.1 301 Moved Permanently
Date: Tue, 22 Sep 2026 20:00:18 GMT
HTTPS Only redirects plain HTTP with a 301; the minimum TLS version refuses older handshakes.
Backups
App Service on Basic and above takes automatic backups every hour (content and configuration, up to 30 GB, kept 30 days, not downloadable, restorable from the portal or az webapp config snapshot restore). Custom backups go to your storage account: on demand or on a schedule (every 2 hours at the most often), up to 10 GB, kept 0-30 days or indefinitely, downloadable ZIP files. They need a container URL with a SAS that allows writing (managed identity is not supported for backups):
$ az webapp config snapshot list -g rg-az5-web -n shop-az5-01 --query "[0:2]" -o table
Time
----------------------------
2026-09-22T20:00:00.0000000Z
2026-09-22T19:00:00.0000000Z
$ SAS=$(az storage container generate-sas --account-name stwebbak5 -n webbackups --permissions racwdl --expiry 2027-12-31 --auth-mode key -o tsv 2>/dev/null)
$ az webapp config backup create -g rg-az5-web --webapp-name shop-az5-01 --backup-name before-release --container-url "https://stwebbak5.blob.core.windows.net/webbackups?$SAS" --query "{status:status, log:log}" -o json
{
"log": null,
"status": "Succeeded"
}
$ az webapp config backup update -g rg-az5-web --webapp-name shop-az5-01 --container-url "https://stwebbak5.blob.core.windows.net/webbackups?$SAS" --frequency 4h --retention 14 --query backupSchedule -o json
{
"frequencyInterval": 4,
"frequencyUnit": "Hour",
"keepAtLeastOneBackup": false,
"lastExecutionTime": null,
"retentionPeriodInDays": 14,
"startTime": "2026-09-22T20:00:23.400Z"
}
$ az webapp config backup list -g rg-az5-web --webapp-name shop-az5-01 -o table
BackupId Name Status Created SizeInBytes
-------- -------------- --------- ------------------------ -----------
1 before-release Succeeded 2026-09-22T20:00:18.400Z 4126
A backup does not restore custom domains' TLS bindings, managed identities, VNet integration, private endpoints or scale settings - those are infrastructure, kept in your templates. A restore stops the target app while it runs; restore into a slot and swap to avoid downtime. When the SAS expires, every scheduled backup fails with "Storage access failed": give the SAS a long expiry and an alert on failed backups.
Networking: in and out
App Service in the multi-tenant tiers does not live in your VNet. Traffic into the app:
- Access restrictions - an ordered allow/deny list by IP range, service tag (
AzureFrontDoor.Backend) or VNet subnet (through a service endpoint). The moment you add one Allow rule, everything else is denied. The SCM site (Kudu, deployments) has its own list, or uses the main one. - Private endpoint - a private IP for the app in your VNet; then turn off public access. Private DNS (
privatelink.azurewebsites.net) as in Azure II.
Traffic out of the app:
- VNet integration - the app's outbound calls leave through a delegated subnet (
Microsoft.Web/serverFarms, /28 minimum, /26 recommended, one per plan), so it reaches private IPs, private endpoints and peered networks. It does not make the app private. - a NAT gateway on that subnet gives a stable outbound IP (for a partner's allowlist).
$ az network vnet create -g rg-az5-web -n vnet-shop --address-prefixes 10.80.0.0/16 --subnet-name snet-apps --subnet-prefixes 10.80.1.0/26 -o none
$ az webapp vnet-integration add -g rg-az5-web -n shop-az5-01 --vnet vnet-shop --subnet snet-apps -o table
IsSwift Location Name ResourceGroup VnetResourceId
------- ---------- --------- ------------- -----------------------------------------------------------------------------------------------------------------------------------------------------
True westeurope vnet-shop rg-az5-web /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg-az5-web/providers/Microsoft.Network/virtualNetworks/vnet-shop/subnets/snet-apps
$ az network vnet subnet show -g rg-az5-web --vnet-name vnet-shop -n snet-apps --query "delegations[].serviceName" -o tsv
Microsoft.Web/serverFarms
$ az webapp config access-restriction add -g rg-az5-web -n shop-az5-01 --rule-name office --action Allow --ip-address 203.0.113.0/24 --priority 100 -o none
$ curl -s -o /dev/null -w "%{http_code}\n" https://www.shop-az5.example/
403
403: the office is allowed, so everyone else - including this box, 198.51.100.24 - is now denied. Add the box (or remove the rule) and it answers again:
$ az webapp config access-restriction add -g rg-az5-web -n shop-az5-01 --rule-name oncall-box --action Allow --ip-address 198.51.100.24/32 --priority 110 -o table
Action IpAddress Name Priority Tag Description
------ ---------------- ---------- ---------- ------- ---------------
Allow 203.0.113.0/24 office 100 Default
Allow 198.51.100.24/32 oncall-box 110 Default
Deny Any Deny all 2147483647 Deny all access
$ curl -s -o /dev/null -w "%{http_code}\n" https://www.shop-az5.example/
200
On the exam (AZ-104 3.4.1-3.4.7): pick the lowest tier that meets the requirements (slots or autoscale -> Standard; custom domain + TLS -> Basic; 20 slots or zone redundancy -> Premium v3; network isolation in your VNet -> Isolated); a custom domain = TXT asuid + CNAME (apex: A + TXT asuid); "free certificate that renews itself" = App Service managed certificate; "call a private database" = VNet integration; "only reachable privately" = private endpoint; "only from these IPs" = access restrictions.
In an interview: "Users get a certificate error on our custom domain after a migration. What do you check?" - "Whether the new app has the hostname bound with a certificate that covers it:
az webapp config hostname listshows the SSL state. If it's still serving the azurewebsites.net certificate, create or import the certificate and bind it with SNI. Then HTTPS Only and the minimum TLS version."