Iot Hub Resource - Test All Routes
测试此 Iot 中心配置的所有路由
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall?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 的版本。 |
请求正文
| 名称 | 类型 | 说明 |
|---|---|---|
| message |
路由消息 |
|
| routingSource |
路由源 |
|
| 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_TestAllRoutes
示例请求
POST https://management.azure.com/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/testHub/routing/routes/$testall?api-version=2023-06-30
{
"routingSource": "DeviceMessages",
"message": {
"body": "Body of message",
"appProperties": {
"key1": "value1"
},
"systemProperties": {
"key1": "value1"
}
}
}
示例响应
{
"routes": [
{
"properties": {
"name": "Routeid",
"source": "DeviceMessages",
"endpointNames": [
"id1"
],
"isEnabled": true
}
}
]
}
定义
| 名称 | 说明 |
|---|---|
|
Error |
错误详细信息。 |
|
Matched |
匹配的路由 |
| Properties | |
|
Route |
IoT 中心用于将消息路由到终结点的路由规则的属性。 |
|
Routing |
路由消息 |
|
Routing |
要应用路由规则的源,例如 DeviceMessages。 |
|
Routing |
孪生引用输入参数。 这是可选参数 |
|
Test |
用于测试所有路由的输入 |
|
Test |
测试所有路由的结果 |
ErrorDetails
错误详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| code |
string |
错误代码。 |
| details |
string |
错误详细信息。 |
| httpStatusCode |
string |
HTTP 状态代码。 |
| message |
string |
错误消息。 |
MatchedRoute
匹配的路由
| 名称 | 类型 | 说明 |
|---|---|---|
| properties |
匹配的路由的属性 |
Properties
| 名称 | 类型 | 说明 |
|---|---|---|
| desired |
object |
理想双重属性 |
| reported |
object |
理想双重属性 |
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 |
孪生标记 |
TestAllRoutesInput
用于测试所有路由的输入
| 名称 | 类型 | 说明 |
|---|---|---|
| message |
路由消息 |
|
| routingSource |
路由源 |
|
| twin |
路由孪生参考 |
TestAllRoutesResult
测试所有路由的结果
| 名称 | 类型 | 说明 |
|---|---|---|
| routes |
匹配路由的 JSON 序列化数组 |