从ACS获取服务标识时,我可以使用分页吗?

时间:2012-02-08 01:52:00

标签: service azure identity acs

背景 我需要一个列表,列出我在Azure ACS中注册的所有服务标识名称。我有一个来自https://myaccesscontrol.accesscontrol.windows.net/v2/mgmt/service的Azure管理服务参考。对于此讨论,“myaccesscontrol”前缀是任意的。如果我理解正确的话,您可以使用不同的订阅名称空间前缀并获得相同的结果。这是Azure订阅时提供给我的服务端点。它公开了一个ManagementService接口。当我得到服务标识列表时

  DataServiceQuery<ServiceIdentity> identities = managementService.ServiceIdentities;

我找回了一个对象,它具有我期望的所有身份的数量。当我展开列表时,我得到前50个。这是典型的分页响应,我希望有一个延续令牌可以让我获得下一个“页面”。

问题 我看不出如何使用ManagementServiceReference.ManagementService接口来获取延续令牌。

讨论 如何:在http://msdn.microsoft.com/en-us/library/ee358711.aspx加载分页结果(WCF数据服务)提供了一个示例,可以查询来自LINQ上下文的QueryOperationResponse响应以继续                 token = response.GetContinuation() QueryOperationResponse是从LINQ上下文Execute()。

中检索的

在我的一些Azure示例代码中,有一些blob,表和队列的分页示例,其中数据是在ResultSegment中收集的。 ResultSegment有一个布尔HasMoreResults成员,一个ResultContinuationToken ContinuationToken成员,以及接受和维护这些成员以支持分页操作的方法。

我没有看到如何从DataServiceQuery获取Continuation。我没有看到Azure公开的ManagementServiceReference.ManagementService支持分页的服务标识列表,即使该服务显然是在分页它发送给我的结果。你能否指出我正确的文章,它将告诉我如何以一种延续回来的方式处理DataServiceQuery?

1 个答案:

答案 0 :(得分:1)

使用可用的管理服务示例项目here,您想要的内容如下所示:

ManagementService mgmtSvc = ManagementServiceHelper.CreateManagementServiceClient();
List<ServiceIdentity> serviceIdentities = new List<ServiceIdentity>();

// Get the first page
var queryResponse = mgmtSvc.ServiceIdentities.Execute();
serviceIdentities.AddRange( queryResponse.ToList() );

// Get the rest
while ( null != ( (QueryOperationResponse)queryResponse ).GetContinuation() )
{
    DataServiceQueryContinuation<ServiceIdentity> continuation =
        ( (QueryOperationResponse<ServiceIdentity>)queryResponse ).GetContinuation();
    queryResponse = mgmtSvc.Execute( continuation );
    serviceIdentities.AddRange( queryResponse.ToList() );
}
相关问题