Architecture question on multi-cloud for .NET teams: the variants (active-active, cloud-per-workload, portable single cloud), real costs (lowest common denominator, egress, skills, security surface), when to avoid it, and how to keep code portable with ports and adapters, containers, OpenTelemetry, Terraform and exit plans.
I'd start with why. "Avoid lock-in" is a fear, not a requirement. Real drivers are regulatory resilience (for example APRA CPS 230), a customer or acquisition on the other cloud, or a service only one cloud has.
Most .NET teams should avoid active-active multi-cloud:
For availability, multi-region on one cloud (Australia East and Southeast, or Sydney and Melbourne) is cheaper and more reliable.
What I'd do is portable by design, single cloud in practice: containers, OpenTelemetry, standard protocols, ports and adapters with cloud SDKs only in adapters, Terraform, and an ADR that records each lock-in and its exit cost.
The trade-off: you buy optionality with complexity, so buy only as much as the business will pay for.
"I wouldn't say yes or no straight away. I'd ask what problem multi-cloud is meant to solve, because the answer changes the design. If it's fear of lock-in, the cheapest protection is portability and an exit plan, not running everything twice. If it's resilience, multi-region on one cloud usually gives more availability for much less effort. If it's regulation, say APRA CPS 230 expectations on operational resilience and material service providers, the regulator wants a credible, tested plan for a provider failure, which can be met without active-active. And if it's a customer or an acquired company on AWS, a workload-per-cloud split may be the honest answer.
For example, at [company] we were asked to [run the platform on both Azure and AWS]. I [estimated the cost of building and operating both], and the numbers were clear: [two IAM models, two network designs, double on-call, data egress of around $X a month, and we'd lose Service Bus sessions and Cosmos DB features we relied on]. We instead [stayed on Azure across Australia East and Southeast], kept the services in containers with OpenTelemetry, put storage, messaging and secrets behind interfaces owned by the domain, and wrote the infrastructure in Terraform. Then we [ran a portability drill, deploying one service to AWS in N days]. That gave leadership a measured exit cost instead of a fear.
The mistake I see is building an abstraction over every cloud service 'just in case'. You end up with a worse version of both clouds and still can't move, because the real lock-in is the data, the identity model and the operations knowledge, not the SDK calls. I'd rather use managed services fully, record each lock-in in an ADR with what leaving would cost, and keep the code portable where it's cheap."
| Variant | What it is | Typical driver | Cost |
|---|---|---|---|
| Active-active across clouds | Same workload live on Azure and AWS | Extreme availability claims, regulatory pressure | Very high: duplicated everything, data sync, lowest common denominator |
| Workload per cloud | Different systems on different clouds | Acquisitions, best-of-breed services, customer location | Medium: two platforms, but each workload uses its cloud fully |
| Single cloud, portable, exit plan | One cloud, designed to move if needed | Lock-in risk, negotiating leverage | Low: discipline and a periodic drill |
| Cost | Why |
|---|---|
| Lowest common denominator | You avoid Service Bus sessions, Cosmos DB, Step Functions, DynamoDB, because the other side lacks them |
| Skills and on-call | Engineers must know two IAM models, two network models and two sets of failure modes |
| Security surface | Two identity systems, two sets of policies, two audit trails to monitor (Essential Eight applies to both) |
| Egress | Moving data between clouds is charged per GB in both directions of a sync |
| Data consistency | Cross-cloud replication of a relational database is hard; one side is usually primary anyway |
| Tooling | Two IaC providers, two monitoring stacks unless you standardise |
| Layer | Cheap to keep portable | Expensive to keep portable |
|---|---|---|
| Compute | Containers (OCI images), Kubernetes or plain container platforms | Functions with cloud-specific triggers and bindings |
| Data | SQL Server or PostgreSQL, EF Core | Cosmos DB, DynamoDB, proprietary query languages |
| Messaging | AMQP, Kafka, abstraction over send/receive | Sessions, filters, scheduled messages, EventBridge rules |
| Observability | OpenTelemetry SDK and OTLP | Vendor agents and proprietary APIs |
| Identity | OIDC for users | Workload identity (managed identity vs IAM roles) is always cloud-specific |
| IaC | Terraform / OpenTofu (same tool, different providers) | Bicep or CloudFormation (one cloud each) |
A team asked to go active-active estimated [2.3x] infrastructure cost and [two extra engineers] for operations. They chose Azure across two Australian regions with a quarterly portability drill instead: deploying their order service to AWS ECS took [3 days], with the adapter swap and Terraform module changes measured and recorded in an ADR. Availability over the next year was [99.97%], above the SLO, at about [40%] of the multi-cloud estimate.
Checks whether the candidate can turn a fashionable mandate into a priced, risk-based decision and still keep .NET code reasonably portable.
Green flags
Red flags
Turn "avoid lock-in" into questions you can answer with numbers:
Whole-provider, all-region outages are rare; region and service outages are much more common and are solved inside one cloud.
Multi-cloud active-active only helps if the failover machinery itself is reliable. The extra moving parts (cross-cloud data replication, global DNS or traffic managers, two deployment pipelines) are new failure sources:
Single cloud, two regions:
users ββΆ Front Door / Route 53 ββ¬ββΆ Australia East (primary)
βββΆ Australia Southeast (secondary, geo-replicated DB)
Multi-cloud active-active:
users ββΆ third-party global DNS ββ¬ββΆ Azure Australia East ββ
βββΆ AWS Sydney ββ΄β cross-cloud data sync (custom, eventual)
The second picture needs conflict handling for writes on both sides, or a single primary database, in which case one cloud is still a single point of failure for writes.
Keep cloud SDKs at the edge. The domain owns small interfaces shaped by what it needs, not by what one SDK exposes:
Domain / Application ββusesβββΆ IDocumentStore, IMessagePublisher, ISecretProvider
β² β² β²
Adapters (one project per cloud): BlobDocumentStore ServiceBusPublisher KeyVaultSecrets
S3DocumentStore SnsPublisher SecretsManagerSecrets
Rules: interfaces are narrow (no GetBlobContainerClient leaking out), cloud types never appear in the domain, and each adapter has the same contract tests run against the real service or an emulator (Azurite, LocalStack) so a swap is verified.
Don't abstract what you would never move, and don't abstract features you deliberately use from one cloud. Record those in an ADR.
| Lock-in | Why it's sticky | Mitigation |
|---|---|---|
| Data gravity | Terabytes and egress fees; live migration needs replication | Open formats, standard engines, documented export |
| Identity | Managed identity vs IAM roles, Entra ID vs IAM Identity Center | Federate users with OIDC; workload identity is per cloud by nature |
| Networking and security | Private endpoints vs PrivateLink, NSGs vs security groups | IaC modules per cloud with the same intent |
| Operations knowledge | Runbooks, dashboards, on-call habits | OpenTelemetry, cloud-neutral runbook structure |
| Contracts | Committed spend, reserved instances, enterprise agreements | Align commitments with the exit horizon |
Both clouds have two Australian regions (Azure Australia East and Southeast, plus Australia Central for government; AWS Sydney and Melbourne), so data residency rarely forces multi-cloud. For APRA-regulated entities, CPS 230 (in force since 1 July 2025) expects management of material service provider risk and credible business continuity, including plans for a provider becoming unavailable. That is usually met with documented, tested exit and continuity plans, not by running everything on two providers. Government workloads look for IRAP-assessed services, and both providers have IRAP assessments covering many services.
Once or twice a year, pick one representative service and deploy it to the other cloud: build the image, swap the adapters, apply the Terraform module, run the contract and smoke tests, and measure the days spent. Put the result in the ADR. That converts "we could move" into evidence.
IDocumentStore and implement it twice, with Azurite and LocalStack, then run the same xUnit contract tests against both.Ports and adapters: the domain depends on a narrow interface; each cloud gets an adapter selected at start-up, and both pass the same contract tests.
// Orders.Application/Ports/IDocumentStore.cs: shaped by what the domain needs, not by an SDK.
namespace Orders.Application.Ports;
public interface IDocumentStore
{
Task SaveAsync(string key, Stream content, string contentType, CancellationToken ct);
Task<Stream?> OpenAsync(string key, CancellationToken ct);
}
// Orders.Infrastructure.Azure/BlobDocumentStore.cs and Orders.Infrastructure.Aws/S3DocumentStore.cs
using Amazon.S3;
using Amazon.S3.Model;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Orders.Application.Ports;
namespace Orders.Infrastructure;
public sealed class BlobDocumentStore(BlobContainerClient container) : IDocumentStore
{
public async Task SaveAsync(string key, Stream content, string contentType, CancellationToken ct) =>
await container.GetBlobClient(key).UploadAsync(content,
new BlobUploadOptions { HttpHeaders = new BlobHttpHeaders { ContentType = contentType } }, ct);
public async Task<Stream?> OpenAsync(string key, CancellationToken ct)
{
var blob = container.GetBlobClient(key);
return await blob.ExistsAsync(ct) ? await blob.OpenReadAsync(cancellationToken: ct) : null;
}
}
public sealed class S3DocumentStore(IAmazonS3 s3, string bucket) : IDocumentStore
{
public Task SaveAsync(string key, Stream content, string contentType, CancellationToken ct) =>
s3.PutObjectAsync(new PutObjectRequest
{ BucketName = bucket, Key = key, InputStream = content, ContentType = contentType }, ct);
public async Task<Stream?> OpenAsync(string key, CancellationToken ct)
{
try
{
var response = await s3.GetObjectAsync(bucket, key, ct);
return response.ResponseStream;
}
catch (AmazonS3Exception ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return null;
}
}
}
// Program.cs: the cloud is a deployment choice. Identity stays platform-native on both (no keys).
using Azure.Identity;
using Azure.Storage.Blobs;
using Amazon.S3;
using Orders.Application.Ports;
using Orders.Infrastructure;
var builder = WebApplication.CreateBuilder(args);
switch (builder.Configuration["Cloud"])
{
case "Azure":
builder.Services.AddSingleton(_ => new BlobContainerClient(
new Uri(builder.Configuration["Documents:ContainerUri"]!), new DefaultAzureCredential()));
builder.Services.AddSingleton<IDocumentStore, BlobDocumentStore>();
break;
case "Aws":
builder.Services.AddDefaultAWSOptions(builder.Configuration.GetAWSOptions());
builder.Services.AddAWSService<IAmazonS3>();
builder.Services.AddSingleton<IDocumentStore>(sp => new S3DocumentStore(
sp.GetRequiredService<IAmazonS3>(), builder.Configuration["Documents:Bucket"]!));
break;
default:
throw new InvalidOperationException("Set Cloud to Azure or Aws."); // fail fast at start-up
}
// Observability is portable: OpenTelemetry with OTLP; the collector decides where it goes.
builder.Services.AddOpenTelemetry()
.WithTracing(t => t.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddOtlpExporter());
var app = builder.Build();
app.Run();
// Contract tests: the same behaviour is verified against Azurite and LocalStack (xUnit).
using System.Text;
using Orders.Application.Ports;
using Xunit;
namespace Orders.ContractTests;
public abstract class DocumentStoreContract
{
protected abstract IDocumentStore CreateStore();
[Fact]
public async Task Saved_document_can_be_read_back()
{
var store = CreateStore();
var key = $"invoices/{Guid.NewGuid()}.txt";
await store.SaveAsync(key, new MemoryStream(Encoding.UTF8.GetBytes("hello")), "text/plain", CancellationToken.None);
await using var stream = await store.OpenAsync(key, CancellationToken.None);
Assert.NotNull(stream);
Assert.Equal("hello", await new StreamReader(stream).ReadToEndAsync());
}
[Fact]
public async Task Missing_document_returns_null() =>
Assert.Null(await CreateStore().OpenAsync("missing/key", CancellationToken.None));
}
Multi-cloud is a business decision about risk and optionality, and a senior engineer's job is to price it. Most of the value people expect from it (resilience, negotiating leverage, the ability to leave) can be bought far more cheaply through multi-region on one cloud, containers, OpenTelemetry, standard data engines, Terraform and a tested exit plan. Use managed services where they save real effort, and be explicit about the lock-in you accept and what it would cost to undo.
Workload-per-cloud is the variant I'd accept most readily: after an acquisition, or when one cloud has a clearly better service for one system, each workload still uses its cloud fully and the cost is mainly a second platform baseline. Active-active across clouds is justified only for a small set of systems with extreme availability needs and the budget and team to match.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Single cloud, multi-region | Most systems, including regulated ones | Moderate (second region, replication) | Provider-level exit is a hard requirement with a short deadline |
| Single cloud with exit plan and drills | Lock-in worries, procurement leverage | Low (discipline, periodic drill) | You never intend to act on it (then skip the ceremony) |
| Workload per cloud | Acquisitions, best-of-breed, customer location | Second platform baseline and skills | One small team |
| Active-active multi-cloud | Rare, extreme availability or regulatory mandate | Very high (2x+ infra, people, data sync) | Almost everyone else |
Measure it with the exit cost in engineer-days from the last drill, the availability actually achieved against the SLO, egress spend, and incident counts per platform.
At the architecture level, over-engineering means paying now, in hosting, cognitive load and delivery speed, for scale or flexibility nobody has evidence for. The warning signs are concrete signals to investigate: far more deployables than teams, Kubernetes and a service mesh for 50 requests a second when App Service or Container Apps would do, a message broker between modules in one process, a generic plug-in framework with a single plug-in. I judge them against the team's size, experience and on-call capacity, because the same design can suit eight platform teams and sink one team of five.
I separate one-way doors (splitting data, event sourcing, choosing a region) from two-way doors (a library, a folder layout). One-way doors get analysis and an ADR; two-way doors get the simplest option. I keep options open with module boundaries rather than network boundaries.
The trade-off: under-building something genuinely irreversible is costly too, so I write down the trigger that would justify the bigger design.
I use three tools that reinforce each other. Architecture Decision Records capture each significant decision in one short page: context, decision, alternatives, consequences and status. They live in the repo and are reviewed by pull request; when a decision changes, a new ADR supersedes the old one.
The C4 model gives diagrams at the right zoom level: System Context for stakeholders, Containers for engineers, Components where it helps. I keep them as code (Structurizr DSL or Mermaid) so they're versioned.
Fitness functions stop the docs from lying: architecture tests (ArchUnitNET), load tests and dependency checks that fail the build when the code drifts from the decisions.
The trade-off: documentation costs time, so I keep it small and automate the checks instead of writing long documents nobody reads.
Most Azure services have a close AWS match: App Service maps to Elastic Beanstalk or App Runner (though most .NET teams end up on ECS with Fargate), Functions to Lambda, Azure SQL to RDS for SQL Server, Blob Storage to S3, Key Vault to Secrets Manager plus KMS, Service Bus to SQS plus SNS, and Azure Monitor / Application Insights to CloudWatch plus X-Ray or OpenTelemetry.
What catches Azure developers out is not the services but the plumbing:
The trade-off: the names map one to one, but the operating model (identity, networking, accounts) does not.
How to tell it (STAR)
**S:** After a regional outage took our [payments API] down for [3 hours], the board asked us to run the platform on both Azure and AWS within a year. **T:** I was asked to [lead the technical response] and recommend how to meet the resilience goal. **A:** I went back to the incident and showed the real cause was an untested, manual regional failover, not Azure itself. I costed three options: active-active multi-cloud, warm standby in Australia Southeast, and single cloud with an exit plan. I also ran a two-day spike moving one service to AWS so the exit cost was measured, not guessed. I recommended the warm standby with automated failover and quarterly game days, plus a documented AWS exit plan, and wrote it up as an ADR for the risk committee. **R:** The board approved it at about [40%] of the multi-cloud estimate. Our first failover test came in at an RTO of [12 minutes], against [3 hours] during the incident.
Last updated 23 Nov 2026.