Skip to main content

Cosmos DB Change Feed Trigger

The CameraOrchestratorFunction is the main entry point for the Image Acquisition Engine. It monitors the acquisitionDevice container in Cosmos DB and reacts to device configuration changes in real-time.

How It Worksโ€‹

Trigger Configurationโ€‹

The function is decorated with [CosmosDBTrigger]:

  • Database: Image acquisition database
  • Container: acquisitionDevice
  • Lease Container: Auto-created for change feed checkpointing
  • Connection: Loaded from Azure App Configuration

In release builds (#if !DEBUG), the Cosmos trigger is active. In debug builds, an HTTP endpoint (HttpStart) is available for manual testing.

Routing Logicโ€‹

When a change is detected, the orchestrator routes by camera manufacturer:

ManufacturerOrchestratorStatus
AxisVapixOrchestratorActive โ€” full implementation
MobotixMobotixOrchestratorSkeleton โ€” awaiting hardware integration

Batch Processingโ€‹

When the change feed delivers multiple device changes in a single batch (e.g., bulk deploy from Admin API):

  1. Each device is enqueued to the orchestration-redeploy queue
  2. The SingleImageMetadataCleanupDequeue queue trigger processes them in parallel
  3. This prevents the Cosmos trigger from being blocked by long-running orchestration setup

Decision Flowโ€‹

For each device change, the orchestrator decides:

  • Deploy โ€” No existing orchestration + isActive = true โ†’ start new
  • Redeploy โ€” Existing orchestration + isActive = true โ†’ terminate old, start new with latest config
  • Stop โ€” isActive = false โ†’ terminate running orchestration