Anya163 / ECM3440-residential-iot1

1 stars 1 forks source link

Design cloud application #23

Open fred9702 opened 2 years ago

fred9702 commented 2 years ago

https://docs.microsoft.com/en-us/rest/api/container-instances/container-groups/create-or-update

This is a link describing how calls could be made from sensor.py to Azure Container Instances (ACI).

Only a single to ACI api call needs to be made to create a container when a new sensor is created in CounterFit.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}?api-version=2019-12-01

The PUT has an accompanying request body that is described in the link. We would pass to this PUT request's body the type and GPIO pin number so that when the container is created and starts the sensor.py app, those unique parameters will be passed to it and used in the creation of a device in the IoT hub.

fred9702 commented 2 years ago

Prosperity 2 0-Production Environment

Cloud Application

fred9702 commented 2 years ago

As the containers are created by the ACI api and start, they will run as part of their "set up" script, the task of creating a device in the Azure IoT Hub to which it will then send the telemetry it consumes from Counter Fit.

fred9702 commented 2 years ago

Using this package will allow us to create devices from sensor.py: https://pypi.org/project/azure-iot-device/ (we already use it in the requirements.txt)

fred9702 commented 2 years ago

All of this will have to be tested:

Mocking the calls to the ACI api. Mocking the creation of device in the IoT Hub. Mocking sending telemetry messages. Mocking CounterFit.