I’ve had some time to dig into Azure App Containers . I have limited container experience, but have been interested and learning in spurts about containers over the last few years. In my opinion, containers have become the best way to run applications. I’m interested in cheaper, quicker and easier way to host containers without Kubernetes. I’d like to have them communicate between each other. I’ve also been interested in Dapr to help with microservices, pub/sub and secret management. After hearing about Azure App Containers at Microsoft Build 2022 , it seems like another Microsoft achievement to let developers focus on writing code to meet business outcomes and not having to worry about infrastructure.
"Azure Container Apps enables you to run microservices and containerized applications on a serverless platform"
from MS Docs Overview
I started by watching videos from .Net Conf 2022 and MS Build 2022 (linked in the resources section below) to get an overview. I then ran through the quick start and then followed more doc steps. The Azure Cli is really slick and makes walking through these steps easy. There are a lot of pieces to put together and I had some struggles.
I had a decent foundation knowledge of containers and some practice using Docker in the past. You’ll need that as well as you go beyond the tutorials.
az acr build
)var urlFromEnvironmentVar = Environment.GetEnvironmentVariable("frontUrl");
builder.Services.AddCors(options =>
{
options.AddPolicy(
name: MyAllowSpecificOrigins,
policy =>
{
policy.WithOrigins(urlFromEnvironmentVar);
});
});
az containerapp create
command --enable-dapr \ --dapr-app-id nodeapp \--dapr-app-port 3000
--secrets "xkey=yvalue
to az containerapp create
Then learn about environments, revisions, monitoring, health checks, scaling with KEDA, using the Dapr api for state storage, etc.
The Microsoft Docs cover the information really well. Your challenge is how to understand all the pieces, think about the needs of your application and put them together.
I started with a web front end and back end for an example. I need to set a configurable api address in the web front end. I’m choosing to use an environment variable.
Docs Communicate between microservices has a node app example, but I’d like to use .Net with Javascript.
First, pass in --env-vars API_BASE_URL=https://$API_BASE_URL \
to az containerapp create
. You could have a different container app for test than production.
Then you need to read the environment variable. There are different options depending on your app.
<script> const settings = { apiUrl = apiUrlFromEnvironmentVariable }</script>
tag. Don’t do this with secretsTo reduce the time from change to running, you need to install .NET debugging tools inside the container to communicate back to your ide
Adding this to your dockerfile should work
RUN apt-get update \
&& apt-get install -y --no-install-recommends unzip \
&& rm -rf /var/lib/apt/lists \
&& curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /remote-debugger
I’m excited about the prospects of using Azure App Containers. I think there is a big potential. If/when I get a chance to create a new app, I’m going to lobby to use Azure App Containers to host the web and api instead of using Azure App Service. That will leave the possibility open to use a microservice approach when it makes sense, instead of only adding functionality to the api or in Azure Functions that are off on there own.
I still have more to learn and will add more to this page as I make progress.
Please consider using Brave and adding me to your BAT payment ledger. Then you won't have to see ads! (when I get to $100 in Google Ads for a payout (I'm at $97.66!), I pledge to turn off ads)
Also check out my Resources Page for referrals that would help me.