all Technical posts

The Long Overdue Arcus EventGrid v3.2 Release

Version v3.2 of the Arcus EventGrid library was released recently, almost two years after v3.1. Here's a long overdue, quick run-down of the new features and changes in this release.

EventGrid Authorization with Arcus Secret Store

We provide support for endpoint validation, when implementing your own custom web hook. This validation allows you to secure your web hook with a secret key (taken from the query string or an HTTP header).

This is needed because Azure EventGrid sends a validation request to a newly configured web hook, in order to prevent people leveraging Azure EventGrid to bring down a 3rd party API.

Authorization with Azure EventGrid was previously done with an attribute where the secret was managed internally. This approach was more a ‘proof of concept’ than a production-ready implementation. The new version uses the Arcus secret store as a way of handling secrets and can be assigned globally on the entire Web application or locally on specific operations.

Configuring the authorization globally is as easily done as our Web API security filters. The following example shows how the x-api-key HTTP header can be used to look for the secret value. This value should be the same value as the one retrieved from the Arcus secret store with the name MySecret.

Enforcing authorization on operation level is done via a dedicated attribute:

For more information on endpoint authorization, see our official documentation page.

Event Subscription Validation with CloudEvents Support

Starting from v3.2, we also support CloudEvents when validating incoming events. Previously, we only validated EventGrid events. The full explanation of how to receive and validate events is fully described in these Microsoft docs. The short version is that in case of EventGrid events, the Aeg-Event-Type HTTP header and that the request body contains a SubscriptionValidation event model. In case of CloudEvents, a OPTIONS HTTP method should be used and validation happens on the WebHook-Request-Origin HTTP header.

Adding such an event validation to your application usually is only necessary on a single operation. Therefore, this feature is not available to be globally registered.

For more information on endpoint validation, see our official documentation page.

Strongly-Typed Event Filtering in Automated Testing

The EventGrid library provides testing infrastructure to allow integration tests run against an Azure EventGrid resource. The result of your integration test can be sent to Azure EventGrid, and the Arcus code makes sure that you receive the typed event. This way of testing is also broadly used across Arcus components (messaging, background jobs, templates) to verify if a certain piece of functionality works as expected. Once you want to test some Azure-running functionality without any access to the code, this testing strategy will help greatly.

An overview of this setup is available on our documentation site and is also shown here:

The ‘host’ runs alongside your integration tests and manages the event subscription. As test writer, you only have to concern yourself with the actual event assertion. A simple setup can look like this:

Notice that in the assertion, you can choose to receive your event with the unique identifying ID for which an event was published. In the new v3.2 version, we allow multiple ways of retrieving back your event. This makes assertion a lot easier and test-friendly because the writer doesn’t have to concern themselves with casting or deserialization. A custom filtering of the event let you choose how you want to retrieve the event back; i.e. based on the event subject, or a custom event data property. It’s all possible for both EventGrid and CloudEvent events.

For more information on the infrastructure provided for your integration testing, see our official documentation.

.NET 6 Support

This release also finally makes sure that that the EventGrid functionality can be used in .NET 6 projects. This is not the last step in fully supporting .NET 6 in Arcus, but is a major step forward.

Conclusion

This new version of Arcus EventGrid was long overdue. A lot of new features are finally released, together with full .NET 6 support. At time of writing, this new version is already implemented in the upcoming Arcus releases and tests. That’s how useful and reusable the library is.

See our official documentation for more information on all the currently supported features. If you have any questions, remarks, comments, or just want to discuss something with us, feel free to contact the Arcus team at Codit.

Thanks for reading!
-Arcus team

Subscribe to our RSS feed

Thanks, we've sent the link to your inbox

Invalid email address

Submit

Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address

Submit

Great you’re on the list!