Skip to Content
Cloud Engineering Academy
13. Microsoft-to-AWS Migration

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.

intermediate⏱ 1 h 30 min🟡 Low costSAA-C03SAP-C03DVA-C03

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

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".

RungAzureAWSYou manage
Virtual machineAzure VM + IISEC2 (Windows Server + IIS)OS patches, IIS, scaling, certificates
Managed web platformApp ServiceElastic BeanstalkCode and settings; AWS creates and updates EC2, load balancer, scaling group
Managed containers, simplestContainer AppsECS Express ModeImage and a few settings
Managed containers, full controlAKS, ACIECS on Fargate (or EKS)Task definition, service, networking
FunctionsAzure FunctionsLambdaHandler 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

OptionBest forSharp edges
EC2 Windows + IISApps that need .NET Framework, COM, Windows auth, or a lift-and-shift with no code changeYou patch it; Windows licence is in the hourly price (licensing lesson); slow to scale
Elastic Beanstalk, .NET 10 on Amazon Linux 2023Straightforward web apps and APIs, lowest change for App Service usersPlatform 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 IISCheck which .NET versions the Windows platform branches currently offer ⚠ VERIFY before assuming .NET 10 support
ECS Express ModeA containerised API that needs a URL, HTTPS and autoscaling with almost no AWS knowledgeNew service; Express Mode defaults suit web APIs, not every shape. See the AWS overview
ECS on FargateMultiple services, sidecars, private-only APIs, strict networkingMore resources to define (task, service, target group)
LambdaEvent-driven and spiky trafficNext 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 equivalentWhat's different
App Service plan (shared capacity for many apps)No plan object. Each Beanstalk environment or ECS service has its own capacityYou 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 strategiesA 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 stringsEnvironment variables; secrets from Secrets Manager or Parameter Store injected at startNever 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 appAWS does not authenticate for you by default; add it deliberately
Always OnNot applicable: instances and tasks stay runningScale-to-zero is a Lambda trait, not a Beanstalk or Fargate one
Kudu console, SSHECS Exec or SSM Session ManagerBoth are audited through CloudTrail; no inbound port 22 needed
Managed certificate for custom domainAWS Certificate Manager certificate on the load balancer, DNS in Route 53ACM certificates are free for use with integrated services
VNet integrationTasks and instances live inside your VPC subnetsThere is no separate integration step; the placement is the networking
Autoscale rulesAuto Scaling target tracking on CPU, request count per targetSet minimum two instances across two AZs for resilience
Log stream, Application InsightsCloudWatch Logs with the awslogs driverSee 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/EUR

Choose a target with the four-question rule

  1. Does it need .NET Framework, COM or Windows authentication? → EC2 Windows or Beanstalk Windows.
  2. Is it a single web app or API with ordinary needs, and is your team new to containers? → Beanstalk (.NET 10 on AL2023).
  3. Is it a containerised HTTP API and you want a URL with almost no setup? → ECS Express Mode.
  4. 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 publish output.
  • 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-1

Run 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

RatesFargateStack.cs
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.

Program.cs
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();
Dockerfile
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

  1. WebApplication.CreateBuilder(args) builds the host. Environment variables override appsettings.json, which is how hosts inject settings without editing files.
  2. AddJsonConsole writes one JSON object per log line to stdout. ECS's awslogs driver and Beanstalk's log agent both ship stdout to CloudWatch Logs, so you need no logging agent in the app.
  3. The dictionary and MapGet give a deterministic endpoint so you can test all hosts with the same curl.
  4. Results.Problem returns RFC 9457 ProblemDetails, the error format used by every Harbourline API in this course.
  5. /health/ready is what the ALB target group and Express Mode health check poll. A slow database call here would make healthy tasks look dead.
  6. In the Dockerfile, two stages keep the SDK out of the runtime image. ASPNETCORE_URLS sets 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_URLS and 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

SymptomLikely causeFix
Target group shows tasks unhealthyHealth check path or port wrong, or app slow to startMatch path /health/ready and port 8080; raise the health check grace period
exec format error at task startImage built for ARM but task set to x86, or the reverseBuild for the task's CPU architecture or set --platform explicitly
Express Mode create fails with a role errorMissing execution or infrastructure roleCreate both roles as in the AWS getting-started guide, then retry
Beanstalk environment red after deployApp crashed on start or wrong portCheck eb-engine.log and the web log in the environment's logs page
502 from the ALBContainer not listening on the expected portConfirm 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

Knowledge check

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

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.

On this page