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.
- Receive "product" updates (pub/sub or input binding)
- Execute templating
- Push to static web (output binding)
- Cache state
- Push all on changed template
To recreate this project, follow this steps with the corresponding files and snippets as guide.
Following services are needed.
- Container instances
- Container registry
- Service Bus
- Storage (file share + static web)
- Application insights
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
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
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"}
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"
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]
- 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
- Key vault secrets