Usage instructions:
- Register app in your Azure AD with needed scopes, user roles and app roles
- Rename local.settings.sample.json to local.settings.json
- Put your Azure AD tenant id in the authority setting
- Put your app client ID in the client ID setting
There are a couple reflection hacks here that are bound to break at some point if the internals change. It was the only way I found to set the response status code from within a middleware since all the relevant classes are marked internal.