I am trying to learn Azure Functions by creating a bot that checks the stock prices. Ticker prices should be obtained using the BitMex API over a websocket.
Since Azure Functions currently do not directly support websockets, what implementation would you suggest I use?
There are many SignalR examples , but they all involve your own code forwarding data to SignalR in some way. I need SignalR (or whatever solution) to get the data from a foreign server via API.
The solution must preferably be serverless.
Related
I have created a Monitoring Metrics Dashboard in my Google Cloud Console. The dashboard is working as expected, but since my app is highly dependent on those metrics, I was thinking about creating a schedule to see these metrics data and update the server accordingly.
After investigating the dashboards, I have noticed that there is an MQL query. Is there any way to execute this query in my node.js function so I can fetch the data and update the server?
You can try MetaApi https://metaapi.cloud cloud service which provides REST API and WebSocket API access to both MetaTrader 4 and MetaTrader 5 accounts.
Official REST API documentation: https://metaapi.cloud/docs/client
SDKs: https://metaapi.cloud/sdks (javascript, python and Java SDKs are provided as per April 2021)
It supports reading account information, positions, orders, trade history, receiving quotes, and accessing market data.
The service also provides copy trading API https://metaapi.cloud/docs/copyfactory and API to calculate forex trading metrics on a MetaTrader account https://metaapi.cloud/docs/metastats.
There is a case similar to yours in Stackoverflow (answered by user3666197).
And also you can easily connect your nodejs server in mysql. MySQL is one of the most popular open-source databases in the world and efficient as well.
Please follow Nodejs mysql tutorial for more details about the steps/process process of how to connect nodejs server to mysql.
We are attempting to get Azure SignalR serverless to with a dotnet core API application. With "default" SignalR, we ran into scaling issues in Azure as server instances behind an API App would continue to receive socket connections even as its CPU increases. There is no way to currently to change load balancing behavior or to take an instance out of traffic. As such, we've looked to use "serverless", however, all documentation points to using Azure Functions. However, given that serverless uses webhooks and such, we should be able to use anything that can take an HTTP request. We already have our APIs setup so getting this to work against out APIs is preferred.
Update 1
Effectively, we're looking for support for serverless that Functions get but for APIs. Functions have triggers and Serverless Hubs to inherit from, etc etc. These things handle negotiate calls and deserialization of negotiation data and all the other things SigR has to do. We're looking for something similar for, I guess, API controllers.
Thanks!
I'm trying to figure out how to connect my angular app to azure service bus. The reason I'm trying to do this is to setup real-time pub/sub solution for live auctions. I haven't really seen any start to finish documentation/tutorials on this with MEAN stack so I'm trying to piece it all together. In order to connect to my nodejs backend, what should I be using in Angular to make that connection? All the tutorials I see are referencing SignalR, but they are using .net. Is there a library that is equivalent for Nodejs or do I need to be using something like this?
I appreciate any help/direction!
It's not entirely clear if you are trying to connect your Angular front end to Service Bus as a replacement for SignalR. If so, it isn't a good idea as it would create a serious security hole. Service Bus is primarily for communication between servers. In this scenario, if you had multiple back end node servers, you could use Service Bus to sync the data they are pushing to your clients.
You are going in a better direction with SignalR. The technology you are looking for in real time server-browser communication is websockets. SignalR is just a .NET implementation of that standard. Once you start looking for websocket implementations on the MEAN stack, you should have a lot more success in finding guides. Here's a couple for generic JS implentations just as an example: Link 1 Link 2.
Edit for comment response:
You don't want to connect angular to Service Bus at all. Once you've exposed the keys publically, anyone can read/write whatever they want to your bus. Instead have Angular send the message to a HTTP function and have the function send the message to Service Bus.
The second problem with this plan is that websockets connections, the part that pushes data back to the client, is a long-running connection with constant communication back and forth. The consumption and premium plans are not built for this. Trying to use websockets on those plans will run up your costs a lot higher than they need to be if you have any significant traffic. You'll need to choose a plan that has a flat monthly cost instead. At that point you could still use Functions, but it may be easier to use a traditional web app.
In this case your system would look like this:
Angular new message -> HTTP Function/Web App -> Service Bus -> Websocket Function/Web app => Angular
If you are only running a single server, you can eliminate Service Bus completely.
The other option is to still use a HTTP function to receive new messages, but then use the SignalR service (not the .NET library) to handle pushing the data to the clients. This elimiates Service Bus as well.
This is what it would look like: Angular new message -> HTTP Function/Web App -> SignalR Service->Angular
Is there any integration between CosmosDB and Api Apps? I'm kinda new in Azure and I don't really understand which is the best approach.
My problem is that I am working on an IoT Project which gets data from the IoT Hub, passes it to a Function that sends it to the CosmosDB which then would need to be consumed by a Frontend. A pretty standard case.
I would usually create a backend to place between the database and the frontend but I really can't understand which is the best way to do it in Azure. Should I use the Api Apps or the integrated SQL Apis that are provided with CosmosDB? Are the Api Apps comparable to "containers" for my backend or do they have any other use other than keeping my code in a cloud machine?
Thanks a lot in advance!
You can't (well, shouldn't) have your frontend to directly call the database so you need a middle layer of some sort.
Creating an API could be one of the ways you go about it but based on your use-case, I would go with an HTTP Trigger Azure Function which would be the API that exposes the data.
You can then use the Cosmos DB Input Binding to retrieve the object you want to return and simply return the JSON of it.
I'm building a game for Windows Phone 8 and would like to use Windows Azure SQL Database for storing my users' data (mostly scores and rankings).
I have been reading Azure's documentation on SQL Database and found this link which describes just the scenario I'm looking for (it's Scenario B in the picture): I want my clients (the game running in a user's windows phone) to get data from an SQL Server through a middle application also hosted on Windows Azure.
By reading further the documentation (personally I think it's really messy and hard to find what you're looking for in there), I've learned that I could use Cloud Services for this middle application, however I'm not sure if I should use a background worker which provides an HTTP API or a worker with a Service Bus Relay (I discovered that I can use service bus in WP8 in this link).
I've got a few questions that I couldn't find an answer to:
1) What would be the "standard" way to go in this case?
2) If both ways are acceptable, are there other advantages to using a Service Bus other than an easier way to connect and send messages to my middle application? What are the disadvantages?
3) Is a cloud service really what I'm looking for (and not just a VM with the middle application code running in it)?
Its difficult to answer these sort of question as there are lots of considerations. I don't believe there is a necessarily 'standard way'.
The Service Bus' relay service's purpose is to help traverse firewalls and NATs, not something that directly relates to your scenario, I suspect.
The Service Bus, though, also includes a messaging capability which provides queues, topics and subscriptions to use to exchange messages between clients or client/server.
You could use the phone client to write and read messages to/from queues. you would then have a worker role hosting your application logic and accessing the database as needed.
Some of the advantages of using messaging include being load leveller, helping handling peaks in traffic (at the expense of latency), helping separating concerns and allowing you to accept requests from the clients when the backend is down as so can help with resiliency.
In theory they can also help you deliver messages to the client in the same fashion, by using a queue or subscription per client, but for a large number of clients this may become a management issue.
On the downside you would have to work with what is a proprietary protocol, and will need to understand the characteristics and limitations of the service bus. you will need to manage the queues and topics over time. there will also be some increased latency, although typically not an issue and, finally, you will have to implement asynchronous messaging on the client side which has advantages but is also harder to implement.
I would imagine that many architectures follow the WEB API route by using a web role cloud service exposing the API. The web role can then perform any business logic and connect to the database in the background.
A third option, which you didn't mention, is to use Windows Azure Mobile Services and implement your business logic as a service API there