Deploy an Anomaly Detector module to IoT Edge
Learn how to deploy the Cognitive Services Anomaly Detector module to an IoT Edge device. Once it's deployed into IoT Edge, the module runs in IoT Edge together with other modules as container instances. It exposes the exact same APIs as an Anomaly Detector container instance running in a standard docker container environment.
- Use an Azure subscription. If you don't have an Azure subscription, create a free account before you begin.
- Install the Azure CLI.
- An IoT Hub and an IoT Edge device.
Create an Anomaly Detector resource
Sign into the Azure portal.
Select Create Anomaly Detector resource.
Enter all required settings:
Setting Value Name Desired name (2-64 characters) Subscription Select appropriate subscription Location Select any nearby and available location Pricing Tier
F0- 10 Calls per second, 20K Transactions per month.
S0- 80 Calls per second
Resource Group Select an available resource group
Click Create and wait for the resource to be created. After it is created, navigate to the resource page
endpointand an API key:
Keys and Endpoint tab in the portal Setting Value Overview Endpoint Copy the endpoint. It looks similar to
Keys API Key Copy 1 of the two keys. It is a 32 alphanumeric-character string with no spaces or dashes,
Deploy the Anomaly Detection module to the edge
In the Azure portal, enter Anomaly Detector on IoT Edge into the search and open the Azure Marketplace result.
It will take you to the Azure portal's Target Devices for IoT Edge Module page. Provide the following required information.
Select your subscription.
Select your IoT Hub.
Select Find device and find an IoT Edge device.
Select the Create button.
Select the AnomalyDetectoronIoTEdge module.
Navigate to Environment Variables and provide the following information.
Keep the value accept for Eula.
Fill out Billing with your Cognitive Services endpoint.
Fill out ApiKey with your Cognitive Services API key.
Select Next: Routes to define your route. You define all messages from all modules to go to Azure IoT Hub.
Select Next: Review + create. You can preview the JSON file that defines all the modules that get deployed to your IoT Edge device.
Select Create to start the module deployment.
After you complete module deployment, you'll go back to the IoT Edge page of your IoT hub. Select your device from the list of IoT Edge devices to see its details.
Scroll down and see the modules listed. Check that the runtime status is running for your new module.
To troubleshoot the runtime status of your IoT Edge device, consult the troubleshooting guide
Test Anomaly Detector on an IoT Edge device
You'll make an HTTP call to the Azure IoT Edge device that has the Azure Cognitive Services container running. The container provides REST-based endpoint APIs. Use the host,
http://<your-edge-device-ipaddress>:5000, for module APIs.
If your edge device does not already allow inbound communication on port 5000, you will need to create a new inbound port rule.
For an Azure VM, this can set under Virtual Machine > Settings > Networking > Inbound port rule > Add inbound port rule.
There are several ways to validate that the module is running. Locate the External IP address and exposed port of the edge device in question, and open your favorite web browser. Use the various request URLs below to validate the container is running. The example request URLs listed below are
http://<your-edge-device-ipaddress:5000, but your specific container may vary. Keep in mind that you need to use your edge device's External IP address.
||The container provides a home page.|
||Also requested with GET, this verifies if the api-key used to start the container is valid without causing an endpoint query. This request can be used for Kubernetes liveness and readiness probes.|
||The container provides a full set of documentation for the endpoints and a Try it out feature. With this feature, you can enter your settings into a web-based HTML form and make the query without having to write any code. After the query returns, an example CURL command is provided to demonstrate the HTTP headers and body format that's required.|