Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Lesson2 / 9

    Relational Data: Azure SQL & PostgreSQL

    Start with the failure

    An API sends COMMIT to Azure SQL, loses the connection, and receives no acknowledgment. Retrying the purchase with a new operation ID might charge twice. Explain what is known, what is unknown, and what the retry strategy must preserve.

    Separate availability from transaction knowledge

    ObservationSafe conclusionNext design step
    Connection drops before the client learns the commit resultCommit outcome can be unknownReconcile using a stable business/operation identity
    A failover-group listener keeps its DNS nameClients can use the same configured nameReconnect; handle DNS/connection changes and uncertain transactions
    A geo-secondary is asynchronousThe latest commits might not be there after forced failoverChoose and test an explicit RPO/RTO runbook
    An EF execution strategy retries transient faultsEligible operations can execute againKeep the unit replay-safe; place an explicit transaction inside the strategy

    Interview reference

    Question 8. Compare Azure SQL Database, SQL Managed Instance, and SQL Server on a VM.

    Azure SQL Database is fully managed PaaS for a single database or elastic pool — Microsoft handles patching, backups, and HA; best for new cloud apps. SQL Managed Instance is also PaaS but offers near-100% SQL Server compatibility (SQL Agent, cross-database queries, CLR, Service Broker) and native VNet deployment — ideal for lift-and-shift of existing SQL Server workloads. SQL Server on a VM is IaaS: full control and 100% compatibility, but you manage OS, patching, and HA yourself. Use these as starting choices, then assess feature, version/edition, network and operational requirements. Managed Instance has documented T-SQL and instance-feature differences; near-100% compatibility is not a guarantee of zero migration changes. A VM preserves SQL Server control, but compatibility still depends on the installed version/edition and OS. MI differences.

    Question 9. Explain the DTU vs vCore purchasing models for Azure SQL.

    A DTU blends CPU, memory and read/write I/O capacity; the DTU purchasing packages also include storage allowances across Basic/Standard/Premium tiers — simple, good for predictable small/medium workloads, with less resource flexibility than vCore, although extra storage can be provisioned within tier limits without increasing DTUs. vCore lets you choose vCores and hardware configuration (which determines memory), and scale storage separately within tier limits, gives transparency into the hardware, offers Azure Hybrid Benefit for eligible provisioned compute/licensing, and includes Hyperscale and serverless options. Azure Hybrid Benefit does not apply to serverless compute. Serverless billing.

    vCore gives more explicit resource choices; choose between the models using workload measurements, supported tiers and total cost rather than treating DTU as unsuitable for every other workload. Serverless is a vCore compute option, not a separate purchasing model.

    Question 10. What are elastic pools and the vCore service tiers (General Purpose, Business Critical, Hyperscale)?

    Elastic pools let many databases share a common pool of resources, smoothing cost when individual databases have spiky, uncorrelated load (great for SaaS multi-tenant — one DB per tenant). You pay for the pool, not each DB's peak. For Azure SQL Database (not the entire Azure SQL family), the vCore service tiers are: General Purpose (remote SSD storage, balanced cost — most workloads); Business Critical (local SSD + always-on replicas for lowest latency and fast failover, plus an included read-only replica endpoint); and Hyperscale (decoupled storage, snapshot-based backups and read replicas). A single Hyperscale database currently supports up to 128 TB, while one in a Hyperscale elastic pool supports up to 100 TB; limits and replica costs depend on the offering. Hyperscale FAQ.

    Choose General Purpose by default, Business Critical for latency-sensitive/high-availability OLTP, and Hyperscale for very large databases or fast scaling needs.

    Question 11. How does high availability and disaster recovery work in Azure SQL — geo-replication vs failover groups?

    Azure SQL Database has built-in local HA; zone redundancy depends on tier, region and configuration. Cross-region recovery is separate. Active geo-replication supports up to four asynchronously replicated readable secondaries, with customer-initiated database failover. Failover groups coordinate databases and provide stable listener names; choose a customer-managed or Microsoft-managed failover policy. Microsoft-managed failover is not an instant response to every database outage: it requires a qualifying regional event and the configured grace period (at least an hour). Forced failover may lose unreplicated commits; failback is customer-initiated. Current guidance recommends customer-managed policy for control over recovery decisions. Choose according to RPO/RTO and test the runbook. Managed Instance has its own instance-level failover-group model; do not apply every SQL Database detail unchanged. SQL Database failover groups.

    Example

    Apps use the failover-group listener rather than a specific server, so its configured DNS name stays the same. Existing connections can break: clients must reconnect/retry, handle DNS changes and reconcile uncertain transactions. A stable listener is not a guarantee of zero downtime or data loss.

    Question 12. What is Azure Database for PostgreSQL Flexible Server, and why is it a common choice?

    Flexible Server is the current managed PostgreSQL offering, offering optional same-zone or zone-redundant HA on supported tiers/regions, configurable maintenance windows, burstable (B-series) SKUs for cost-sensitive workloads, custom server parameters, and VNet integration / private access. It replaces the older Single Server model, which was retired on March 28, 2025.

    It's popular for cost-effective, open-source-stack apps: a small burstable instance (e.g. B1ms) runs dev/low-traffic workloads cheaply. Choose appropriate capacity/HA for production. Burstable does not support HA, so enabling HA requires a supported compute tier; zone redundancy also needs regional support. .NET apps connect through Npgsql. Managed-identity login requires Entra authentication configured on the server, a mapped database principal with appropriate grants, and token acquisition/refresh for new connections—not merely enabling an identity on the client. PostgreSQL HA, managed-identity connection.

    Question 13. How do you make .NET data access resilient to transient SQL faults?

    Cloud databases occasionally throw transient errors (failovers, throttling, brief network drops), so use bounded retries with backoff for recognized transient faults when replay is safe; do not retry every error indiscriminately. EF Core has this built in via an execution strategy (EnableRetryOnFailure), which retries queries and SaveChanges on recognized transient failures; it does not make side effects idempotent, and a lost commit acknowledgment needs an explicit recovery strategy. For ADO.NET/Dapper, use a suitable driver or resilience policy (such as Polly) targeting transient failures, with cancellation, an overall time budget and safe replay. Avoid multiplying retries across layers. Be careful with explicit transactions under retrying strategies — you must wrap the whole unit in strategy.ExecuteAsync(...) so a retry re-runs the entire transaction, not a partial one. Set sensible command timeouts and use connection pooling. Retrying execution strategies may internally buffer query results, so account for memory on large queries. EF Core connection resiliency.

    Example

    C#
    services.AddDbContext<AppDb>(o =>
     o.UseSqlServer(conn, sql =>
     sql.EnableRetryOnFailure(
     maxRetryCount: 5, maxRetryDelay: TimeSpan.FromSeconds(10),
     errorNumbersToAdd: null)));

    Question 14. What options exist for securing data in Azure SQL (auth, network, encryption)?

    Authentication: prefer Microsoft Entra authentication with a managed identity over SQL logins, so there's no password to leak. For Azure SQL Database networking (Managed Instance networking differs): a private endpoint provides private IP connectivity; configure private DNS/routing and explicitly disable public network access when that is the intended boundary. Creating the endpoint alone does not disable the public endpoint. VNet service endpoints plus firewall rules restrict access through the service's public endpoint; they are not equivalent to Private Link. Private Link. Encryption: data is encrypted at rest by default (Transparent Data Encryption) and in transit (TLS); Always Encrypted (client-side encryption) can protect sensitive columns even from DBAs who lack the keys. Separately, Dynamic Data Masking obscures results for unprivileged users; it is not encryption or a barrier against privileged administrators.

    Layer these — identity-based auth + private networking + TDE + column-level protection — and audit with SQL auditing and Microsoft Defender for SQL.

    Check your decision

    After a connection loss during COMMIT, which retry design best avoids creating a second logical purchase?

    A Retry with a new purchase ID because the first call threw
    B Disable all timeouts so a result can never be uncertain
    C Assume a stable failover-group listener means the transaction rolled back
    D Reuse a durable business-operation identity and reconcile the original outcome before duplicating its effect
    Show answer

    Correct answer: D

    A failed acknowledgment does not establish rollback. A stable operation identity supports checking or enforcing one logical purchase across replay. Retry configuration and a stable listener improve recovery, but neither proves the first transaction failed.

    Hint: Distinguish the database outcome from the client’s knowledge of it.

    Practice before reading the answers

    1. Choose a starting Azure SQL option for an application that depends on SQL Agent and cross-database instance features. What must be checked before calling it a zero-change migration?
    1. An elastic pool hosts many tenants whose peaks all occur at 09:00. What assumption behind the expected pooling saving is weak?

    Answer check

    1. Assess Managed Instance first, then check the actual feature/version, T-SQL differences, networking, compatibility and operational requirements. The VM option retains more control when a concrete unsupported requirement needs it.
    1. The peaks are correlated. The pool must still serve the simultaneous demand; measure the combined workload and per-database limits rather than summing imaginary independent savings.
    Sign in to mark lessons done and keep your place in the course.Sign in

    TechInterviewNotes Editorial Team · Updated 28 Oct 2026 ·