如何增加 Microsoft Graph API 订阅限制?Microsoft、Graph、API

2023-09-07 09:05:03 作者:不知我者怎居我心

我还没有找到使用图表订阅所有用户更改的方法,它 看起来不可能.

I have not been able to find a method of using the graph to subscribe to all users changes, it looks like it is not possible.

所以我开始单独订阅每个人,理想情况下我希望最终从日历、电子邮件和联系人中获得所有更新,但我是从日历开始的.

So I set about subscribing to everyone individually, ideally I would like all updates from calendars, email and contacts eventually, but I started with calendars.

该代码仅适用于我的用户,但是当我尝试为所有人(大约 300 个用户)订阅时,我遇到了一个严格的限制,订阅了七个,因为进一步的请求失败了一个通用的 Bad Request 状态.

The code works perfectly with just my user, however when I try to subscribe for everyone (around 300 users), I hit a hard a limit, at seven subscriptions, as in further requests fail with a generic Bad Request status.

在官方文档 https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/webhooks 它说:

限制某些限制适用,超过时可能会产生错误:

Limitations Certain limits apply and may generate errors when exceeded:

1) 最大订阅配额

每个应用:总共 50,000 次订阅每租户:所有应用的订阅总数为 35 个每个应用和租户组合:总共 7 个订阅

Tenant 似乎是指实际的活动目录,因此我们限制为每个应用程序 7 个,或总共 35 个.

It seems that Tenant refers to an actual active directory, so we are limited to 7 per app, or 35 in total.

将用户拆分到多个域的 Active Directory 的可能性为零,即使同时使用多个应用程序来做同样的事情似乎也很奇怪,这些限制对我来说毫无意义.

There is zero chance of splitting users into multi Active Directories of domains, even juggling multiple apps to do the same thing seems strange, these limits make no sense at all to me.

有没有办法增加这些微小的限制?

我正在订阅 users/$email/events,所以我发布到 https://graph.microsoft.com/v1.0/subscriptions

I am subscribing to users/$email/events so I post to https://graph.microsoft.com/v1.0/subscriptions

{
   "changeType": "created,updated,deleted",
   "notificationUrl": "https://webhooks.mydomain.com/my/endpoint",
   "resource": "users/$email/events",
   "expirationDateTime":"2018-05-12T16:00:00.9356913Z",
   "clientState": "my-super-secret-identifier"
}

只要我想要 <=7 个订阅,它就可以很好地工作.我还订阅了 root/users,看看这是否会给我所有的更改,这意味着我只能订阅 6 个单独的日历.

And it works great, as long as I want <=7 subscriptions. I also subscribed to, the root /users to see if that would give me all changes, which meant I could then only subscribe to 6 individual calendars.

我正在使用官方的 PHP 库,但假设/希望没关系.

I am using the official PHP library, but presume/hope that doesn't matter.

推荐答案

正如 Jason 在评论中所说,问题中的限制应该只适用于 Active Directory 资源,而不适用于用户级别,文档现已更改:

As Jason said in the comments, the restriction in the question should only have applied to Active Directory Resources, not on the user level, the docs have now been changed:

Azure AD 资源限制

某些限制适用于基于 Azure AD资源(用户、组),超过时可能会产生错误:

Certain limits apply to Azure AD based resources (users, groups) and may generate errors when exceeded:

最大订阅配额:

每个应用:总共 50,000 次订阅每个租户:总共 35 个订阅跨所有应用每个应用和租户组合:总共 7 个订阅

无论是建议的力量导致了问题,还是我不知道的某个地方的一些暂时性错误,但互联网之神对我微笑,我的代码现在可以工作了;即使我没有改变它.

Whether it was a case of the power of suggestion causing the issue, or some transient bug somewhere I don't know, but the Gods of the Interwebs have smiled on me, and my code works now; even though I didn't change it.

也许删除和添加权限对我有帮助?不确定.

Maybe removing and adding permissions helped in my case? Not sure.

至少现在有文档.