Difference between azure notification hub and azure mobile services - azure

What are the main differences between azure notification hub and mobile services
Which is best to use when.
Thanks

Those services have a totally different purpose.
Mobile Services allow you to provide a backend to (mobile) devices running your apps. Imagine a database that is exposed via a REST based API. You can react on CRUD operations by writing JavaScript code (Azure uses node.js for this purspose) and restrict the access to the database. This allows you to rapidly develop new apps (or at least proofs). Via JavaScript you can send push notifications by communicating the Windows Notification Service (WNS), the Apple Push Notification Service (APNS), etc. or by accessing an Azure Notification Hub, but that's not a native capability provided by the Mobile Services, it's just talking to external services.
Azure Notification Hub allows you to manage push subscriptions on multiple platforms (iOS, Android, WP8, Windows Store) with one single component. You no longer need to track the subscriptions in your own tables (like you would need to do with a solution just based on Mobile Services) and don't need to care about scaling. Imagine different devices registering at this hub and you have the ability to send a push message to those devices without the need to know, what kind of device you're talking to. It's just an abstraction of pushing messages.
To clearify:
Pseudo code with manual subscription handling vs. Notification Hub. Manual way with direct communication with WNS/APNS/...:
// query your data tables to determine the devices to notify
// note, that you need to manage (insert, delete) all of those entries as well
var subscriptions = ...;
for (var subscription in subscriptions )
{
if (subscription.Type == 0) // WP8
{
// communicate with the Windows Phone push service to push
}
else if (subscription.Type == 1) // iOS
{
// communicate with the Apple Push Notification Service push
}
else if // etc.
}
With Notification Hubs:
// determine subscriptions to notify by tag, it's just that simple
var tag = 'player:12345';
var hub = azure.createNotificationHubService(/* credentials */);
// you don't need to care about WNS/APNS/..., the hub will do that for you
hub.send(tag, yourMessage, /* callback */);
I hope you get the picture.

Last week happened the #AzureChat and they answered this question too:
Q4: When should I use push in Mobile Services vs push in Notification
Hubs?
A4: Notification Hubs works with any backend, including Mobile
Services, your custom backend in the cloud, or your on-premises
backend. Use Notification Hubs with your custom backend (including
on-premises), if your backend needs rich high scale personable push.
Use Mobile Services direct push if your push needs in mobile services
are direct. Use Mobile Services and Notification Hubs if you need
richer push in your Mobile Services including broadcast & templating,
etc. - #kirillg_msft
A4: Notification Hubs are optimized to broadcast millions of highly
personalized push notifications within minutes. Mobile Services is
great for sending event-triggered push notifications. In a two player
game, for example, you would use push through Notification Hubs to
broadcast special offers to everyone at once, but push through Mobile
Services to notify Player B that Player A just completed his turn. -
#mlunes90
http://blogs.msdn.com/b/windowsazure/archive/2013/10/11/recap-mobile-services-azurechat.aspx

Check the features/pricing of both on the official pages:
Azure Mobile Services
Azure Mobile Services provides a scalable cloud backend for building
Windows Store, Windows Phone, Apple iOS, Android, and HTML/JavaScript
applications. Store data in the cloud, authenticate users, and send
push notifications to your application within minutes.
Azure Notification Hubs
Azure Notification Hubs provides a highly scalable, cross-platform
push notification infrastructure that enables you to either broadcast
push notifications to millions of users at once or tailor
notifications to individual users. You can use Notification Hubs with
any connected mobile application—whether it’s built on Azure Virtual
Machines, Cloud Services, Web Sites, or Mobile Services.
Use Azure Mobile Services if you need a server backend for your app, where you store data and implement server side logic. Azure Notification Hubs is included, which you can use for push notifications.
Use only Azure Notification Hubs if you don't need server side data or logic or are already using another service for this and only need a service to send push notifications.

Related

Use a custom angular client application with Azure IoT Central

I am exploring the Azure IoT central rest APIs to create a custom Angular client. Is this possible or does it have any limitations? IoT Central is attractive due to its pricing. Specifically, I found that retrieving multiple telemetry values isn't possible as per the following documentation page. Which means you have to send individual "get" requests to fetch multiple telemetry.
Azure IoT Central (get telemetry value)
Is there a possibility to register a call back and receive regular updates of the values like in event hubs? Basically I want to develop a custom client facing app with the IoT Central Pricing. Is it possible?
It is possible, to receive regular updates on telemetry you can use continuous data export. You can export to Service Bus, Event Hubs and Blob Storage. See the documentation here on how to set that up. You can receive those events in any JavaScript application.
Please be aware that continuous data export will give you updates from all devices. If you need to filter them out you will need to build something to filter that out. One example I have built in the past is a .NET Core application that listens to the messages and sends that to the different clients over SignalR.

Mobile app to iot communication in azure iot hub

