Skip to content

Latest commit

 

History

History
99 lines (74 loc) · 3.85 KB

README.md

File metadata and controls

99 lines (74 loc) · 3.85 KB

DAPR Container Apps in Azure

Learning Azure Container Apps based on this guide from Microsoft

This repo contains code to deploy the Dapr hello-world application on Azure Container Apps with Dapr using Azure Storage Account for storing state.

Technologies

  • 🔨 Azure PowerShell and AZ CLI for interaction with Azure
  • ⚙️ PowerShell for deployment script
  • 💪 Bicep for Infrastructure as Code

Overview

diagram (diagram by Microsoft - CC BY 4.0)

Usage

Prerequisites

  1. Install/update Azure PowerShell module
  2. Install/update Azure CLI
    • Install containerapp extension: az extension add --name containerapp --upgrade (as of May 2022 this is not available in Azure PowerShell)
  3. Install/update Bicep CLI
  4. Connect to Azure:
    • Az Pwsh: Connect-AzAccount
    • az cli: az login
  5. Set Context:
    • Az Pwsh: Set-AzContext -SubscriptionName <subscription name>
    • az cli: az account set --name <subscription name>
  6. Register resource provider: Register-AzResourceProvider -ProviderNamespace Microsoft.App

Deploy

Open PowerShell and run deploy.ps1 to deploy the resources:

./deploy.ps1

# Example output
🚀 Deploying container apps...(this will take a few minutes)

✔️  Deploy succeeded! API url:
https://nodeapp.<unique name>.canadacentral.azurecontainerapps.io/order

⌛ Waiting for a minute before querying api and logs...

🔎 Querying /order API...
{
  "orderId": 99
}

🗒️  Querying logs from Log Analytics Workspace. Listing 5 latest entries...
[
  {
    "ContainerAppName_s": "nodeapp",
    "Log_s": "Got a new order! Order ID: 83",
    "TimeGenerated": "2022-05-20T21:36:37.839Z"
  },
  {
    "ContainerAppName_s": "nodeapp",
    "Log_s": "Got a new order! Order ID: 84",
    "TimeGenerated": "2022-05-20T21:36:37.839Z"
  },
  {
    "ContainerAppName_s": "nodeapp",
    "Log_s": "Got a new order! Order ID: 85",
    "TimeGenerated": "2022-05-20T21:36:39.674Z"
  },
  {
    "ContainerAppName_s": "nodeapp",
    "Log_s": "Got a new order! Order ID: 60",
    "TimeGenerated": "2022-05-20T21:36:13.533Z"
  },
  {
    "ContainerAppName_s": "nodeapp",
    "Log_s": "Got a new order! Order ID: 64",
    "TimeGenerated": "2022-05-20T21:36:17.643Z"
  }
]

Clean up resources

The services deployed are designed for demo purposes and they are quite chatty, which will result in Azure cost (mostly compute, logging, storage). Around $2-$3 daily.

To clean up resources run the following command:

Remove-AzResourceGroup -Name dapr-containerapps-demo -Force

Notice

The steps needed for this demo are closely based on this guide from Microsoft. The deployment logic and Bicep templates have been updated by me to fit an end-to-end demo deployment scenario and to use latest versions of tooling/providers.

The application deployed is the Dapr hello-world application.