Azure Event Grid libraries for Java

Build event-driven applications that listen and react to events from Azure services and custom sources using simple HTTP-based event handling with Azure Event Grid.

Learn more about Azure Event Grid and get started with the Azure Blob storage event tutorial.

Client SDK

Create events, authenticate, and post to topics using the Azure Event Grid Client SDK.

Add a dependency to your Maven pom.xml file to use the client library in your project.


Publish events

The following code authenticates with Azure and publishes a List of EventGridEvent events of a custom type (in this example, Contoso.Items.ItemsReceived ) to a topic. The topic key and endpoint address used in the sample can be retrieved from the Azure CLI:

az eventgrid topic show -g gridResourceGroup -n topicName
az eventgrid topic key list -g gridResourceGroup -n topicName
// Create an event grid client.
TopicCredentials topicCredentials = new TopicCredentials(System.getenv("EVENTGRID_TOPIC_KEY"));
EventGridClient client = new EventGridClientImpl(topicCredentials);

// Publish custom events to the EventGrid.
System.out.println("Publish custom events to the EventGrid");
List<EventGridEvent> eventsList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
    eventsList.add(new EventGridEvent(
        String.format("Door%d", i),
        new ContosoItemReceivedEventData("Contoso Item SKU #1"),

String eventGridEndpoint = String.format("https://%s/", new URI(System.getenv("EVENTGRID_TOPIC_ENDPOINT")).getHost());

client.publishEvents(eventGridEndpoint, eventsList);

Management SDK

Create, update, or delete Event Grid instances, topics, and subscriptions with the Event Grid management SDK.

Add a dependency to your Maven pom.xml file to use the client library in your project.


The following example creates an Event Grid subscription, taken from the EventGrid Java samples

// Create an event grid subscription.
System.out.println("Creating an Azure EventGrid Subscription");

EventSubscription eventSubscription = eventGridManager.eventSubscriptions().define(eventSubscriptionName)
    .withDestination(new EventHubEventSubscriptionDestination()
    .withFilter(new EventSubscriptionFilter()