【发布时间】:2019-02-13 09:45:25
【问题描述】:
最近创建了 WebAPI2 网络服务来获取所有活动目录应用程序和用户的列表。应用程序和用户的本地 IIS 列表将使用 Azure AD Graph API 毫无问题地获取。
在 Azure 上将 webAPI2 作为资源部署时。用户列表将按预期获取,但使用以下代码获取的应用程序列表会引发错误。
调用以获取应用程序列表:
IPagedCollection<IApplication> applications= await activeDirectoryClient.Applications.ExecuteAsync();
错误堆栈
System.ArgumentNullException:值不能为空。 参数名称:类型 在 Microsoft.Data.Edm.EdmUtil.CheckArgumentNull[T](T 值,字符串参数名称) 在 Microsoft.Data.Edm.EdmTypeSemantics.AsComplex(IEdmTypeReference 类型) 在 Microsoft.Data.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideComplexValue, String propertyName, Boolean readRawValueE 在 Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadOpenProperty (IODataJsonLightReaderEntryState entryState, String propertyName, Boolean propertyWithValue) 在 Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadUndeclaredProperty (IODataJsonLightReaderEntryState entryState, String propertyName, Boolean propertyWithValue) 在 Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryPropertyWithValue(IODataJsonLightReaderEntryState entryState, String propertyName)
申请流程:
我的 Web 应用程序假设 A 调用 WebAPI B 以获取用户和应用程序列表。 webAPI 的应用程序类型是原生的,我正在使用 UserPasswordCredential 和 AcquireTokenAsync 来获取访问令牌。
【问题讨论】:
-
哇...您是否尝试过使用为客户端获取的访问令牌手动调用 API?
-
@juunas 是的,手动它工作正常。即使在我的本地 IIS 上也可以正常工作。但是,当在 Azure 上上传 WebAPI 时,应用程序列表会出现此问题。我还用应用程序流程更新了问题。
-
@juunas 我刚刚在另一个 .net 托管环境中部署了这个 webApi。它工作正常。在这个托管环境中,我们有专用的虚拟机和 IIS。但是我们需要在 Azure 上部署这个 WebAPI。感谢任何帮助。
-
@umer 我失败了,同样的错误,你解决了这个问题吗?
-
@umer 好消息,客户现在可以在生产环境中获取应用程序,我认为我没有进行任何更改。也许只有那一天有问题。
标签: azure asp.net-web-api2 azure-active-directory azure-ad-graph-api