Skip to content

A sample of pushing static pages on change using dapr and azure aci.

Notifications You must be signed in to change notification settings

perokvist/Dapr.WebPush

Repository files navigation

Dapr.WebPush

This is a demo of a flow pushing a product web page/fragment to a static site, when product information changes, using dapr pub/sub and bindings.

Flow

Context to context communication

  • Receive "product" updates (pub/sub or input binding)
  • Execute templating
  • Push to static web (output binding)

TODO

  • Cache state
  • Push all on changed template

Guide

To recreate this project, follow this steps with the corresponding files and snippets as guide.

Azure

Following services are needed.

  • Container instances
  • Container registry
  • Service Bus
  • Storage (file share + static web)
  • Application insights

Docker and Compose

Files for full details;

Dapr components used;

Steps;

  • Create an app with a docker file.
  • Add a compose file to your solution
  • Add daprd to compose
  • Add the shared volume to the compose file
  • Upload the dapr components and config file to the file share (components folder)
  • Set the starting command for daprd to correspond with the file share
  • Add the telemetry collector to compose
  • Create a folder and upload configuration for "otel" collector
  • Configure volume in compose for the collector

Github Action

Follow along with the workflow file.

This workflow utilize secrets outlined in resources

  • Checkout
  • Install compose CLI
  • Login to Azure
  • Login to Container Registry
  • Build container
  • Push container to Registry
  • Login docker to Azure for context
  • Create an ACI context
  • Use Compose to push group to ACI

Product Data

 dapr publish --pubsub azurepubsub -t in -d '{\"Title\": \"Fancy Table\", \"Price\": 2500, \"Id\": 4}'

Using the dapr CLI we'll post this payload. This could be modified and sent via service bus explorer.

 {"id":"69136027-cb55-47cd-9b32-cdf27b3059f8","source":"push","type":"com.dapr.event.sent","specversion":"1.0","datacontenttype":"application/json","data":{"Title":"Fancy Table","Price":2500,"Id":4},"subject":"00-2c3a831ad26182bf444b131b84945393-792c2bb284a9f319-01","topic":"in","pubsubname":"azurepubsub"}

Application insights

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: native
  namespace: default
spec:
  type: exporters.native
  metadata:
  - name: enabled
    value: "true"
  - name: agentEndpoint
    value: "0.0.0.0:55678"
dapr run {.....} --config config/otel.config 
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: appconfig
  namespace: default
spec:
  tracing:
    samplingRate: "1"

Open Telemetry

receivers:
  opencensus:
      endpoint: 0.0.0.0:55678
exporters:
  azuremonitor:
  azuremonitor/2:
    endpoint: "https://dc.services.visualstudio.com/v2/track"
    instrumentation_key: "<KEY>"
    maxbatchsize: 100
    maxbatchinterval: 10s
service:
  pipelines:
    traces:
      receivers: [opencensus]
      exporters: [azuremonitor/2]

Deployment

  • Building an image
  • Push it to a Azure Conatiner Registry
  • Deploy it with Dapr through docker compose to ACI
  • Using a Azure File share for component config

Context to context communication

TODO

  • Key vault secrets

Resources

About

A sample of pushing static pages on change using dapr and azure aci.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published