如何解决从 APIM 记录到事件中心似乎无法正常工作
我已按照 MS docs 中的说明进行操作。
我创建了一个 事件中心 命名空间,该命名空间托管一个名为 clicks-hub
的中心,该中心由名为 ClicksLoggingPolicy
的策略保护,仅具有 发送 声明。
然后我使用以下 URL 将记录器添加到我的 APIM 服务中: https://management.azure.com/subscriptions/MY_SUBS/resourceGroups/MY_RESGROUP/providers/Microsoft.ApiManagement/service/MY_APIM/loggers/clicksLogger?api-version=2019-12-01
使用此有效负载:
{
"properties": {
"loggerType": "azureEventHub","description": "Logger for click events","credentials": {
"name": "clicks-hub","connectionString": "Endpoint=sb://myapim.servicebus.windows.net/;SharedAccessKeyName=ClicksLoggingPolicy;SharedAccessKey=****************"
}
}
}
发送 PUT 请求后,我得到了 201 created
。
我已使用此 POST 操作配置了 APIM API。它遵循 XML 政策:
<policies>
<inbound>
<log-to-eventhub logger-id="clicksLogger">@( "LOGGING_FROM_AZURE_APIM" )</log-to-eventhub>
<mock-response status-code="200" content-type="application/json" />
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
我使用 APIM 测试 面板触发了各种请求,我可以看到关于指标的请求:
但是当我启动集线器时什么都没有:
SELECT
*
INTO
[OutputAlias]
FROM
[clicks-hub]
我尝试使用 this tool 提取一些测试数据,我可以看到消息。
知道我遗漏了什么吗?
预先感谢任何愿意提供帮助的人。
问候,贾科莫 S. S.
解决方法
似乎您只能在 EventHub 消息是对象/是 JSON 时进行查询:
来自本政策
1
255
1
只有带有 <policies>
<inbound>
<log-to-eventhub logger-id="kai-logger">@( "LOGGING_FROM_AZURE_APIM1" )</log-to-eventhub>
<log-to-eventhub logger-id="kai-logger">@( "{'message':'LOGGING_FROM_AZURE_APIM2'}" )</log-to-eventhub>
<mock-response status-code="200" content-type="application/json" />
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
的消息显示在查询中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。