Iot Hub Resource - Test Route
测试此 IoT 中心的新路由
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew?api-version=2023-06-30
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
iot
|
path | True |
string |
要测试的 IotHub |
|
resource
|
path | True |
string |
IoT 中心所属的资源组 |
|
subscription
|
path | True |
string |
订阅标识符。 |
|
api-version
|
query | True |
string |
API 的版本。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| route | True |
路由属性 |
|
| message |
路由消息 |
||
| twin |
路由孪生参考 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
还行 |
|
| Other Status Codes |
DefaultErrorResponse |
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
IotHubResource_TestRoute
示例请求
POST https://management.azure.com/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/testHub/routing/routes/$testnew?api-version=2023-06-30
{
"message": {
"body": "Body of message",
"appProperties": {
"key1": "value1"
},
"systemProperties": {
"key1": "value1"
}
},
"route": {
"name": "Routeid",
"source": "DeviceMessages",
"endpointNames": [
"id1"
],
"isEnabled": true
}
}
示例响应
{
"result": "false",
"details": {
"compilationErrors": [
{
"message": "string response",
"severity": "error",
"location": {
"start": {
"line": 12,
"column": 12
},
"end": {
"line": 12,
"column": 24
}
}
}
]
}
}
定义
| 名称 | 说明 |
|---|---|
|
Error |
错误详细信息。 |
| Properties | |
|
Route |
评估路由时出现编译错误 |
|
Route |
发生路由错误的位置 |
|
Route |
路由错误的范围 |
|
Route |
路由错误的严重性 |
|
Route |
IoT 中心用于将消息路由到终结点的路由规则的属性。 |
|
Routing |
路由消息 |
|
Routing |
要应用路由规则的源,例如 DeviceMessages。 |
|
Routing |
孪生引用输入参数。 这是可选参数 |
|
Test |
测试路由的结果 |
|
Test |
测试路由的输入 |
|
Test |
测试一个路由的结果 |
|
Test |
测试路由的详细结果 |
ErrorDetails
错误详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| code |
string |
错误代码。 |
| details |
string |
错误详细信息。 |
| httpStatusCode |
string |
HTTP 状态代码。 |
| message |
string |
错误消息。 |
Properties
| 名称 | 类型 | 说明 |
|---|---|---|
| desired |
object |
理想双重属性 |
| reported |
object |
理想双重属性 |
RouteCompilationError
评估路由时出现编译错误
| 名称 | 类型 | 说明 |
|---|---|---|
| location |
发生路由错误的位置 |
|
| message |
string |
路由错误消息 |
| severity |
路由错误的严重性 |
RouteErrorPosition
发生路由错误的位置
| 名称 | 类型 | 说明 |
|---|---|---|
| column |
integer (int32) |
发生路由错误的列 |
| line |
integer (int32) |
发生路由错误的行 |
RouteErrorRange
路由错误的范围
| 名称 | 类型 | 说明 |
|---|---|---|
| end |
结束路由错误发生的位置 |
|
| start |
开始发生路由错误的位置 |
RouteErrorSeverity
路由错误的严重性
| 值 | 说明 |
|---|---|
| error | |
| warning |
RouteProperties
IoT 中心用于将消息路由到终结点的路由规则的属性。
| 名称 | 类型 | 说明 |
|---|---|---|
| condition |
string |
评估为应用路由规则的条件。 如果未提供任何条件,则默认情况下计算结果为 true。 有关语法,请参阅:https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language |
| endpointNames |
string[] |
路由满足条件的消息的终结点列表。 目前只允许一个终结点。 |
| isEnabled |
boolean |
用于指定是否启用路由。 |
| name |
string pattern: ^[A-Za-z0-9-._]{1,64}$ |
路由的名称。 该名称只能包含字母数字字符、句点、下划线、连字符,最大长度为 64 个字符,并且必须是唯一的。 |
| source |
要应用路由规则的源,例如 DeviceMessages。 |
RoutingMessage
路由消息
| 名称 | 类型 | 说明 |
|---|---|---|
| appProperties |
object |
应用属性 |
| body |
string |
路由消息正文 |
| systemProperties |
object |
系统属性 |
RoutingSource
要应用路由规则的源,例如 DeviceMessages。
| 值 | 说明 |
|---|---|
| Invalid | |
| DeviceMessages | |
| TwinChangeEvents | |
| DeviceLifecycleEvents | |
| DeviceJobLifecycleEvents | |
| DeviceConnectionStateEvents |
RoutingTwin
孪生引用输入参数。 这是可选参数
| 名称 | 类型 | 说明 |
|---|---|---|
| properties | ||
| tags |
object |
孪生标记 |
TestResultStatus
测试路由的结果
| 值 | 说明 |
|---|---|
| undefined | |
| false | |
| true |
TestRouteInput
测试路由的输入
| 名称 | 类型 | 说明 |
|---|---|---|
| message |
路由消息 |
|
| route |
路由属性 |
|
| twin |
路由孪生参考 |
TestRouteResult
测试一个路由的结果
| 名称 | 类型 | 说明 |
|---|---|---|
| details |
测试路由的详细结果 |
|
| result |
测试路由的结果 |
TestRouteResultDetails
测试路由的详细结果
| 名称 | 类型 | 说明 |
|---|---|---|
| compilationErrors |
路由编译错误的 JSON 序列化列表 |