I'm working on an Angular application, and I need to implement Azure Event Grid subscription directly from the client-side without involving a backend service layer. I've researched various approaches but haven't found a clear solution.
Here are my requirements and what I've tried:
Requirements:
- Subscribe to Azure Event Grid from the Angular application.
- Avoid using a backend service layer for the subscription process.
What I've Tried:
Explored the Azure SDK for JavaScript, but it seems primarily designed for Node.js.
Investigated using @azure/eventgrid library, but encountered issues related to the lack of support in a browser environment.
Question Details:
- Is it possible to subscribe to Azure Event Grid directly from an Angular application without relying on a backend service?
- Are there any client-side libraries or methods available for handling Azure Event Grid subscriptions in a browser environment?
- If a backend service layer is unavoidable, what is the minimal setup required to achieve Azure Event Grid subscription with Angular?
Code Snippet tried in nodejs:
const eventSubscriptionInfo = {
destination: {
endpointType: "WebHook",
endpointUrl: endpointUrl,
},
filter: {
isSubjectCaseSensitive: false,
subjectBeginsWith: "",
subjectEndsWith: "",
includedEventTypes: ["All"],
},
};
const credential = new DefaultAzureCredential();
const client = new EventGridManagementClient(credential, subscriptionId);
const result = await client.eventSubscriptions.beginCreateOrUpdateAndWait(
scope,
eventSubscriptionName,
eventSubscriptionInfo
);
Environment Details:
Angular version: Angular 15
Azure SDK: 5.0.0
Data for an event gird event is received as a JSON object in the body of an http request, and unfortunately there is no way to handle HTTP request on the client side. thus you will need a server app that will listen for those HTTP request and emit HTTP responses.