【发布时间】:2018-01-29 16:54:27
【问题描述】:
我愿意使用策略将我的 Azure Api 管理中的内容记录到 eventthub 中。
我正在关注此文档:https://docs.microsoft.com/en-us/rest/api/apimanagement/logger/createorupdate
这是我的 HTTP 请求(使用 Postman):
PUT /subscriptions/3f0a0802-0a42-4a73-82b2-094d41acd70a/resourceGroups/GRP-Poc-BilanHydrique/providers/Microsoft.ApiManagement/service/WaterBalance/loggers/end-user-logger?api-version=2017-03-01 HTTP/1.1
Host: management.azure.com
Authorization: {my token}
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 449f686d-3a86-b714-0b37-979567f6f921
{
"properties": {
"loggerType": "azureEventHub",
"description": "adding a new logger",
"credentials": {
"name": "api-management-logs",
"connectionString": "{my connection string}"
}
}
}
我从 Api Manager UI 在以下 URL 生成了我的令牌:/admin/tenant/access 我已经检查了过期时间。
看起来像这样:
SharedAccessSignature integration&{date}&{base64stuff}==
这是我创建该令牌的位置的屏幕截图: screenshot
这里有回复:
{
"error": {
"code": "AuthenticationFailedInvalidHeader",
"message": "Échec de l'authentification. L'en-tête 'Authorization' est fourni dans un format incorrect."
}
我不知道发生了什么。有任何想法吗 ? 有解决方法吗?有没有办法通过 azure 门户创建 api 管理记录器?
谢谢!
01/30 更新:
感谢您的回答,我发现这不是正确的 API。 我尝试了 API 管理端点,但收到 500 HTTP 错误:
请求:
PUT /loggers/end-user-logger?api-version=2018-01-01 HTTP/1.1
Host: waterbalance.management.azure-api.net
Authorization: SharedAccessSignature integration&201801301710&{secret}==
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 2618737b-af3e-c7d3-1d31-6b6f654100e9
{
"properties": {
"loggerType": "AzureEventHub",
"description": "adding a new logger",
"credentials": {
"name": "end-user-logs",
"connectionString": "Endpoint=sb://api-management-logs.servicebus.windows.net/;SharedAccessKeyName=Sending;SharedAccessKey={secret}"
}
}
}
回复:
{
"error": {
"code": "InternalServerError",
"message": "Request processing failed due to internal error.",
"details": null
}
这似乎不是令牌问题,因为我没有收到未经授权的错误。
【问题讨论】:
标签: rest azure authorization azure-api-management azure-cli