I want to implement the following system.
There are users and each user will have an IoT device. The user should be able to do the following:
Login with their email and password.
Control the IoT device in real time (the user will perform some operation on the IoT device and the result will be displayed instantly on the app).
See the state of IoT device in real time. If something changes on the IoT device it should reflect on the app in real time.
I was wondering if this is doable using azure IoT Hub. I came across an architecture where the device is connected to IoT hub and the app is connected to signalR. The messages from IoT device will go to IoT Hub which will update the app using signalR.
But is there any way we can not have additional component like signalR? Can IoT device and mobile app be connected directly to azure IoT hub and exchange data between them without an entity in between other than IoT hub?
Connecting mobile app to IoT hub seems like an option but I did not find any way to implement email and password based authentication to allow users to connect to IoT hub.
Any help in this regard is appreciated.
You could absolutely go without SignalR. You can use the IoT Hub Service SDK to send C2D messages to your device from your phone, and also listen to the device telemetry with the same SDK.
However, it would probably be a better idea to have some restrictions on what you can do with that SDK. If the user first has to log in, I take it that they don't get access to every device in your application? Using some kind of role-based access might be preferable, you would build an API for that, which then uses the Service SDK to give you the data.
Also, even though you could listen to the device data directly from your phone, that means that if you have bad reception/wifi, data might not be received. You might want to consider storing it somewhere? I don't know the details about your application, but if you would then want to listen to events from that storage and send it to your app... SignalR might not be the worst idea.
"See the state of IoT device in real time. If something changes on the IoT device it should reflect on the app in real time."
For this EventGrid integration (https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-event-grid ) would help. For realtime telemetry as Matthijs said SignalR would be a better choice.If you are fine with some delay (say 10 sec) then Azure Time Series Insights can also be used.

Can we subscribe an email ID or Cell number as subscriber to Azure event hubs/notification hubs?

In my python application, if any bad/good event happens, I want to send the event details as notification message to user's email addresses or phone #s that have been subscribed to this application. So I am looking for publisher-subscriber model azure cloud
Looks like multiple Azure services achieving similar goal but having a thin line of differences. Event hubs and notification hubs seems promising. So my question is as follows:
Can email ID/phone # be subscribed to Azure event hub and receive the message being sent/produced to Azure event hub?
If not event hub, what is the correct option? Can I achieve it with Service bus or Notification hub?
In AWS, there is a service called SNS (Simple Notification Service) where one can subscribe email/phone number and opt for receiving event messages about that application. I am looking for equivalent to that in Azure.
You can use the Azure Logic Apps / Azure Functions with Event Hubs to achieve this easily.
Using logic apps you can do like simple as below image.
Logic Apps has many in-build connectors for most all Azure Services, you can use Event-hubs,Service bus,SQL etc.,
You can find all the list of available connectors here
Update 1
Once you connected the Event-Hubs to send an Email connector, you will automatically get all the available source data from event-hubs to email task. See below
You can achieve this by using Azure Application Insights. With this, you will be able to monitor your application and receive alerts during application unavailabillity, failures or even during performance issue.
Check this https://learn.microsoft.com/en-us/azure/application-insights/app-insights-tutorial-alert

Azure Iot hub client communication with multiple devices

I have a node.js server application that communicates with Iot devices using Azure IoT Hub service.
When I examine the sample code sample code from Azure repository about cloud to device message. I see that one client was created. If there are multiple devices and multiple messages to be sent to multiple devices, is it okay to create multiple Iot hub clients, or should I stick to one client solution. What could be the cons and pros of two approach?
Have a look at the Azure IoT Hub feature for your scenario such as a Schedule and broadcast jobs. This feature enables a cloud back-end to schedule and update millions of devices based on your needs.

Badge management with Azure Notification Hubs

I am investigating migrating from Azure Mobile Services push notifications to Azure Notification Hubs for two primary benefits: 1) pub/sub architecture using tags, and 2) abstracting the device registration.
However, I'm struggling to understand the pattern for device badge value management.
With mobile services push notifications it's straightforward to maintain the current badge value in the db for individual device registrations. But with Notifications Hubs where Azure maintains the 'subscribed' devices registrations and manages the fan out of device notifications, what is the best approach for the client devices to update their current badge value with Azure Notification Hubs?
I have reviewed the Azure documentation, viewed several of the excellent overview videos, such as Channel 9 Cloud Cover episode 100, but documentation and examples seem to be lacking with regard to Notification Hubs and management of badge values.
Thanks for your help, friends!
Unfortunately badge management is not straightforward in a pub/sub architecture. If you use tags to indicate individual users then you can keep your counter in your backend and then add it in your notification when sending to your hub.
In you are using tags as interest group, then things are not straightforward, and they depend on what you want that count to be. For some platforms (i.e. iOS and ANdroid) you can code some client code that keeps a personalized counter. Some other times however, one has to avoid keeping personalized counters and resort to use generic badges like "!" in Windows 8.

Resources