This repository provides an example codes to build microservices using the Dapr and Azure Container Apps.
Follow these steps to get the project up and running:
- Install Dapr CLI: Follow the instructions here.
- Install Docker: Ensure Docker is installed and running on your machine. You can download it from here.
- Install .NET SDK: Download and install the .NET SDK from here.
-
Start 3rd party services:
docker compose -f ./docker/docker-compose.yaml up
-
Run the Multi-App:
dapr run -f ./dapr/dapr.yaml
-
Access the API:
- Weather API:
http://localhost:5123/weather
- Weather API:
Add hurricate watch message to hurricanes
queue:
{
"City": "Tampere",
"Category": 3
}
Follow these steps to deploy the solution to Azure.
Use following commands to create and push images to docker hub.
Set username:
export DOCKER_HUB_USERNAME=<your_username>
Tag and push images to Docker Hub.
docker build -t $DOCKER_HUB_USERNAME/dapr-weather-api:latest -f src/Weather.Api/Dockerfile .
docker push $DOCKER_HUB_USERNAME/dapr-weather-api:latest
docker build -t $DOCKER_HUB_USERNAME/dapr-weather-service:latest -f src/Weather.Service/Dockerfile .
docker push $DOCKER_HUB_USERNAME/dapr-weather-service:latest
docker build -t $DOCKER_HUB_USERNAME/dapr-weather-processor:latest -f src/Weather.Processor/Dockerfile .
docker push $DOCKER_HUB_USERNAME/dapr-weather-processor:latest
To deploy updates to Azure, follow these steps:
- Open terminal
- Log in using your Azure AD credentials:
az login
- Go to the directory:
cd infra/bicep
- First verify the changes using what-if command:
az deployment sub what-if --subscription {subscription} --location westeurope --template-file main.bicep --parameters {env}.bicepparam
- Deploy the changes:
az deployment sub create --subscription {subscription} --location westeurope --template-file main.bicep --parameters {env}.bicepparam
Here is a list of common problems you might encounter:
Failed to bind to address http://127.0.0.1:5123 address already in use
List process that uses the port and kill it.
sudo lsof -i -P | grep LISTEN | grep :5123
kill -9 <PID>