Handles incoming events from OSDU/Azure Data Manager for Energy and relays them to Azure Event Grid.
3.9K
Small Azure Functions relay that accepts OSDU notifications, validates HMAC signatures (incl. OSDU challenge/handshake), optionally translates OSDU DataNotification payloads into Azure Event Grid events, and forwards them to an Event Grid topic.
/api/osdu-relay80 (map to your host, e.g., -p 7071:80)mcr.microsoft.com/azure-functions/python:4-python3.12Pull and run with required environment variables:
# PowerShell
$IMAGE = "docker pull eirikhaughom/adme-notification-relay:main"
docker pull $IMAGE
docker run --rm --name adme-notification-relay `
-p 7071:80 `
-e EVENT_GRID_ENDPOINT="https://<topic-or-domain>.<region>.eventgrid.azure.net/api/events" `
-e EVENT_GRID_AUTH="key" `
-e EVENT_GRID_KEY="<event-grid-access-key>" `
-e HMAC_SECRET="<hex-or-string-secret>" `
$IMAGE
Then call the function:
GET http://localhost:7071/api/osdu-relayGET http://localhost:7071/api/osdu-relay?crc=...&hmac=...POST http://localhost:7071/api/osdu-relayFor local dev with Azurite, use docker compose so the function can reach a local Storage emulator. See the repo’s docker-compose.yml for an example.
responseHash expected by clients.Minimum to run:
EVENT_GRID_ENDPOINT (required): Event Grid publish endpoint.
https://<topic or domain>.<region>.eventgrid.azure.net/api/eventsHMAC_SECRET or Key Vault settings (one of): HMAC secret to validate signatures.
HMAC_SECRET (simple local/dev), OR one of the Key Vault options below.Auth modes for Event Grid (set EVENT_GRID_AUTH):
managed (default): Managed Identity/AAD using environment credentials
sp: Service Principal (Client ID/Secret)
AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET (or the EVENT_GRID_* overrides below).key: Access Key header
EVENT_GRID_KEY.Key Vault (optional, to fetch HMAC_SECRET at runtime):
KEY_VAULT_SECRET_URI OR KEY_VAULT_URL + KEY_VAULT_SECRET_NAMEKEY_VAULT_AUTH = managed (default) or sp with AZURE_* or KEY_VAULT_* overridesEvent Grid Namespace (optional):
EVENT_GRID_NAMESPACE_TOPIC: Namespace Topic name (only for Namespace endpoints)EVENT_GRID_CLOUD_SOURCE (default /osdu/relay): CloudEvent source when converting for NamespaceService Principal overrides (optional, when using *_AUTH=sp):
AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRETKEY_VAULT_TENANT_ID, KEY_VAULT_CLIENT_ID, KEY_VAULT_CLIENT_SECRETEVENT_GRID_TENANT_ID, EVENT_GRID_CLIENT_ID, EVENT_GRID_CLIENT_SECRETSignature and translation settings (optional):
HMAC_HEADER (default Authorization), SIGNATURE_PREFIX (default hmac), SIGNATURE_FORMAT (hex|base64)CHALLENGE_HMAC_REQUIRED (default true), CHALLENGE_HASH_ENCODING (base64-hex default, base64, or hex)EVENT_TYPE_MODE (single default or by_op), EVENT_TYPE_* variablesFor the full list and details, see the project README in the repository.
# PowerShell
$env:AzureWebJobsStorage = "<YOUR_STORAGE_CONN_STRING>"
$env:EVENT_GRID_ENDPOINT = "https://<topic>.<region>.eventgrid.azure.net/api/events"
$env:EVENT_GRID_AUTH = "key"
$env:EVENT_GRID_KEY = "<event-grid-access-key>"
$env:HMAC_SECRET = "<hex-or-string-secret>"
docker run --rm -p 7071:80 --name osdu-notification-broker `
-e AzureWebJobsStorage `
-e EVENT_GRID_ENDPOINT -e EVENT_GRID_AUTH -e EVENT_GRID_KEY `
-e HMAC_SECRET `
<IMAGE>:<TAG>
Send an OSDU payload; the service will translate and forward when appropriate:
curl -X POST "http://localhost:7071/api/osdu-relay" \
-H "Content-Type: application/json" \
-H "Authorization: hmac <signature>" \
--data '[{"id":"opendes:doc:123","kind":"opendes:doc:0.2.0","op":"create"}]'
Add ?dryRun=1 to see the translated Event Grid batch without forwarding.
KEY_VAULT_SECRET_URI.Set app env vars:
EVENT_GRID_AUTH=managedEVENT_GRID_ENDPOINT=...KEY_VAULT_SECRET_URI=... (or HMAC_SECRET)EVENT_GRID_NAMESPACE_TOPIC=... if using a Namespace80 (map as needed)GET /api/osdu-relay returns 200 OK when the host is upGET /api/osdu-relay?crc=...&hmac=... returns { "responseHash": "..." } on successAzureWebJobsStorage at the Azurite endpoints.SIGNATURE_FORMAT.Content type
Image
Digest
sha256:54efa8ef5…
Size
10.7 kB
Last updated
12 months ago
docker pull eirikhaughom/adme-notification-relay:sha256-09b436ac0664d3f4a5abbe243248a5f70c6be57c626e196cf96acd6c87f8af27