Cameleer

Azure Event Grid component

The azure-eventgrid component publishes events to an Azure Event Grid topic, as CloudEvents or in the Event Grid schema.

Scheme: azure-eventgrid: · Crate: cameleer-cloud · Cargo feature: cloud · Consumer: no · Producer: yes · Apache Camel: Azure Event Grid

When to use it

  • Publish business events (order placed, device offline) that Azure Functions, Logic Apps or webhooks subscribe to.
  • Bridge events from MQTT, Kafka or on-premises systems into Azure's event routing.

URI format

text
azure-eventgrid:topicEndpoint[?options]

The path is the topic endpoint URL, for example https://mytopic.westeurope-1.eventgrid.azure.net/api/events.

Example

Publish an OrderPlaced CloudEvent:

yaml example: azure-eventgrid-publish-order
- route:
    id: publish-order-event
    from:
      uri: "timer:order-event?repeatCount=1"
      steps:
        - setBody:
            constant: '{"orderId":"o-1001","total":99.5}'
        - unmarshal:
            json: {}
        - setHeader:
            name: CamelAzureEventGridEventType
            constant: Shop.OrderPlaced
        - setHeader:
            name: CamelAzureEventGridSubject
            constant: orders/o-1001
        - to: "azure-eventgrid:{{env:EVENTGRID_TOPIC_ENDPOINT:https://mytopic.westeurope-1.eventgrid.azure.net/api/events}}?accessKey=RAW({{env:EVENTGRID_ACCESS_KEY:}})"
        - log: "published event ${header.CamelAzureEventGridEventId}"

The body is the event data; a list body publishes one event per element.

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("timer:order-event?repeatCount=1")
        .set_body(constant(r#"{"orderId":"o-1001","total":99.5}"#))
        .unmarshal("json")
        .set_header("CamelAzureEventGridEventType", constant("Shop.OrderPlaced"))
        .set_header("CamelAzureEventGridSubject", constant("orders/o-1001"))
        .to("azure-eventgrid:{{env:EVENTGRID_TOPIC_ENDPOINT:https://mytopic.westeurope-1.eventgrid.azure.net/api/events}}?accessKey=RAW({{env:EVENTGRID_ACCESS_KEY:}})")
        .log("published event ${header.CamelAzureEventGridEventId}");
})?;

Options

optiondefaultdescription
eventSchemaCloudEventCloudEvent (CloudEvents 1.0 JSON batch) or EventGrid (Event Grid schema).
accessKeyTopic access key (aeg-sas-key header).
credentialTypeACCESS_KEY with a keyACCESS_KEY, AZURE_SAS (an aeg-sas-token: sharedAccessSignature, or one signed with accessKey), or Entra ID (tenantId, clientId, clientSecret, authorityHost; AZURE_IDENTITY reads AZURE_* variables).
sharedAccessSignaturePre-built SAS token.
sasTokenTtl3600Lifetime (seconds) of tokens signed with accessKey.
topicEndpointAlternative to the path.
uriEndpointOverride, proxyHost, proxyPort, trustAllCertificatesConnection settings.

Message headers

headerdirectiondescription
CamelAzureEventGridEventTypeinEvent type (default org.apache.camel.event).
CamelAzureEventGridSubjectinSubject.
CamelAzureEventGridSourceinCloudEvents source (default: the topic endpoint).
CamelAzureEventGridEventIdin/outEvent id (random UUID by default); the ids sent (a list for list bodies).
CamelAzureEventGridDataVersioninEvent Grid schema data version (default 1.0).
CamelAzureEventGridDataContentTypeinCloudEvents data content type (default application/json).

Run it with Docker

sh
docker run --rm -e EVENTGRID_TOPIC_ENDPOINT -e EVENTGRID_ACCESS_KEY \
  -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/events.camel.yaml

Common questions

How do I receive Event Grid events in a route?

Subscribe an Event Hub, a Storage queue or a Service Bus queue to the topic and consume it with azure-eventhubs, azure-storage-queue or azure-servicebus.

Which schema should I use?

CloudEvent for new topics; EventGrid when the topic was created with the Event Grid schema.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub