如何使用 Azure 门户调用直接方法How to use Azure portal to invoke direct methods

借助 IoT 中心,你可以从云中对边缘设备调用直接方法IoT Hub gives you the ability to invoke direct methods on edge devices from the cloud. IoT Edge 上的实时视频分析 (LVA) 模块公开了多种直接方法,这些方法可以用于定义、部署和实例化用于分析实时视频的不同工作流。The Live Video Analytics on IoT Edge (LVA) module exposes several direct methods that can be used to define, deploy, and instantiate different workflows for analyzing live video.

本文介绍如何通过 Azure 门户对 IoT Edge 的实时视频分析模块调用直接方法调用。In this article, you will learn how to invoke direct method calls on Live Video Analytics for an IoT Edge module via the Azure portal.

先决条件Prerequisites

通过 Azure 门户调用直接方法Invoking direct methods via Azure portal

LVA 模块公开的每种直接方法均可通过 Azure 门户进行调用。Each of the direct methods exposed by the LVA module can be invoked via Azure portal. 下面的步骤提供了调用一种直接方法的详细操作。The steps below provide the details for one direct method. 你可以使用类似的步骤调用其他直接方法。You can invoke other direct methods using similar steps. 但是,每种直接方法都需要一个特定的 JSON 正文。However, each direct method requires a specific JSON body.

使用 GraphTopologyList 方法调用,检索当前部署在IoT Edge 上的实时视频分析模块上的所有图形拓扑列表。Use the GraphTopologyList method call to retrieve a list of all the graph topologies currently deployed on the Live Video Analytics on IoT Edge module. 使用以下步骤来调用此直接方法:Use the following steps to invoke this direct method:

  1. 登录 Azure 门户Log into Azure portal

  2. 从门户主页找到相关的资源组来定位 IoT 中心,或者如果你知道自己的 IoT 中心,请选择它。Find the relevant resource group from your portal homepage to locate your IoT Hub, or if you know you IoT Hub, select it. 门户主页中的资源组resource group in portal home page

  3. 在 IoT 中心页上,选择“自动设备管理”下的“IoT Edge”以列出各个设备 ID。Once on the IoT Hub page, select IoT Edge under Automatic Device Management to list the various device IDs. 选择相关设备 ID 以列出该设备上运行的模块。Select the relevant device ID to list the modules running on the device. iot 中心页iot hub page

  4. 选择 IoT Edge 上的实时视频分析模块以打开其配置页面。Select the Live Video Analytics on IoT Edge module to bring up its configuration page.

    选择 IoT Edge 上的实时视频分析模块以打开其配置页面Select the Live Video Analytics on IoT Edge module to bring up its configuration page

  5. 选择“直接方法”菜单选项。Select on the Direct method menu option.

    单击“直接方法”菜单选项Click on the Direct method menu option

    备注

    如当前页面所示,你可能需要在连接字符串部分中添加一个值。You might need to add a value in the Connection string sections as you can see on the current page. 你无需隐藏或更改“设置名称”部分中的任何内容。You do not need to hide or change anything in the Setting name section. 这些内容可以公开。It is ok to let it be public.

  6. 在“方法名称”字段中,键入“GraphTopologyList”。Type GraphTopologyList in the Method Name field.

  7. 将下面的 JSON 复制并粘贴到“有效负载”字段中。Copy and paste the JSON below in the Payload field.

    {
    "@apiVersion":
    }
    
  8. 选择页面顶部的“调用方法”按钮。Select the Invoke Method button at the top of the page.

    “调用方法”按钮invoke method button

  9. 你应该会在“结果”区域中看到一条状态 200 消息。You should see a status 200 message in the Result area.

    连接超时connection timeout

响应Responses

条件Condition 状态代码Status Code 详细错误代码Detailed Error Code
SuccessSuccess 200200 空值N/A
一般用户错误General user errors 400 range400 range
一般服务器错误General server errors 500 range500 range

后续步骤Next steps

可在直接方法页上找到更多直接方法。More direct methods can be found on the direct methods page.

备注

图形实例可实例化特定拓扑,因此在创建图形实例之前,请确保已设置正确的拓扑。A graph instance instantiates a specific topology, so please ensure you have the right topology set before creating a graph instance.

快速入门:检测运动并发出事件是很好的参考文档,它可以帮助你了解要进行的直接方法调用的确切顺序。Quickstart: Detect motion emit events is a good reference for understanding the exact sequence of direct method calls to be made.