Announcing the new Azure Event Grid Client Libraries

Announcing the new Azure Event Grid Client Libraries

In this release, we’ve simplified the API surface, added distributed tracing, and added support for publishing using the CloudEvent schema and custom event schemas.

We are pleased to announce that the new Azure Event Grid libraries have reached general availability (GA). Version 4 of the Azure Event Grid packages have now been released (.NETJavaPython and JavaScript/TypeScript), following the new Azure SDK guidelines. These guidelines provide consistency across all Azure SDK client libraries while also allowing each language to follow the idioms for their respective languages.

This library is the result of months of development, design discussions, feedback, and observing developers in user studies as they worked with Azure Event Grid. In this release, we’ve simplified the API surface, added distributed tracing, and added support for publishing using the CloudEvent schema and custom event schemas.

Cross Service SDK improvements

The new Event Grid client libraries allow Event Grid developers to take advantage of the cross-service improvements made to the Azure development experience, such as:

  • Core credential types to share a single authentication approach between clients
  • A unified logging and diagnostics pipeline offering a common view of the activities across each of the client libraries

In particular, the new Event Grid libraries use the core AzureKeyCredential type for authenticating the service client.

C#

EventGridPublisherClient client = new EventGridPublisherClient(
    new Uri("<endpoint>"),
    new AzureKeyCredential("<access-key>"));

Java

EventGridPublisherClient<EventGridEvent> eventGridEventClient = new EventGridPublisherClientBuilder()
    .endpoint("<endpoint>")
    .credential(new AzureKeyCredential("<access-key>"))
    .buildEventGridEventPublisherClient();

JavaScript

const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid");
const client = new EventGridPublisherClient("<endpoint>", "EventGrid", new AzureKeyCredential("<access-key>"));

Python

from azure.core.credentials import AzureKeyCredential
from azure.eventgrid import EventGridPublisherClient
credential = AzureKeyCredential("<access-key>")
client = EventGridPublisherClient("<endpoint>", credential)

New features

In addition to the cross-service improvements, Version 4 of the library includes several new features specific to Event Grid: – Support for publishing events using the **[CloudEvent](https://cloudevents.io/) schema** to topics which are configured to use the CloudEvent V1 schema.

C#

var cloudEvent = new CloudEvent(
    source: "/cloudevents/example/source",
    type: "Example.EventType",
    data: new MyDataModel() { A = 5, B = true });

await client.SendEventAsync(cloudEvent);

Java

// Initialize the client for use with the cloud event schema
EventGridPublisherClient<CloudEvent> publisherClient = new EventGridPublisherClientBuilder()
    .endpoint("<endpoint>")
    .credential(new AzureKeyCredential("<access-key>"))
    .buildCloudEventPublisherClient();

User newUser = new User("John2", "James");
CloudEvent cloudEventModel = new CloudEvent("https://com.example.myapp", "User.Created.Object",
BinaryData.fromObject(newUser), CloudEventDataFormat.JSON, "application/json");
publisherClient.sendEvents(cloudEventModel);

JavaScript

// Initialize the client for use with the cloud event schema
const client = new EventGridPublisherClient(
  "<endpoint>",
  "CloudEvent",
  new AzureKeyCredential("<access-key>")
);

// Send an event to the Event Grid Service, using the Cloud Event schema.
// A random ID will be generated for this event, since one is not provided.
await client.send([
  {
    type: "com.example.cloudevent",
    source: "/azure/sdk/eventgrid/samples/sendEventSample",
    data: {
      message: "this is a sample event"
    }
  }
]);

Python

client.send([
    CloudEvent(
        type="Contoso.Items.ItemReceived",
        source="/contoso/items",
        data={
            "itemSku": "Contoso Item SKU #1"
        },
        subject="Door1"
    )
])
  • Support for publishing events using a custom schema to topics which are configured to use a custom schema. Custom schema events are useful in situations where you are dealing with events that do not match either the CloudEvent or the Event Grid schema, but you would still like to use Azure Event Grid. In both Java and .NET, custom events are represented with the BinaryData type. This is a common type used across several messaging libraries in Java and .NET, including Service Bus, Event Hubs, and Storage Queues.

azure sdk releases

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Azure SDK Release (January 2020) | Azure SDKs

This month, we have promoted three of the client libraries to general availability, and expanded our service support to include a preview SDK for our first Cognitive Service: the Azure Text Analytics service. The new generally available libraries being released this month are: Azure App Configuration Azure Key Vault Certificates Azure Event Hubs These are ready to use in your production applications.

Azure SDK Release (March 2020) | Azure SDKs

Welcome to the March release of the Azure SDK. We have updated the following libraries: App Configuration (Java only). Event Hubs. Key Vault Certificates, Keys, and Secrets v4.0. Storage Blobs, File Shares, and Queues. Storage Data Lake (new GA release). These are ready to use in your production applications.

Azure SDK Release (May 2021)

Thank you for your interest in the new Azure SDKs! We release new features, improvements, and bug fixes every month. Please subscribe to our Azure SDK Blog RSS Feed to get notified when a new release is available.

Azure SDK Release (February 2020) | Azure SDKs

Welcome to the February release of the Azure SDK. We have updated the following libraries: Cosmos DB (JavaScript only). Event Hubs (Java and JavaScript). Key Vault (Python only). Storage (Blobs, Files, and Queues). These are ready to use in your production applications.

Azure SDK: What's new in the Azure Identity August 2020 General Availability Release

Since we shipped the first Azure Identity library preview in June 2019, it has been a vital part of building Azure cloud solutions. We have received great feedback from our development community and have added new features and have fixed many bugs.