Receiving Cloud-to-Device messages from Azure to esp8266 - azure

Using this project here Im able to get an esp8266 to send messages to the Azure Iot hub, and I can read them with PowerBI. However, I would like to be able to use the device explorer Twin to send messages to the device.
I imagine that since the esp is sending messages to the Iot hub using an HTTP POST request, that I should be able to use an HTTP GET request to read the messages sent to the device when using the correct endpoint, outlined here.
Is this correct, or am I missing something? Doing this seems to only cause errors. If this is the right way, what would the format of a proper GET request be.

Receiving Cloud-to-Device message from Azure IoT hub via REST api you can use GET method.
Different from POST method you need use "devicebound" instead of "events" in Request URI part.
About Common parameters and headers, only Authorization header is required and it is the same with in the POST request.
There is no body required in GET request.
So, your GET request would look like this:
GET /devices/[Device ID]/messages/devicebound?api-version=2016-02-03 HTTP/1.1
Host: [IoTHubName].azure-devices.net
Authorization: SharedAccessSignature sr=[Shared Access Signature]

Related

HTTPS endpoint of Azure event hub

I am using service that can only send messages using webhook. The only thing I can set up in that webhook are HTTP endpoint, user name and password (you can see it on the screenshot below). I would like to send messages to my event hub, but I don't know how to find its HTTP endpoint. The only thing I could find was SAS Endpoint.
Event Hubs offers a REST API that allows you to perform a subset of the operations supported by its AMQP API. Publishing basic events via REST is possible and would use the endpoint: https://{servicebusNamespace}.servicebus.windows.net/{eventHubPath}/messages.
The full set of documentation for the REST API can be found here, and the specifics for sending events here.

Sendgrid Event Webhook sends fake emails response and not real data

I have created a post api and did put that post api inside the event webhook settings of sendgrid. But when i enabled it and check the json response on my api in local, i am getting fake messages and not real data.
Anyone know whats the reason. I checked their documentation, it is not telling anything else.
Source of information : https://sendgrid.com/docs/for-developers/tracking-events/getting-started-event-webhook/
If you are using event webhook according to above documentation in the question. You wont get the real data as for testing purpose sendgrid sends that data from your account. Instead try implementing the API. Then you will get the real response as it would contain your sendgrid api key.

Can I send encrypted binary traffic to a WCF relay? If not, why not?

I am trying to use an Azure WCF Relay to send an encrypted AS2 message to a BizTalk WCF endpoint hosted on-premises. I've confirmed that the relay is connected on the receiver side and I've been able to send it junk text-based messages and confirmed that these arrive on the receiver.
My working AS2 sender is an Azure Logic App with the AS2 encoder and an HTTP send action. This works with another real AS2 receiver provided by a third party. The message is encrypted and signed and transmitted with a content type of application/pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m\" and a content transfer encoding of binary.
This yields a SOAP Fault as a response, with the fault code namespace of http://schemas.microsoft.com/netservices/2009/05/servicebus/relay. This pretty well confirms to me that it's the relay returning this error. Nothing at all shows up on the on-premises side. I've experimented with BasicHttpRelayBinding - which should expect SOAP - and WebHttpRelayBinding, which from my understanding, should accept anything. Neither works.
Must the message sent to a WCF Relay be a SOAP message? If so, how would I embed this binary content in it so that it can be unpacked and processed as "normal" AS2 on the other side? Otherwise, will this ever work, or am I onto a loser here?
If you want to send non-SOAP traffic over WcfRelay then use WebHttpRelayBinding.
Example:
https://github.com/Azure/azure-relay/tree/master/samples/wcf-relay/RelayHttp

Azure Iot Rest API Message from cloud to device

Get : https://myiot.azure-devices.net/devices/mydevice/messages/devicebound?api-version=2016-02-03
Authorization: SAS key
i am getting 204 No content response from above api while receiving message using postman request maker from cloud to device.When i send messages from device to cloud it is appearing in my iot hub but giving error 204 while receiving messages from cloud.
First, if you haven't sent Cloud-To-Device messages and you get No content response(error code:204) from calling the GET api(https://myiot.azure-devices.net/devices/mydevice/messages/devicebound?api-version=2016-02-03). It is expected. It means the server has fulfilled the request, but there is no new information to send back.
Second, you want to receive the Device-To-Cloud message you have sent. It is unreachable. Because this GET api is used to receive Cloud-To-Device messages.
In short, Device-To-Cloud and Cloud-To-Device are different messaging primitives that Azure IoT hub provides to communicate with a device. And Device-To-Device communication that you want is not supported natively with Azure IoT Hub.
Finally, how to send Cloud-To-Device message?
For test purpose, you can send Cloud-To-Device message from Device Explorer. More detailed information you can reference here.
Yes, you can send cloud-to-device message
POST : https://[iotHubName].azure-devices.net/devices/[deviceId]/messages/deviceBound?api-version=2020-09-30
Header must include Authorization like :
SharedAccessSignature sr=webchatIOTHub.azure-devices.net&sig=lc7seNnczkq7Xj0IDSdFHshTTHEJUDt4y98e9Eoj%2B18%3D&se=1655587178&skn=iothubowner
For SAS (sharedAccessSignature) you have to run PowerShell CLI :
az iot hub generate-sas-token -n [iotHubName]--du 3600000000
Also, you can view the RestAPI when you use the browser to send message to device
enter image description here

Send IoT Message to Azure Event Hub by URL

I am now using a Beacon Reveiver to get the iBeacon Information.
Here is the problem:
the receiver platform server only allow me to type a url.
How should I do to send the information to azure eventhub??
I found this API:
https://NAMESPACE.servicebus.windows.net/EVENTHUB-NAME/publishers/PUBLISHER-NAME/messages
I tried it ,but it seems doesn't work.
Do i miss anything?? or Can anyone teach me how to add the authentication in url? What should I do now?
Thanks
You must set an authentication HTTP header in order to send events to Event Hubs. You can't include authentication information in the request URL.
Even though you can't send messages directly to Event Hubs, you can develop a custom Web API that uses your own URL-based authentication mechanism and forwards the requests to Event Hubs (or another service). That defeats the purpose of using Event Hubs to some degree but gives you more flexibility.

Resources