Connect photon to azure without webhooks

Hi there,
I’m trying to connect my photon to an Azure IoT Hub, but it seems no tutorials exists about it at the moment. I’m having difficulties in finding a “template” to correctly comunicate between the Photon and Azure. On Azure website there are only pieces of codes but I’m not an expert of https comunication so it’s not easy to adeguate those codes to my case :frowning:
Please help me,
Thank you guys

1 Like

no one can help me?

Hi @5e8a,

I’m David, the engineer who built webhooks! :slight_smile: Connecting to Azure directly requires both an HTTPS client, and the generation of a secure Azure header for each message. Can you tell me more about your use case?

We built webhooks to make this sort of thing extremely easy and scalable, so I’m curious to learn more about your project.

Thanks!
David

Hi Dave,
we are working on a smart parking application, we would like to use the Photon to collect the data from a sensor network and to post these data on Azure and/or AWS. We would like to have a bidirectional communication between Azure and the Photon without the “intermediation” of Particle Cloud. We have tried to use the “HTTPSCLIENT-PARTICLE” library available on the web IDE to do a POST request but it didn’t work for us. Can you provide us a simple code “template” to make a POST or GET request to the Azure IoT Hub?
Thank you for your help!

2 Likes

Hi @Dave, we have a similar problem with webhooks and i tried to solve it by using also httpsclient-particle, like @5e8a … but in our case it is stilll not possible, since the cyphers supported by the secure server we want to connect are not avaible on this lib, but people from glowfi.sh are doing an incredible work on this issue. in our project we are trying to directly make https requests (GET, POST) from our photon devices to wit.ai. in the particular case of the POST requests, we need to send a .wav file including a recorded audio command in order to obtain from wit.ai the corresponding text command … at first, we though about using webhooks, but, obviously, the limitation of a data field up to 255 bytes, and a maximum of 1 message per second, make it impossible. webhooks are an amazing improvement on photon devices, but for some specific applications, like this or the direct connection to azure, have some important limitations. we hope photon can support https client requests soon … very soon :wink:
best regards

3 Likes

I’m also interested in having the device connect directly to an Azure Event Hub as I do not see the value added in passing it via particle cloud. it is just adding another point of failure and latency at no extra added value.

Can you share what has already been done on this topic?

1 Like

As with the others I’d like to be able to connect my photon directly to Azure. I’ve used webhooks and they’re great but the limit of 120 requests/minute/host is going to be an issue for us. The whole point of Event Hubs/IoT Hubs is scalability towards hundreds of thousands of events per minute - limiting it to 120 defeats the object of using the hubs in the first place. I accept the reason for rate limiting calls to a specific host and also the difficulty of implementing https in such a small space. Even if https were present users would still have to be able to generate hmac-sha256 hashes of the SAS keys which in itself is hard without bulky libraries. A more practical solution is probably to use MQTT from the photon to a Protocol Gateway in front of the Event Hub. It’s such a shame that IoT Hubs don’t natively support MQTT.

Since GA Azure IoT Hubs has native MQTT support built in. The problem is it requiring MQTT-TLS/SSL which is not supported on the Photon. I really hope this will change in the future.

@Dave @5e8a @graemethc @fbt

It’s a shame we never got to the bottom of this - I am in exactly the same situation and completely stuck with it all. I’ve tried Microsoft’s libraries (which are useless for a board like this) and native MQTT is proving impossible, with all of the authentication that is needed with the Azure IoTHub. Can we reopen this thread and work on it together?

I’ve seen a couple of tutorials on this site but they seem to like to the Azure Event Hub, not the IoT Hub directly. Also, these tutorials rely heavily on the CLI to set websockets, when I think a lot of novices like me would prefer to use the web UI.

Thanks

Hi All,

We spent a lot of time and effort optimizing our protocol and encryption layer to run on these embedded devices, so while I’m not surprised it’s hard to connect to their services directly, I’m hearing that you’re interested in getting your data into Azure. What about the webhook experience is getting in your way, what kind of integration would you want to see? Can you tell me more about your projects?

Thanks!
David

Hi David,

