0

I am trying to get all assets from an azure media service account, Here is my code:

MediaContract mediaService = MediaService.create(MediaConfiguration.configureWithOAuthAuthentication(
                    mediaServiceUri, oAuthUri, AMSAccountName, AMSAccountKey, scope));
List<AssetInfo> info = mediaService.list(Asset.list());

However, this only gives me 1000 of them, and there are definitely more than that in the account.

In Azure table query, there is a token to be used to get more entries if there are more than 1000 of them.

Does anybody knows how I can get all assets for azure media service?

Thanks,

Community
  • 1
  • 1
Kenneth
  • 41
  • 5

2 Answers2

3

With Alex's help, i am able to hack the java-sdk the same way as this php implementation

Here are the codes:

        List<AssetInfo> allAssets = new ArrayList<>();
        int skip = 0;
        while (true) {
            List<AssetInfo> curAssets = mediaService.list(getAllAssetPage(skip));
            if (curAssets.size() > 0) {
                allAssets.addAll(curAssets);
                if (curAssets.size() == 1000) {
                    System.out.println(String.format("Got %d assets.", allAssets.size()));
                    skip += 1000;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
        private static DefaultListOperation<AssetInfo> getAllAssetPage(int skip) {
            return new DefaultListOperation<AssetInfo>("Assets",
            new GenericType<ListResult<AssetInfo>>() {
            }).setSkip(skip);
        }
Kenneth
  • 41
  • 5
1

it is the built-in limit due to performance reasons (and REST v2), i believe. I think there is no way to retrieve all of them by one query. It is possible, however, to use take and skip 1000 by 1000 etc.

But i see that you use MediaContract class, and i could not find it in the .NET repository - i guess it is Java one? I can't comment on that, but i believe the approach should be the same as described in the article (skip/take). I have found the PHP implementation, maybe will be helpful.

https://msdn.microsoft.com/library/gg309461.aspx#BKMK_skip

Alex Belotserkovskiy
  • 4,012
  • 1
  • 13
  • 10
  • Alex, Thanks a lot for the info. Seems that java sdk doesn't have the capability to skip either, so the only option for me is to query the restful endpoint directly probably? – Kenneth Apr 21 '16 at 23:52
  • I believe so. I searched SDK repository again and did not find the ready implementation. – Alex Belotserkovskiy Apr 22 '16 at 05:17