CDN with custom domains in Azure - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When setting up a CDN with custom domains in Azure, it is important to understand how the time to configure and deploy grows as you add more custom domains.
We want to know how the number of custom domains affects the total operations needed.
Analyze the time complexity of the following operation sequence.
// Create a CDN profile
az cdn profile create --name MyCDNProfile --resource-group MyResourceGroup --location eastus
// Create a CDN endpoint
az cdn endpoint create --name MyCDNEndpoint --profile-name MyCDNProfile --resource-group MyResourceGroup --origin www.example.com
// For each custom domain, add it to the CDN endpoint
foreach domain in customDomains:
az cdn custom-domain create --endpoint-name MyCDNEndpoint --profile-name MyCDNProfile --resource-group MyResourceGroup --hostname domain
This sequence creates a CDN profile and endpoint, then adds multiple custom domains to the endpoint.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Adding each custom domain to the CDN endpoint via the
az cdn custom-domain createcommand. - How many times: Once for each custom domain you want to add.
Each custom domain requires a separate API call to add it to the CDN endpoint. So, as you add more domains, the total number of calls grows directly with the number of domains.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 calls to add custom domains |
| 100 | 100 calls to add custom domains |
| 1000 | 1000 calls to add custom domains |
Pattern observation: The number of operations grows linearly as you add more custom domains.
Time Complexity: O(n)
This means the time to add custom domains grows directly in proportion to how many domains you add.
[X] Wrong: "Adding multiple custom domains is a single operation regardless of how many domains there are."
[OK] Correct: Each custom domain requires its own API call and configuration step, so the total time grows with the number of domains.
Understanding how operations scale with input size helps you design efficient cloud deployments and explain your reasoning clearly in interviews.
What if we batch multiple custom domains in a single API call? How would the time complexity change?
Practice
Solution
Step 1: Understand CDN default behavior
Azure CDN provides a default URL for content delivery, but it uses a generic domain name.Step 2: Purpose of custom domain
Using a custom domain lets you serve content with your own website address, improving branding and user trust.Final Answer:
To deliver content using your own website address instead of the default CDN URL -> Option AQuick Check:
Custom domain = Own website address [OK]
- Thinking custom domain increases storage
- Assuming custom domain reduces cost
- Believing custom domain disables HTTPS
Solution
Step 1: Identify DNS record for domain aliasing
CNAME records map one domain name to another, which is needed to point your custom domain to the CDN endpoint.Step 2: Exclude other DNS record types
MX is for mail, TXT for text info, SRV for service location, none suitable for domain aliasing.Final Answer:
CNAME record -> Option AQuick Check:
Custom domain uses CNAME DNS record [OK]
- Using MX record for domain mapping
- Confusing TXT record with CNAME
- Trying to use SRV record for CDN
az cdn custom-domain create --endpoint-name myEndpoint --profile-name myProfile --resource-group myGroup --hostname www.example.com
Solution
Step 1: Understand DNS validation in Azure CDN
Azure CDN requires DNS validation to confirm ownership of the custom domain via CNAME record.Step 2: Effect of missing or incorrect DNS record
If the CNAME record is missing or incorrect, the command fails with a DNS validation error to prevent misconfiguration.Final Answer:
The command will fail with a DNS validation error -> Option DQuick Check:
Missing CNAME causes DNS validation error [OK]
- Assuming CDN auto-creates DNS records
- Thinking custom domain adds without DNS setup
- Believing HTTPS disables if DNS is wrong
Solution
Step 1: Check HTTPS enablement for custom domain
Azure CDN requires explicit enabling of HTTPS on custom domains to serve secure content.Step 2: Exclude other causes
CDN endpoints support HTTPS, A record usage causes DNS issues but not HTTPS directly, region mismatch does not block HTTPS.Final Answer:
You forgot to enable HTTPS on the custom domain in the CDN settings -> Option CQuick Check:
HTTPS must be enabled on custom domain [OK]
- Assuming HTTPS is automatic
- Blaming region mismatch for HTTPS failure
- Using A record instead of CNAME but ignoring HTTPS setting
Solution
Step 1: Setup CDN profile and endpoint with custom domain
Create a CDN profile and endpoint, then add your custom domain using a CNAME DNS record for proper domain mapping.Step 2: Enable HTTPS and use global CDN POPs
Enable HTTPS using Azure-managed certificates for security and scalability, and leverage multiple CDN Points of Presence (POPs) worldwide to handle global traffic efficiently.Final Answer:
Create a CDN profile and endpoint, add your custom domain with a CNAME DNS record, enable HTTPS with Azure-managed certificates, and use multiple CDN POPs worldwide -> Option BQuick Check:
Custom domain + CNAME + HTTPS + global POPs = Best practice [OK]
- Using A record instead of CNAME
- Disabling HTTPS to save latency
- Skipping DNS changes for custom domains
- Relying on single CDN POP for global scale