I can’t get the Webhooks to communicate with the Azure IoT Hub. There’s so much information out there, with conflicting information, which is confusing me on the layout of the webhook. I’ve heard a lot of talk that simply copying and pasting the SAS details works but only within the time that the SAS token is valid? The whole thing confuses me.

thanks

I want to connect an Electron to (ideally) an Azure IoT Hub (using webhooks is fine). Just to monitor some sensors that the Particle is connected to. These get processed by our cloud system.

Hi @joearkay,

Good question! You can give the hook your sas key and secret, and it’ll construct the special headers for Azure on its own, allowing the hook to last indefinitely.

Here’s an example:

{
    "eventName": "your_event",
    "url": "https://your_service_bus.servicebus.windows.net/your_event_hub_name/messages",
    "requestType": "POST",
    "azure_sas_token": {
        "key_name": "YOUR_KEY_NAME",
        "key": "YOUR_PASSWORD"
    },
    "nodefaults": true,
    "mydevices": true
}

Here’s a project I built using Azure Event Hubs, Stream Processors, Sql Server, etc, etc. I’ve done a few presentations for it, but I haven’t done a full Hackster post yet explaining all the steps - https://github.com/dmiddlecamp/petesfarm

Thanks!
David

@dave brill thanks! Any way to do this with the azure IoT hub opposed to Event Hub?

Thanks

Hi @joearkay,

What I’ve heard is from a webhooks perspective, Azure IOT is reallly close to Azure EventHubs. I think Microsoft changed their access provisioning system such that each message belonging to a device requires a separate SAS Key/Secret, which makes using one hook for a lot of devices difficult. This could be solved with a more custom / deeper integration that sends special requests to their provisioning system, but since we already have a really strong device management platform, that seemed like overkill for an MVP.

I think if enough of the community were really excited about deeper Azure IOT integration / support, that might be something we could invest time on. At the moment, as far as I know, most Azure-y things can really easily be accomplished with our existing webhook support and Azure Event Hubs, but it’s certainly not something we’ve ruled out for the future.

I hope that helps!

Thanks,
David

Hey Guys,

I have found some good tutorials about this though still I had no success in sending data to Azure, it would be nice is there was a simple step by step video out there.

Since I have spent weeks losing my mind over it and just give up and connect to simpler clouds.

Have other had any luck sending data there?

Cheers,

Erkele

1 Like

Ok brill, thanks David!

@Dave

Hey, Dave, I have come to the conclusion that I think storing data send from my Photon-based product in Azure and then using Microsoft Power BI visualization software to create graphs and charts which will be embedded into web pages is the way to go for what I’m trying to accomplish.

I wanted to check in with you since you seem to know how to get data sent from a Photon into an Azure database using Webhooks.

So as of right now what is the best practice for pushing sensor data from a Photon / Electron directly to an Azure Database?

Also is Azure Event Hubs what I should be looking at using vs. just an Azure Database?

Any advice is greatly appreciated!

Hi @RWB,

Good question! I think this is something we want to keep making easier. Eventually I expect you’ll see a “database connector” on the integrations page that would let you simply specify a table / connection string to your favorite database.

For my example app, I setup a webhook to an event hub, and then I had a stream processor gathering events from that hub, and transforming them into a database. That’s a fairly expensive option, since you’re paying for a hub, and a stream processor on Azure. I think if I did it again, I’d just spin up a super-simple web app to catch the webhook events, or a worker to subscribe to my event stream, and use that worker to dump events directly into the database. Until we have a database connector released that is. :slight_smile:

I have some of my notes here, but it’s not super well documented yet if that helps:

Thanks!
David

Yes, easier would be a good thing for sure.

Microsoft Power BI dashboard interface has high integration with Excel spreadsheets which it can use to create all the charts and graphs.

Since a few people have documented how to send data from a Photon to a Google Excel spreadsheet; I think I’ll explore that method of databasing sensor data into a format Power BI can use and see how that goes.

I’m not sure what the limitations of logging to Google Sheets are but I’m going to look into it.

Any idea on when a Database Connector for Azure could be available?