5 min read

App Runner - build and run your containerized web application in AWS

A fully managed service that makes it easy for developers to deploy from source code or container image directly to a scalable and secure web application.
App Runner - build and run your containerized web application in AWS
AWS App Runner - build and run your containerized web application in AWS (credit: aws.amazon.com). 
Running your containerized application on the Microsoft Azure cloud platform
In this post, I will demonstrate one option to run your containerized .NET application on one of the most popular cloud providers on earth (Microsoft Azure).
When developer want to run their containerized application on AWS, Elastic Beanstalk or Fargate can be a good option, and with the introduction of App Runner. AWS make it even more easier for developer to build & run their containerized web application in AWS.

Prerequisites:

  • AWS IAM Account with proper permission on AWS ECR and AWS App Runner.
  • Basic Docker knowledge.

How does AWS App Runner work?

App Runner is a fully managed container-native service, which means developers don't have to worry about container orchestrator, build pipeline, load balancer, or even TLS certificate so that they can shift 100% focus on developing applications.

How do AWS App Runner works? (credit: docs.aws.amazon.com)

AWS App Runner takes your app container image or source codes as an input, along with deployment & service settings. It will build, deploy and publish your web app via a secured URL (https://{unique-string}.{aws-region}.awsapprunner.com/) in the simplest way.

AWS App Runner supports two repository types: container image and source codes. As long as you can containerize your application, you can choose App Runner to publish your web app. With source codes mode, currently, only Python, and Node.js are supported.

Deploy .NET Core 3.1 web application to AWS App Runner

I have a simple .NET Core web application on the GitHub repository. I want to publish this so that I can test it and share it with other members of the company. I decided to use AWS App Runner to build & run my web app on AWS infrastructure. The source code is very simple and can be found here: https://github.com/wata-corp/my-demo-web-app.

  1. Create a public repository on AWS ECR and push docker image

First, I need to create a container image registry, where I can push my web app Docker image to. As App Runner limits the support to Aws ECR only, so I will navigate to the ECR dashboard and create one.

Create a public repository on AWS ECR.

After creating a new repository successfully, use the following commands to tag and push our web app docker image to AWS ECR. You need to open your terminal on the project directory to run commands.

Click the "View push commands" button to get all necessary commands.
$ aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.awsd7m8d7e5

$ docker build -t aws-app-runner .

$ docker tag aws-app-runner:latest public.ecr.aws/d7m8d7e5/aws-app-runner:latest

$ docker push public.ecr.aws/d7m8d7e5/aws-app-runner:latest

NOTES: you need create your own ECR instance to push docker image!
Successfully push our web app docker image to AWS ECR.

2. Create AWS App Runner service and deploy our web app.

Navigate to the AWS App Runner dashboard at (https://us-east-2.console.aws.amazon.com/apprunner/home) and create an App Runner service. We can either deploy directly from a container registry (AWS ECR) or from a source code repository (like GitHub).

Within this demo, we will use the Container registry for repository type and use the docker image URL from AWS ECR that we just created in step 1 (note: your docker image URL will be different).

Select repository type and deployment settings.
Configure app runner service CPU, memory, and port.
Service name: my-web-app-service
Virtual CPU & memory: 1 vCPU, 2GB
Port: 80

Then click Next to review all configurations and then Create the service. It will take 3-5 minutes for the service to up & run, we can also review logs in the App Runner console to see if there are any issues with the deployment.

03-23-2022 06:07:56 PM [AppRunner] Service status is set to RUNNING.
03-23-2022 06:07:56 PM [AppRunner] Service creation completed successfully.
03-23-2022 06:07:55 PM [AppRunner] Successfully routed incoming traffic to application.
03-23-2022 06:07:25 PM [AppRunner] Health check is successful. Routing traffic to application.
03-23-2022 06:06:38 PM [AppRunner] Performing health check on port '80'.
03-23-2022 06:06:29 PM [AppRunner] Provisioning instances and deploying image.
03-23-2022 06:06:18 PM [AppRunner] Successfully pulled image from ECR.
03-23-2022 06:04:37 PM [AppRunner] Service status is set to OPERATION_IN_PROGRESS.
03-23-2022 06:04:36 PM [AppRunner] Service creation started.
App Runner service created successfully!

3. Observe the results

From the service dashboard, we can get the default domain of our application, let's check to verify if our containerized web app running successfully on AWS App Runner. In my case the default domain is https://q323taamwi.us-east-2.awsapprunner.com/, yours will be different.

You can also check the logs, metrics and even add a custom domain to your app, check out AWS's official document for more information here: https://docs.aws.amazon.com/apprunner/latest/dg/what-is-apprunner.html.

.NET Core web app container successfully up & run on AWS infra.

Conclusions

From a developer perspective, AWS App Runner is a well-managed container service, it is easy to use, any developer can build, deploy containerized applications on AWS infra with less prior AWS knowledge.

However, there are still some concerns with App Runner like:

  • With container registry, it ONLY supports AWS ECR
  • With the source code repository, it ONLY supports GitHub, and the narrow list of runtime environments (Python, and Node.js) while compared to Azure Container Instance or GCP Cloud Run.
  • Pricing model: resource configuration (vCPU and memory), it would be better if AWS offer pay-as-you-use option.
Thanks for reading my post, try it on your own AWS account with different modes to learn more, see you in next post!