Hosting side by side: IIS and App Service vs AWS
Run the same ASP.NET Core API on every hosting model an Azure team knows (IIS on a VM, App Service, Container Apps, AKS) and on its AWS counterpart (EC2 Windows, Elastic Beanstalk, ECS Express Mode, ECS on Fargate), then choose between them with a short decision rule.
Assumes: .NET 10 LTS · Elastic Beanstalk .NET 10 on Amazon Linux 2023 · Amazon ECS (Fargate, Express Mode) · AWS CDK v2 (C#) · AWS CLI v2 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Map each Azure hosting model (VM with IIS, App Service, Container Apps, AKS, ACI) to its closest AWS option and say what you gain and lose.
- Translate App Service concepts (plan, slots, app settings, Easy Auth, Always On, Kudu) into AWS equivalents.
- Package one ASP.NET Core API so it runs unchanged on Beanstalk, ECS Express Mode and ECS on Fargate.
- Apply a four-question rule that picks a hosting model for a given workload.
- Estimate the monthly cost of the always-on parts and tear everything down the same day.
Prerequisites
- Azure vs AWS: the big picture
- Hosting options compared, the full AWS-side treatment. This lesson is the migration-oriented view of it.
- Containerising .NET and Elastic Beanstalk for .NET
- Tools: Docker, .NET 10 SDK, AWS CLI v2 with
learn-sandbox. Cloud steps are optional and cost a few cents.
Why this matters in banking
Harbourline's Rates API serves currency conversion to the mobile app. On Azure it runs on an App Service plan with two instances, a staging slot for releases, and "Easy Auth" in front of it. When the team lifts it to AWS they discover the questions App Service answered silently: where do the instances live, who patches them, how does a release swap traffic, and who validates the caller? On AWS each answer is a visible resource you own. Done well, that is a gain in control and auditability; done carelessly, it is a Friday-night outage and an unpatched Windows host.
The goal of this lesson is to make those answers explicit for every hosting model, before the first workload moves.
The idea in plain language
Hosting answers one question: where does my code run, and who looks after the machine? Cloud offers a ladder from "you look after everything" to "you only provide code".
| Rung | Azure | AWS | You manage |
|---|---|---|---|
| Virtual machine | Azure VM + IIS | EC2 (Windows Server + IIS) | OS patches, IIS, scaling, certificates |
| Managed web platform | App Service | Elastic Beanstalk | Code and settings; AWS creates and updates EC2, load balancer, scaling group |
| Managed containers, simplest | Container Apps | ECS Express Mode | Image and a few settings |
| Managed containers, full control | AKS, ACI | ECS on Fargate (or EKS) | Task definition, service, networking |
| Functions | Azure Functions | Lambda | Handler code (next lesson) |
Analogy: a VM is renting an empty shop and fitting it out yourself. App Service and Beanstalk are renting a serviced kiosk: someone else fixes the lights, but you can still see the fuse box on AWS. Container platforms are a shipping container you can drop on any quay; the quay (Fargate) provides the crane.
One honest difference: App Service hides its workers, the plan and the front end. Beanstalk puts a real EC2 fleet, Auto Scaling group and load balancer into your account, where you can see, tag, patch and bill them. That visibility is why audit teams like it and why a careless team can leave it running.
What problem each AWS option solves
| Option | Best for | Sharp edges |
|---|---|---|
| EC2 Windows + IIS | Apps that need .NET Framework, COM, Windows auth, or a lift-and-shift with no code change | You patch it; Windows licence is in the hourly price (licensing lesson); slow to scale |
| Elastic Beanstalk, .NET 10 on Amazon Linux 2023 | Straightforward web apps and APIs, lowest change for App Service users | Platform versions retire; you manage environment settings; Linux branch cannot run .NET Framework |
| Elastic Beanstalk, Windows Server with IIS | .NET Framework 4.8 apps that must stay on IIS | Check which .NET versions the Windows platform branches currently offer ⚠ VERIFY before assuming .NET 10 support |
| ECS Express Mode | A containerised API that needs a URL, HTTPS and autoscaling with almost no AWS knowledge | New service; Express Mode defaults suit web APIs, not every shape. See the AWS overview |
| ECS on Fargate | Multiple services, sidecars, private-only APIs, strict networking | More resources to define (task, service, target group) |
| Lambda | Event-driven and spiky traffic | Next lesson |
AWS App Runner is not on this list. It closed to new customers (announced 2026-03-31, effective 2026-04-30), and AWS recommends ECS Express Mode as the replacement. Do not design a new Harbourline workload on it.
Microsoft / Azure comparison
| You know (Azure) | AWS equivalent | What's different |
|---|---|---|
| App Service plan (shared capacity for many apps) | No plan object. Each Beanstalk environment or ECS service has its own capacity | You can no longer "pack" many small apps on one plan; ECS can pack tasks on a cluster, Express Mode shares a load balancer |
| Deployment slots (swap staging and production) | Beanstalk swap environment URLs; ECS blue/green with CodeDeploy or ECS native deployment strategies | A slot shares the plan; a Beanstalk swap swaps two full environments, so you pay for both while testing. See ECS deployment strategies |
| Application settings and connection strings | Environment variables; secrets from Secrets Manager or Parameter Store injected at start | Never put secrets in plain environment variables; see the DevOps lesson |
| Easy Auth (built-in sign-in) | ALB authentication actions (OIDC, Cognito) or validate JWTs in the app | AWS does not authenticate for you by default; add it deliberately |
| Always On | Not applicable: instances and tasks stay running | Scale-to-zero is a Lambda trait, not a Beanstalk or Fargate one |
| Kudu console, SSH | ECS Exec or SSM Session Manager | Both are audited through CloudTrail; no inbound port 22 needed |
| Managed certificate for custom domain | AWS Certificate Manager certificate on the load balancer, DNS in Route 53 | ACM certificates are free for use with integrated services |
| VNet integration | Tasks and instances live inside your VPC subnets | There is no separate integration step; the placement is the networking |
| Autoscale rules | Auto Scaling target tracking on CPU, request count per target | Set minimum two instances across two AZs for resilience |
| Log stream, Application Insights | CloudWatch Logs with the awslogs driver | See the monitoring lesson |
Architecture
Security-boundary view. The ALB sits in public subnets; tasks sit in private subnets and accept traffic only from the ALB's security group. The task role limits what the container can call (one secret, one log group). Outbound traffic to AWS APIs goes through VPC endpoints or a NAT gateway (NAT egress). Compare this with App Service, where front end, workers and network integration are Microsoft-managed and invisible.
Step-by-step implementation
Build one artifact that works everywhere
Create the API in Complete code. It listens on the port from ASPNETCORE_URLS, exposes /health/ready, reads configuration from the environment, and logs JSON to the console. These four habits make it portable across IIS-less hosts.
Run it locally in a container
docker build -t hl-m13-rates:v1 .
docker run --rm -p 8080:8080 hl-m13-rates:v1
curl http://localhost:8080/rates/GBP/EURChoose a target with the four-question rule
- Does it need .NET Framework, COM or Windows authentication? → EC2 Windows or Beanstalk Windows.
- Is it a single web app or API with ordinary needs, and is your team new to containers? → Beanstalk (.NET 10 on AL2023).
- Is it a containerised HTTP API and you want a URL with almost no setup? → ECS Express Mode.
- Several services, sidecars, private-only, or tight network control? → ECS on Fargate.
Event-driven and bursty? Look at Lambda first.
Deploy to one target in the sandbox (optional)
The CLI section shows Express Mode. A Beanstalk deployment is walked through step by step in Elastic Beanstalk for .NET, so this lesson does not repeat it.
Tear down the same day
Delete the service and any load balancer it created, then confirm with the tag query in Cost and cleanup.
AWS Console instructions
- Beanstalk: Console → Elastic Beanstalk → Create application → Web server environment, platform .NET 10 running on 64bit Amazon Linux 2023 (the exact label changes with each platform version), upload the zipped
dotnet publishoutput. - ECS Express Mode: Console → Amazon ECS → Express Mode services → Create, choose the ECR image, a task execution role and an infrastructure role, and review the defaults before creating.
- ECS on Fargate: Console → Amazon ECS → Clusters → Create cluster, then Task definitions → Create new, then Create service on the cluster.
AWS CLI
# Which .NET platform versions does Elastic Beanstalk currently offer?
aws elasticbeanstalk list-available-solution-stacks --profile learn-sandbox --region us-east-1 \
--query "SolutionStacks[?contains(@, '.NET')]"
# ECS Express Mode: one call creates the Fargate service, load balancer and scaling (OPTIONAL, costs while running).
# Prerequisites: an image in ECR, plus ecsTaskExecutionRole and ecsInfrastructureRoleForExpressServices.
ACCOUNT=$(aws sts get-caller-identity --query Account --output text --profile learn-sandbox)
aws ecs create-express-gateway-service --profile learn-sandbox --region us-east-1 \
--service-name hl-m13-rates-express \
--execution-role-arn arn:aws:iam::$ACCOUNT:role/ecsTaskExecutionRole \
--infrastructure-role-arn arn:aws:iam::$ACCOUNT:role/ecsInfrastructureRoleForExpressServices \
--primary-container "{\"image\":\"$ACCOUNT.dkr.ecr.us-east-1.amazonaws.com/hl-m13-rates:v1\",\"containerPort\":8080}" \
--cpu 0.25 --memory 0.5 \
--health-check-path /health/ready \
--scaling-target '{"minTaskCount":1,"maxTaskCount":2}' \
--tags key=Project,value=cea-lab key=Lab,value=m13-hosting key=Environment,value=learn \
--monitor-resources
# Inspect, then delete. Flags follow the ECS CLI; confirm with the built-in help first. ⚠ VERIFY
aws ecs describe-express-gateway-service --service-arn <service-arn> --profile learn-sandbox --region us-east-1
aws ecs delete-express-gateway-service --service-arn <service-arn> --profile learn-sandbox --region us-east-1Run aws ecs create-express-gateway-service help to confirm units and flags before use; the option names follow the pattern documented for Express Mode but AWS may refine them.
Infrastructure as Code
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ECS.Patterns;
using Constructs;
public sealed class RatesFargateStack : Stack
{
public RatesFargateStack(Construct scope, string id, IStackProps props) : base(scope, id, props)
{
// Two AZs, one NAT gateway: the cheapest layout that still survives an AZ loss for the tasks.
var vpc = new Vpc(this, "Vpc", new VpcProps { MaxAzs = 2, NatGateways = 1 });
var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc });
_ = new ApplicationLoadBalancedFargateService(this, "Rates", new ApplicationLoadBalancedFargateServiceProps
{
Cluster = cluster,
Cpu = 256,
MemoryLimitMiB = 512,
DesiredCount = 2,
PublicLoadBalancer = true,
TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions
{
Image = ContainerImage.FromAsset("./src/Harbourline.RatesApi"),
ContainerPort = 8080,
},
});
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Lab", "m13-hosting");
Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
}
}Complete code
A minimal API that carries every portability habit. Project name Harbourline.RatesApi.
using System.Text.Json;
var builder = WebApplication.CreateBuilder(args);
// JSON console logs: CloudWatch Logs Insights can then filter on fields instead of regex.
builder.Logging.ClearProviders();
builder.Logging.AddJsonConsole(o => o.JsonWriterOptions = new JsonWriterOptions { Indented = false });
var app = builder.Build();
// Fictional fixed rates; a real service would call a rates provider.
var rates = new Dictionary<string, decimal>(StringComparer.OrdinalIgnoreCase)
{
["GBP-EUR"] = 1.17m,
["EUR-GBP"] = 0.85m,
};
app.MapGet("/rates/{from}/{to}", (string from, string to) =>
rates.TryGetValue($"{from}-{to}", out var r)
? Results.Ok(new { from = from.ToUpperInvariant(), to = to.ToUpperInvariant(), rate = r })
: Results.Problem(statusCode: 404, title: "Unknown currency pair"));
// Load balancers and orchestrators call this; keep it free of dependencies it cannot reach.
app.MapGet("/health/ready", () => Results.Ok(new { status = "ready" }));
app.Run();FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
# The aspnet image listens on 8080 as a non-root user by default in .NET 8 and later.
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "Harbourline.RatesApi.dll"]Code explained line by line
WebApplication.CreateBuilder(args)builds the host. Environment variables overrideappsettings.json, which is how hosts inject settings without editing files.AddJsonConsolewrites one JSON object per log line to stdout. ECS'sawslogsdriver and Beanstalk's log agent both ship stdout to CloudWatch Logs, so you need no logging agent in the app.- The dictionary and
MapGetgive a deterministic endpoint so you can test all hosts with the samecurl. Results.Problemreturns RFC 9457 ProblemDetails, the error format used by every Harbourline API in this course./health/readyis what the ALB target group and Express Mode health check poll. A slow database call here would make healthy tasks look dead.- In the Dockerfile, two stages keep the SDK out of the runtime image.
ASPNETCORE_URLSsets the port the load balancer targets.
Security considerations
⚠ Learning shortcut — not for production
The CDK example exposes a public HTTP load balancer with no certificate, no WAF and no authentication, so you can curl it. A production Harbourline API sits behind CloudFront with WAF, terminates TLS 1.2 or later with an ACM certificate, authenticates callers (Cognito, mTLS or a JWT authoriser) and lives in private subnets with only the load balancer public. App Service gave you TLS and Easy Auth almost by default; on AWS you must add them.
- Patch ownership. EC2 Windows: you. Beanstalk: you choose managed platform updates; turn them on. Fargate: AWS patches the host, you rebuild the image for OS and runtime fixes.
- No secrets in images or plain environment variables. Use the task role plus Secrets Manager references.
- Least privilege task role. One role per service; the execution role (pull image, write logs) is separate from the task role (what the code may call).
- Encrypt and log. Enable access logs on the ALB to an S3 bucket with a lifecycle rule, and keep CloudWatch log retention finite.
- Shared responsibility. Hosting choice moves the line; compliance claims remain Harbourline's to evidence. This lesson makes no compliance claim.
Banking use case
Harbourline's migration team sorts its fifteen hosted apps with the four-question rule and gets a typical bank result: two need Windows (a Web Forms back-office tool, a COM-dependent statement generator), eight are ASP.NET Core or MVC apps that fit Beanstalk or Express Mode immediately, three are internal services with sidecars that go to Fargate, and two are queue consumers better suited to Lambda. The Windows pair is not ported now; it is rehosted (a later lesson) and re-examined once the rest has settled. This is the 7 Rs thinking you will formalise in The 7 Rs.
Common mistakes
- Looking for the App Service plan. Teams search for a shared-capacity object. Decide per service, and use ECS capacity or Express Mode's shared load balancer for cost control.
- Swapping environments without database compatibility. A Beanstalk swap flips traffic, not schema. Keep database changes backward-compatible across both versions.
- Port mismatch. The container listens on 80 in the old Dockerfile while the target group checks 8080. Set
ASPNETCORE_URLSand the health check path together. - Running Windows containers on Fargate by default. It is possible but heavier; for modern .NET use Linux images.
- Forgetting to delete the load balancer. ALBs bill hourly even with no traffic.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Target group shows tasks unhealthy | Health check path or port wrong, or app slow to start | Match path /health/ready and port 8080; raise the health check grace period |
exec format error at task start | Image built for ARM but task set to x86, or the reverse | Build for the task's CPU architecture or set --platform explicitly |
| Express Mode create fails with a role error | Missing execution or infrastructure role | Create both roles as in the AWS getting-started guide, then retry |
| Beanstalk environment red after deploy | App crashed on start or wrong port | Check eb-engine.log and the web log in the environment's logs page |
| 502 from the ALB | Container not listening on the expected port | Confirm ASPNETCORE_URLS and the container port |
Cost and cleanup
Cost label: credits (a few cents to under USD 1 if torn down within the hour). The always-on parts are an Application Load Balancer (roughly USD 16 a month at the time of writing, plus usage), a NAT gateway if you create one (about USD 33 a month plus data), and Fargate tasks (a 0.25 vCPU, 0.5 GB task is under USD 10 a month). Prices vary by Region and change; confirm on the AWS Pricing Calculator ⚠ VERIFY. Free alternative: run the container locally and do the exercises as design work.
# Delete what you created (service ARN comes from describe/list)
aws ecs delete-express-gateway-service --service-arn <service-arn> --profile learn-sandbox --region us-east-1
# CDK route: destroy the stack
cdk destroy RatesFargateStack --profile learn-sandbox
# Verify nothing tagged for the course is left
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab \
--profile learn-sandbox --region us-east-1 --query "ResourceTagMappingList[].ResourceARN"Also check Console → EC2 → Load Balancers and NAT gateways for strays.
Exercises
- 🟢 Guided: build and run the container locally, then fill in a table of the five App Service concepts (plan, slot, app setting, Easy Auth, Always On) with the AWS equivalent each.
- 🟡 Challenge: write the decision rule as a C# method
string ChooseHost(AppProfile p)with at least eight unit-testable branches, and test it with three Harbourline apps. - 🔴 Live problem: a ticket says "the Rates API must stay up during a release and roll back in under five minutes." Choose a hosting model and a deployment strategy, say what you would monitor during the swap, and state the cost impact of running two versions side by side.
Assignment
Write a hosting decision record for one real application you maintain: the four-question answers, the chosen AWS option, the rejected options and why, a rough monthly cost, and the rollback method. Commit it to your portfolio repository.
Solutions
Plan: no equivalent, capacity belongs to each service. Slot: Beanstalk swap environment URLs or ECS blue/green. App setting: environment variable, with secrets injected from Secrets Manager. Easy Auth: ALB OIDC or Cognito action, or JWT validation in the app. Always On: not needed, tasks and instances stay running. The why: AWS makes each of these a visible resource, so you choose and own the configuration.
A compact rule: if (p.NeedsWindows) return "EC2 Windows or Beanstalk Windows"; if (p.IsEventDriven) return "Lambda"; if (p.Services > 1 || p.NeedsSidecar || p.PrivateOnly) return "ECS on Fargate"; if (p.IsContainerised) return "ECS Express Mode"; return "Beanstalk .NET 10";. Test each branch with one app. The order matters: constraints (Windows, event-driven) come before preferences, otherwise a Windows app would be sent to containers.
Knowledge check
Answer: swapping environment URLs between two environments. Unlike slots, both are full environments, so you pay for both while they coexist.
Answer: Amazon ECS Express Mode (or plain ECS on Fargate for more control). App Runner is closed to new customers.
Answer: on the load balancer (OIDC or Cognito authentication action), in an API Gateway authoriser, or in the app with JWT bearer middleware. AWS does not enable it by default.
Answer: if the database is briefly slow, every task fails the check and the orchestrator replaces healthy tasks, turning a small fault into an outage. Use a separate deeper check for diagnostics.
Answer: EC2 Windows with IIS (or the Beanstalk Windows platform). The Linux-based options cannot run .NET Framework.
Interview questions
- "We run on App Service. What is the smallest AWS move?" Elastic Beanstalk with the .NET 10 Linux platform if the app is ASP.NET Core, or ECS Express Mode if it is already a container. I would deploy to a test account first and compare cost, deploy time and logging.
- "Who patches what?" On EC2, we do everything. On Beanstalk, platform updates are ours to enable. On Fargate, AWS patches the host but we rebuild images.
- "How do you do a zero-downtime release?" Blue/green with a traffic shift, a health check gate and a rollback trigger; the database change must work with both versions.
Certification practice
A team wants to host a stateless containerised web API with HTTPS, load balancing and automatic scaling, and has almost no AWS experience. They do not want to define target groups or task definitions by hand. Which is the best fit?
A. Amazon EC2 with a user data script B. Amazon ECS Express Mode C. AWS App Runner in a newly created account D. Amazon EKS with managed node groups
Answer: B. Express Mode provisions a Fargate service, load balancer, TLS and scaling from an image and two roles. A requires manual patching and scaling. C is closed to new customers. D adds far more operational surface than the team asked for.
A .NET Framework 4.8 application depends on COM components and Windows authentication. The bank wants it on AWS within a month with no code changes. Which approach is most appropriate?
A. Port to .NET 10 and run on Lambda B. Rehost on Amazon EC2 Windows (or Elastic Beanstalk Windows platform) C. Run on ECS Express Mode with a Linux image D. Repurchase as SaaS
Answer: B. Only Windows hosting runs .NET Framework with COM. A and C require code changes and cannot run COM. D is a business decision and not possible in a month without a product.
Completion checklist
- I can map five App Service concepts to AWS from memory
- I ran the Rates API in a container locally
- I can state the four-question rule and apply it to an app I own
- I deleted any load balancer, NAT gateway and service I created and ran the tag query
Key takeaways
- App Service hides its infrastructure; Beanstalk and ECS show it in your account, which means more control and more responsibility.
- Express Mode is the simple container path; Fargate is the controlled one; Windows needs EC2 or Beanstalk Windows.
- Slots become swapped environments or blue/green; Easy Auth becomes an explicit authentication step.
- Always check the always-on cost items: load balancers and NAT gateways.
Further reading
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Azure vs AWS: the big picture
Map the Azure structures you know (tenant, subscription, resource group, region pair, VNet, NSG, managed identity) onto their AWS counterparts, and learn the handful of differences that cause real outages and surprise bills during a migration.
Azure Functions to AWS Lambda
Translate Azure Functions triggers, bindings, hosting plans and Durable Functions into Lambda event source mappings, SDK calls, concurrency settings and Step Functions, and port a queue-triggered payment function to a Lambda handler with partial batch failure handling.