【发布时间】:2022-08-23 15:09:18
【问题描述】:
基本上我正在尝试订阅有关组更改的通知,以便在 3rd 方系统中调整授权,请在下面找到代码。它使用用于 Java 的图形 sdk。我添加了我遵循的文档以供参考,请参阅 Microsoft Docs 中的 Change notification delivery 和 post subscriptions。
不幸的是我得到了一个
Invalid event hub notification url。我尝试了域和租户 ID,但没有运气。这并不让我感到惊讶,因为 notificationUrl 看起来真的很奇怪。有人可以在这里分享一些光吗?
// From https://docs.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://docs.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
[...]
标签: azure azure-ad-graph-api azure-eventhub