publish CLI command reference

Detailed information on the publish CLI command

Description

Publish a pub-sub event.

Supported platforms

Usage

  1. dapr publish [flags]

Flags

NameEnvironment VariableDefaultDescription
—publish-app-id, -iThe ID that represents the app from which you are publishing
—pubsub, -pThe name of the pub/sub component
—topic, -tThe topic to be published to
—data, -dThe JSON serialized string (optional)
—data-file, -fA file containing the JSON serialized data (optional)
—help, -hPrint this help message
—metadata, -mA JSON serialized publish metadata (optional)
—unix-domain-socket, -uThe path to the unix domain socket (optional)

Examples

  1. # Publish to sample topic in target pubsub via a publishing app
  2. dapr publish --publish-app-id appId --topic sample --pubsub target --data '{"key":"value"}'
  3. # Publish to sample topic in target pubsub via a publishing app using Unix domain socket
  4. dapr publish --enable-domain-socket --publish-app-id myapp --pubsub target --topic sample --data '{"key":"value"}'
  5. # Publish to sample topic in target pubsub via a publishing app without cloud event
  6. dapr publish --publish-app-id myapp --pubsub target --topic sample --data '{"key":"value"}' --metadata '{"rawPayload":"true"}'

Last modified October 11, 2024: Fixed typo (#4389) (fe17926)