We are happy to introduce this Preview feature which enables you to run microservices and containerized applications on a serverless platform.
Considering the distributed nature of microservices, you need to account for failures, retries, and timeouts in a system composed of microservices. While Container Apps features the building blocks for running microservices, use of Dapr (Distributed Application Runtime) provides an even richer microservices programming model.
Azure Container Apps offers a fully managed version of the Dapr APIs when building microservices. When you use Dapr in Azure Container Apps, you can enable sidecars to run next to your microservices that provide a rich set of capabilities. Available Dapr APIs include Service to Service calls, Pub/Sub, Event Bindings, State Stores, and Actors.
In this blog, we demonstrate a sample Dapr application deployed in Azure Container Apps, which can:
Read input message from Azure Storage Queue using Dapr Input Binding feature
Process the message using a Python application running inside a Docker Container
Output the result into Azure Storage Blob using Dapr Output Binding feature
Azure account with an active subscription
Azure CLI Ensure you're running the latest version of the CLI via the upgrade command.
Using the following Docker command to create Docker image and push it to Docker hub.
cd "<the folder where you save your Dockerfile>"
$Dockerhubaccount="<your docker hub account name>"
docker build -t $Dockerhubaccount/daprbindingtest:v1 .
docker push $Dockerhubaccount/daprbindingtest:v1
Deploy Azure Container App with the Docker image and enable Dapr sidecar
Use "az containerapp create" command to create an App in your container app environment.
In the log, we should be able to see: - Successful init for output binding bloboutput (the name is defined in the daprcomponents.yaml) - Successful inti for input binding queueinput (the name is defined in the daprcomponents.yaml) - Application discovered on port 6000 (as we defined in Python application code) - Also Dapr should be able to send OPTIONS request to /queueinput, and get Http 200 response. That means the application can take message from input Storage Queue.
Run test to confirm your Container App can read message from Storage Queue and push the process result to Storage Blob
Now, let's add a new message in the Storage Queue.
After the application being successfully executed, we can find any output audio file in the output Storage Blob.
To check the application log, you can use Container App --> Logs Portal, run the following query command: