我想使用Azure SDK将事件中心设置为将事件发布到事件网格主题。
这可以在Azure Portal中直接从Event Hub Namespace,creating a Event Grid System主题完成。
然而,我似乎找不到一种合适的方法来使用Azure SDK来创建事件网格系统主题,或者创建事件网格自定义主题并将其设置为事件中心命名空间的端点。
有什么想法吗?
发布于 2020-07-14 01:22:43
文档是可用的,可能有点分散。如果导航到事件网格documentation site,则菜单树中的参考节点包含所有支持的语言/SDK。对于.NET,它将带您转到关于如何发布和订阅(link)的文章。要管理主题,您需要使用here提供的management SDK和示例。
请注意,这些示例使用的是略显过时的management SDK版本(相关issue),但是您应该能够升级这些版本并使用这些示例。
发布于 2020-07-14 23:25:27
最终使用REST API发出创建事件网格系统主题的HTTP请求。接口请求文档:https://docs.microsoft.com/en-us/rest/api/eventgrid/version2020-04-01-preview/systemtopics/createorupdate
发布于 2020-09-05 15:21:26
呼!!这个问题让我苦思冥想了3天&我几乎失去了希望,但最终还是成功了。
参考:https://docs.microsoft.com/en-us/java/api/overview/azure/eventgrid?view=azure-java-stable
代码
final String clientId = "clientId";
final String tenantId = "tenantId";
final String clientSecret = "clientSecret";
final String subscriptionId = "subscriptionId";
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(clientId, tenantId, clientSecret,
AzureEnvironment.AZURE);
credentials.withDefaultSubscriptionId(subscriptionId);
EventGridManager eventGridManager = EventGridManager.configure().authenticate(credentials,
credentials.defaultSubscriptionId());
eventGridManager.eventSubscriptions().define("subscription")
.withScope("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.storage/storageaccounts/{storageAccountName}")
.withEventDeliverySchema(EventDeliverySchema.EVENT_GRID_SCHEMA)
.withDestination(new WebHookEventSubscriptionDestination().withEndpointUrl("{valid https url}"))
.create();
这将创建一个带有订阅的系统主题
https://stackoverflow.com/questions/62879395
复制相似问题