Skip to content

vjrantal/postgresql-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purpose of the repository

This repository contains sample code for messaging over the Azure IoT Hub.

The scenario demonstrated is:

  • How to upload blobs from Python
  • How send device to cloud messages that contain metadata about the uploaded files
  • How to use Azure Functions to store the metadata onto a PostgreSQL database
  • How to call device methods

Instructions

Setup IoT Hub

Setup Python sample

  • Clone
  • Build using the script appropriate for you platform https://github.com/Azure/azure-iot-sdk-python/tree/master/build_all
  • After success build, copy the native library (e.g. iothub_client.so) onto root of this repository or to a system path (or edit LD_LIBRARY_PATH)
  • Update line CONNECTION_STRING = "[Device Connection String]" in file iothub_upload_sample.py to have your device connection string
    • If you haven't created a device yet, you can do that in Azure Portal
  • Run the sample with python iothub_upload_sample.py

Setup Azure Functions

  • Create an Azure Function
  • Setup the Function to be deployed from a local Git repository
  • Edit file IoTHubToPostgreSQL/config.js to have connection details for you PostgreSQL database
  • Edit file IoTHubToPostgreSQL/function.js to have right Event Hub name and consumer group
  • Push this repository into the local Git repository that you created above
  • Construct an Event Hub compatible connection string
  • Update the Azure Function to have the right connection string in App Settings with key iothub-ehub (this key is referenced from file IoTHubToPostgreSQL/function.json):

Update app settings

Calling device methods

You can use https://github.com/Azure/iothub-explorer to test invocation of device methods. At the same time, you can observe that the Azure Function is not getting triggered from these, because the device method messaging is not routed via the same pipeline as cloud to device messages.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published