簡體   English   中英

MS graph api:使用 Azure 事件中心訂閱有關組更改的通知

[英]MS graph api: Subscribe for notifications on groups changes with Azure event hub

基本上我正在嘗試訂閱有關組更改的通知,以便在第 3 方系統中調整授權,找到下面的代碼。 它使用 Java 的圖形 sdk。 我已經添加了我遵循的文檔以供參考,請參閱 Microsoft Docs 中的更改通知傳遞發布訂閱

不幸的是,我收到一個Invalid event hub notification url 我嘗試了域和租戶 ID,但沒有成功。 我並不感到驚訝,因為 notificationUrl 看起來真的很奇怪。 任何人都可以在這里分享一些光嗎?

       // From https://learn.microsoft.com/de-de/graph/change-notifications-delivery:

        // The main difference during subscription creation will be the notificationUrl. You must set it to
        //  EventHub:https://<azurekeyvaultname>.vault.azure.net/secrets/<secretname>?tenantId=<domainname>, with the following values:

        //   azurekeyvaultname - The name you gave to the key vault when you created it. Can be found in the DNS name.
        //   secretname - The name you gave to the secret when you created it. Can be found on the Azure Key Vault Secrets page.
        //   domainname - The name of your tenant; for example, consto.onmicrosoft.com or contoso.com. Because this domain will be used to access the Azure Key Vault, it is important that it matches the domain used by the Azure subscription that holds the Azure Key Vault. To get this information, you can go to the overview page of the Azure Key Vault you created and click the subscription. The domain name is displayed under the Directory field.

        @GetMapping("/subscribe")
        public void subscribeTochangeNotifications() {
                // following https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http#request-example

                Subscription subscription = new Subscription();
                subscription.changeType = "created,updated";
                subscription.notificationUrl = "EventHub:https://xxxxxxxxx.vault.azure.net/secrets/event-hub-client-secret?tenantId=xxxxxxxxx-xxxx-xxxx-xxxxxxxxx";
                subscription.expirationDateTime = OffsetDateTime.parse("2022-07-05T18:23:45.9356913Z");
                subscription.resource = "/groups";
                subscription.clientState = "SecretClientState";

                azureClient.subscriptions().buildRequest().post(subscription);
        }

詳細的錯誤信息是:

nested exception is com.microsoft.graph.http.GraphServiceException: Error code: InvalidRequest
Error message: Invalid event hub notification url='EventHub:https://xxxxxxxxxxxxxxxxx.vault.azure.net/secrets/event-hub-client-secret?tenantId=yyyyyyy-yyy-yyyy-yyyyyyyyyy'.

POST https://graph.microsoft.com/v1.0/subscriptions
SdkVersion : graph-java/v5.30.0
SdkVersion : graph-java/v5.30.0
[...]

400 : Bad Request
[...]

你能找到解決辦法嗎? 我也面臨着完全相同的問題。 如果有人可以就可能導致這種情況的原因分享想法,那就太好了。

面臨完全相同的問題,但我的網址和連接字符串似乎是正確的

我們遇到了同樣的問題(使用 pulumi 設置)。 我們在密鑰保管庫機密中的連接字符串缺少

";EntityPath=graphevents" 

在最后。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM