Cli-microsoft365: Question: Using m365 teams team list is there a limit to the number of teams

Created on 9 Nov 2020  路  10Comments  路  Source: pnp/cli-microsoft365

I have attempted to use the m365 teams team list in our production tenant today. I have had no problem in the test environment which has around 90 teams.

Our production environment has 1500+ teams and growing daily. When I run this command I get a response:
connect ETIMEDOUT [ip address]

So is there a limit? Is there a way I can call this command in a paging way?

question

Most helpful comment

I'm trying to retrieve all teams. I did try the command with --debug and there was lots of throttling when it was calling getTeamFromGroup.

I need to do some more testing, as I ran the command in PowerShell Core using my account. When it failed it was running inside a PowerShell 5.1 devops pipeline with a service principal account. Unfortunately I need to run it in PowerShell 5.1 at the moment as I have some calls in the script that cannot be converted.

Let me do some more testing and get back to you.

All 10 comments

The command already supports paging and right now we use the default page size as defined by Microsoft Graph. Are you trying to retrieve joined- or all teams?
Have you also tried to use the --debug switch to see if it's the first call that's failing already or if some of them come true and it fails at some later point?

I'm trying to retrieve all teams. I did try the command with --debug and there was lots of throttling when it was calling getTeamFromGroup.

I need to do some more testing, as I ran the command in PowerShell Core using my account. When it failed it was running inside a PowerShell 5.1 devops pipeline with a service principal account. Unfortunately I need to run it in PowerShell 5.1 at the moment as I have some calls in the script that cannot be converted.

Let me do some more testing and get back to you.

Hi @waldekmastykarz, I have attempted to do some extra testing today. I've been using PowerShell Core with a Service Principal AppID and Certificate.

I have attempted to run the following numerous times:
m365 teams team list

Sometimes I get a result, sometimes I get "Request failed with status code 500", other times I get a 502 or 504 status code.

500 response

Request error
data      : {"error":{"code":"InternalServerError","message":"Failed to execute backend request.","innerError":{"date":"2020-11-13T12:53:32","request-id":"67ec0087-0833-4e7a-b682-f4b92f18ca8d","client-request-id":"67ec0087-0833-4e7a-b682-f4b92f18ca8d"}}}
headers   : {"cache-control":"private","content-type":"application/json","request-id":"67ec0087-0833-4e7a-b682-f4b92f18ca8d","client-request-id":"67ec0087-0833-4e7a-b682-f4b92f18ca8d","x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"SliceC\",\"Ring\":\"5\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"AGSFE_IN_9\"}}","strict-transport-security":"max-age=31536000","date":"Fri, 13 Nov 2020 12:53:32 GMT","connection":"close","content-length":"307"}
status    : 500
statusText: Internal Server Error

502 response (haven't been able to get it while using --debug)
504 response just got error message saying request response 504.

When I don't get an error status message, it does display all on screen with a green "DONE" at the end, so the command does work.

Also when I did

$teamSites = m365 teams team list -o json
$teamSites > teamsitesfile.json

The teamsitesfile.json isn't complete and is not a complete json file. I cannot provide you with the file, but I have done this 3 times now, and each time the teamsitesfile.json is 1869 lines long, and that line is half an id value.

{
    "id": "b217af

This is also a problem if I'm calling:

$teamSitesJson = m365 teams team list -o json | ConvertFrom-Json

but not when I called

$teamSitesJsonId = m365 teams team list --query "[].{id:id}" -o json | ConvertFrom-Json

I think there is two problems here. One is the 500 and 502 issues I'm getting, which is probably being caused by the mass throttling. The other is that the json output is not working for large amounts of data.

Looking at the code, maybe there needs to be another command to prevent the code calling getTeamFromGroup() after retrieving the Teams. It seems this is only checking the archive of the team. Maybe --checkArchiveStatus. All I really need is a list of Teams, the graph call

`${this.resource}/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$select=id,displayName,description`

would be enough.

Is there anything else I can test/try to provide better information to you?

We've just got reported #1953 and I wonder if this is the same issue. Typically, 5xx errors are coming from the service and are not something we can do anything about. That said, if you get these errors consistently when trying to retrieve all Teams and there is no service downgrade then I will follow this up with folks from the Graph team to see if they know anything more about it.

As for the truncated output, it seems like #1266 which is related to an odd behavior in PowerShell. So far, we haven't been able to find a solution for it, but let's give it another shot and see if we can create a clean repro outside of the CLI to prove that it's indeed an issue with PowerShell.

I have more information regarding the truncated output in PowerShell, which I added to #1266. Let's track it there and leave this issue for resolving the issue around retrieving Teams from M365.

The truncated output in PowerShell has been solved and is fixed in the latest beta release.

Thank you. I will test it out tomorrow.

Awesome! Looking forward to hear how it's working for you.

@waldekmastykarz I can confirm that I can receive all items as json now. Thank you. Also ran 3 times in a row without an error.

Earlier in this question I asked about if another command could be added to skip checking Archive Status. For people who just want a list of teams, this would make this call a lot quicker and less throttling on tenants with large numbers of teams.

Looking at the code, maybe there needs to be another command to prevent the code calling getTeamFromGroup() after retrieving the Teams. It seems this is only checking the archive of the team. Maybe --checkArchiveStatus. All I really need is a list of Teams, the graph call

${this.resource}/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$select=id,displayName,description
would be enough.

Is this something that could be considered? I'm not concerned what the extra command is called. I just want to get a list of teams as quickly without causing throttling when there is no need to. Happy to open a new issue if it's something that could be considered.

Awesome to hear you're unblocked @pmatthews05. I think it's a valid suggestion for us to let you choose if you want to check archive status or not. If you could please open a separate issue, then we'll pick it up from there. Appreciate your help! 馃憦

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewconnell picture andrewconnell  路  3Comments

garrytrinder picture garrytrinder  路  3Comments

aakashbhardwaj619 picture aakashbhardwaj619  路  3Comments

OodapowUiPath picture OodapowUiPath  路  3Comments

VelinGeorgiev picture VelinGeorgiev  路  3Comments