In Azure Service Bus scenarios, a descriptive
IAzureServiceBusMessageRouter implementation can be injected into your function, which gives you access to the message routing and by extension your registered message handlers.
Remove exception details from health report in Web API project template
The OpenAPI documentation is by default available in the Web API project template (but can be excluded if needed). Adding the OpenAPI documentation to your API also means that the API models used during request/response will be externalized in the OpenAPI endpoint JSON. It was by inspecting this OpenAPI documentation that we saw a problem with the default application health endpoint that is available in the Web API project template. This endpoint used Microsoft’s
HealthReport model which can include exception details when the application is unhealthy. Generating the OpenAPI document caused failures because the exception details could contain possible internal type information which resulted in an enormous amount of types that needed to be included in the document. Moreover, from a security perspective, this is not a good approach because it leaks information about the internal system. It could even leak application types that aren’t used in the API.
We solved this problem by adding a custom API model to the template. This custom model is an exact copy of Microsoft’s
HealthReport except that it doesn’t contain any exception details. It still has a description, data and tags to inform the user why the application is healthy or not, but it doesn’t burden the recipient with internal information.
The health endpoint available in the Web API project template uses this new API model as a way to expose the application’s health. For more information on the Web API project template, see our official documentation.
Hide JSON serialization behind maintainable extensions
The Arcus templates are especially useful for speeding up development and removing the need to write boilerplate code. With message handling, secret management and more, we have all sorts of ways to abstract a problem into business components. However, sometimes the boilerplate functionality is not that big. The Web API project template used to have some lines of code to restrict and configure the JSON serialization. It was not a lot but it was enough to make the application startup code dirty and less maintainable. The code removes output formatters, changing how the JSON serialization handles enumerations, etc.
This is what it looked like before. This piece of code was added to every new project result of the Web API project template.
If we decide to change this strategy, we couldn’t provide support to consumers who already ran the template in their project. A previous Web API release made sure that our JSON serialization strategy is accessible through the MVC options, which makes it not only cleaner but more maintainable.
The code sample is the actual result of how the Web API project template now handles JSON serialization. As you can see, it is a much cleaner and safer approach. For more information on the Web API project template, see our official documentation.
.NET 6 support
The v0.8 Templates end the long journey of adding .NET 6 support to Arcus. All of the dependent libraries were already targeting both .NET Core and .NET 6, but now the template projects are also fully .NET 6 compatible. Unlike the libraries, the templates don’t require multi-target support, so the .NET 6 features can be used freely.
We’ve learned a lot by adding this kind of widespread support to Arcus and plan to use that knowledge in the future when .NET 7 arrives.
The Templates v0.8 release was much-requested. It took us some time to fully make these project templates not only .NET 6 compatible, but to use the latest features and Arcus changes from dependent libraries. Now, these templates are finally finished and can be used in your next project.
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!
Subscribe to our RSS feed