We are running on .NET Core 2.1 and sometimes get the exception "Secure binary serialization is not supported on this platform" when running the following query:
await _adClient.Users[userId].AppRoleAssignments.ExecuteAsync();
Reexecuting the query often works, so some condition is being met in which the binary serialization is not attempted (or succeeds?) on subsequent requests? That said, if I restart the service it will often work on the first request too.
We are using the older AD Graph client because 1) Microsoft Graph client does not fully support AppRoleAssignments
yet and 2) what is supported is part of beta and not recommended for production use.
Full call stack below:
System.Data.Services.Client.BaseAsyncResult.EndExecute<T>(object source, string method, IAsyncResult asyncResult)
System.Data.Services.Client.QueryResult.EndExecuteQuery<TElement>(object source, string method, IAsyncResult asyncResult)
System.Data.Services.Client.DataServiceRequest.EndExecute<TElement>(object source, DataServiceContext context, string method, IAsyncResult asyncResult)
System.Data.Services.Client.DataServiceQuery<TElement>.EndExecute(IAsyncResult asyncResult)
Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper+<>c__DisplayClass4c<TSource, TInterface>.<ExecuteAsync>b__4a(IAsyncResult r)
System.Threading.Tasks.TaskFactory<TResult>.FromAsyncCoreLogic(IAsyncResult iar, Func<IAsyncResult, TResult> endFunction, Action<IAsyncResult> endAction, Task<TResult> promise, bool requiresSynchronization)
Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper.ExecuteAsync<TSource, TInterface>(DataServiceQuery<TSource> inner)
Microsoft.Azure.ActiveDirectory.GraphClient.AppRoleAssignmentCollection.<ExecuteAsync>b__2()
Merck.SeaMonkey.Api.AzureADApi.Controllers.UserController.GetApplicationRoleAssignments(string userId) in UserController.cs
The new Microsoft Graph client is not an option here, although I suppose we can drop down to the base REST interface, which is a bit of work with all the retry logic, result parsing, etc. that we'd relied on the graph client to do.
UPDATE: Give the source of the exception, we're presuming there's an issue in serializing an entity in the OData response. Using AD Graph Explorer though, we see a very simple response of an empty values array along with a link to the metadata document for the entity. We have made the issue recur often by removing and adding new app role assignments, but we can't force it to occur 100% reliably. It looks like some state is being corrupted, perhaps in some internal cache?