Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The AzureIotHub Import connects to the built-in endpoint of the Azure IOT Hub. By default the IOT Hub exposes the endpoint as an Azure Service Bus Even Hub compatible endpoint. This allows clients to connect using the AMQPS protocol, which is used by the AzureIotHub import. The default port for AMQPS is port 5671 and a forecasting shell server should be allowed to connect to the Azure IOT Hub using this port from the Forecasting Shell Server.

...

To configure the AzureIotHub import, some required properties have to be specified:

Property nameDescriptionExample valueAzure Portal Screenshot
eventHubCompatiblePath

Event HUB compatible name that can be used to access the IoT Hub over AMQPS
iothub-ehub-delft-fews-3109254-e665c23b62

AzureIotHub-Built-inendpoint
consumersGroup
An event heb can have different consumer groups. Specify the used consumer group here.
$Default
AzureIotHub-Built-inendpoint
eventHubCompatibleHostname
Event hub compatible hostname that can be used to access the IoT Hub over AMQPS
ihsuprodamres086dednamespace.servicebus.windows.net
AzureIotHub-Built-inendpoint
numberOfPartitions
For scalability an event hub can be partitioned. The number of partitions used have to be specified here.2AzureIotHub-Built-inendpoint
sharedAccessPolicyName
Name of the SAS policy that is used for authentication agains the IoT Hub.serviceAzureIotHub-SharedAccessPolicies
sharedAccessPolicyKey
The actual policy key that can be used to authenticate against the IoT Hub.
V86dqC3AhjIqSgvAuShKDSsNamUJh5rJrqZ1e3hw7EA=
AzureIotHub-SharedAccessPolicies
runningTimeMilliseconds
Optional property. Specifies how long the import will run in milliseconds. Default is one hour. Should only be changed for testing.
120000
not relevant
readMessagesFromStartOptional property. Used for testing to read all messages available in the event hub. This option will read already processed messages again.falsenot relevant


Example Import Configuration

...

Code Block
languagexml
borderStylesolid
titleExample IOT Hub Import
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews
http://fews.wldelft.nl/schemas/version1.0/timeSeriesImportRun.xsd">
	<import>
		<general>	
            <importType>AzureIotHub</importType>
			<serverUrl>https://delft-fews-iot-hub.azure-devices.net</serverUrl> <!-- Not actually used -->
   			<relativeViewPeriod unit="day" start="-7" end="1" ></relativeViewPeriod>
            <missingValue>-99.99</missingValue>
            <dataFeedId>Azure IOT Hub</dataFeedId> <!-- data feed id is required for IOT hub -->
        </general>
		<properties>
			<string key="eventHubCompatiblePath" value="iothub-ehub-delft-fews-3109254-e665c23b62" />
			<string key="consumersGroup" value="$Default" />
			<string key="eventHubCompatibleHostname" value="ihsuprodamres086dednamespace.servicebus.windows.net" />			
			<string key="sharedAccessPolicyName" value="service" />			
			<string key="sharedAccessPolicyKey" value="V86dqC3AhjIqSgvAuShKDSsNamUJh5rJrqZ1e3hw7EA=" />			
			<int key="numberOfPartitions" value="2" />		
			<int key="runningTimeMilliseconds" value="120000" /> <!-- run for 2 minutes for testing. Overrules the default running time of one hour -->
			<!--int key="runningTimeMilliseconds" value="120000" /properties>	--> 
			<!-- used for testing. Read all available messages -->
			<!--bool  key="readMessagesFromStart" value="true" /-->
 </properties> 

		<timeSeriesSet>
			<moduleInstanceId>ImportObserved</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>T.obs</parameterId>
			<locationSetId>LocationSetId</locationSetId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant"/>
			<readWriteMode>add originals</readWriteMode>
			<expiryTime unit="year" multiplier="1"/>
		</timeSeriesSet>
	</import>
</timeSeriesImportRun>




...

  • sharedAccessPolicyName: set to 2 in "service". If a custom policy is used, make sure at least the Service connect permissing has been assigned to the policy.
  •  sharedAccessPolicyKey: Either the Primary Key or Secondary key can be used for that. It should be similar to:  V86dqC3AhjIqSgvAuShKDSsNamUJh5rJrqZ1e3hw7EA=

...

To be able to send test messages to the Azure IoT Hub, a device has to be registered. See the following example of the Azure Portal where on the IoT device page, a device has been registered called "deltares-test-iot-device".

...

When looking at the details of a client device registration, among others the Primary or Secondary connection string can be determined and used for testing.

...

Microsoft Visual Studio Code IoT Hub Extension

See: https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools

Microsoft Visual Studio Code has support for a IoT Hub extension pack called IoT tools, that can be used to send Device to Cloud messages (D2C messages). See the following screenshot to see how to send a D2C message from the test clientdevice. To use The IoT Hub tools, an Azure Portal account is required.


Azure IoT Hub Tester

See: https://www.codeproject.com/Articles/1173356/Azure-IoT-Hub-Tester

With this tool a connection can be made to the IOT hub using the primary or secondary connection string that is given with the client registration. device registration. No Azure Portal account is required to test.

Info

The namespace is NOT the name of the iot clientdevice, but the name of the iot hub. In this case: delft-fews-iot-hub


Image Modified

Once connected, test message can be sent with the tool. Currently only PI XML can be used for testing.

Image Modified