Azure Event Grid topic publish: A request was made to load the default HttpClient provider but one could not be found on the classpath

Viewed 122

I am trying to send azure cloud events from maven project to azure event grid topic, I'm getting below error when trying to send the message

Error while sending the message to Event grid topic : A request was made to load the default HttpClient provider but one could not be found on the classpath. If you are using a dependency manager, consider including a dependency on azure-core-http-netty or azure-core-http-okhttp. Depending on your existing dependencies, you have the choice of Netty or OkHttp implementations. Additionally, refer to https://aka.ms/azsdk/java/docs/custom-httpclient to learn about writing your own implementation.

Below are the dependencies I am using

<dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-core</artifactId>
        <version>1.15.0</version>
    </dependency>
    <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-messaging-eventgrid</artifactId>
    <version>4.1.0</version>
</dependency>

Below is the code I'm using to send to event grid topic

EventGridPublisherClient<CloudEvent> cloudEventClient = new EventGridPublisherClientBuilder()
                        .endpoint(eventGridTopic)
                        .credential(new AzureKeyCredential(eventGridKey))
                        .buildCloudEventPublisherClient();
                cloudEventClient.sendEvent(new CloudEvent(AppConstants.SOURCE + env, AppConstants.MESSAGE_TYPE, BinaryData.fromObject(json), CloudEventDataFormat.JSON, MediaType.APPLICATION_JSON));

0 Answers
Related