Open API specification for Azure functions using JavaScript (Node js) - javascript

I want to add Open API specification to create swagger document for endpoints of Azure function app that is developed using JavaScript (Node js).
I understand this can be done in Dotnet Azure function app using the package Microsoft.Azure.WebJobs.Extensions.OpenApi.
Is there any such package available for Javascript Azure function? Or Suggest any other alternative to create documentation for Node azure functions?

We have two options available for integrating Open API specifications with JavaScript Azure Function which are MSAL and ADAL.
The Microsoft Authentication Library (MSAL) enables developers to acquire tokens from the Microsoft identity platform in order to authenticate users and access secured web APIs.
Using MSAL, a token can be acquired from a number of application types like web applications, web APIs, single-page apps (JavaScript), mobile and native applications. Check this Microsoft Authentication Library for JavaScript for more information.
Similarly, the Azure Active Directory Authentication Library (ADAL) for Node.js enables Node.js applications to authenticate to Azure AD in order to access AAD protected web resources. But since ADAL is being deprecated, it's recommend that you use the Microsoft Authentication Library (MSAL).
For more information check this Azure AD Library for JavaScript.

Related

How can I send livestream to YouTube using node js

You may know the software called OBS studio: by only knowing the live stream key, it sends live stream to YouTube.
I am supposing that it is using some kind of YouTube API to do that. If that's the case what is that API? Can I use this with Node.js?
Google offers an API that is quite reach of features:
YouTube Live Streaming API.
You may begin your journey by reading the official getting started doc: YouTube Live Streaming API Overview. Then I recommend absorbing these two important documents: Life of a Broadcast and Understanding Broadcasts and Streams.
Depending of the type of application you intend to develop (desktop app or server-side web app), you need to get acquainted with the so-called OAuth 2.0 authentication/authorization flows (since all the endpoints of this API require OAuth): OAuth 2.0 Flow: Installed apps or OAuth 2.0 Flow: Server-side web apps.
For what concerns Node.js, Google has made available a client library: Google API Client Library for Node.js (alpha); and also some Node.js sample code, that, unfortunately, does not yet include programs exercising the Live Streaming API.
There is the YouTube Live Streaming API. It is an HTTP-based API, so you will be able to access it from Node.js as well as basically any other programming language capable of making HTTP-requests.

Connecting WebSockets from browser to other applications

Presentation
My application is split in 3 parts :
C# .Net 5.0 desktop application that harvest and distribute data
Angular 10 static application that control the C# app (start/Stop) and
print the data in the form of charts for the user
Azure Function Rest API used as a backend for the Angular Static
Application (.NET core 3.1)
My goal is to have a WebSocket used for "real time" communication between the C# and Angular app instead of relying on Http Request to Azure Function REST api
I don't use a "classic" server like express.js. Azure Function replaces it fully.
Because of that, I'm using the service Azure WebPubSub to host the sockets.
Problem : I cannot connect the websocket I create from Angular (Browser Application).
The problem doesn't come from WebPubSub because the WebSockets are fully working (sending & receiving) between my C# app, Azure Functions and even some node.js test scripts.
Also, my web socket created in the browser app can communicate with itself but no other apps get the message send from my websocket in browser app.
Question : Can I communicate from the browser to others app in real time (websocket based) with my current architecture and if yes, how ?
On the Azure WebPubSub Documentation Page there are no examples of what I try to achieve. Same thing searching on the internet.
A solution using an Express.js server linked to the app, being the could be used as the middleman between the browser app and c# app. But I want to avoid it if possible.
I just want to know if what I'm trying to do is possible.
Also, the app could be re-done in React.js so non-Angular specific answer are better.
The Web PubSub logstream sample:https://learn.microsoft.com/azure/azure-web-pubsub/tutorial-subprotocol?tabs=javascript sounds like a similar scenario.
Your AngualrJS Web App is similar to the logstream's web application, and it joins the stream group.
Your C# .Net 5.0 desktop application is similar to the logstream's message publisher application stream: https://learn.microsoft.com/azure/azure-web-pubsub/tutorial-subprotocol?tabs=csharp#publish-messages-from-client, which send messages to the stream group.

Securing API key in React SPA

I am a new developer. I have a React SPA deployed on Firebase that queries Google’s Geocoding and Time Zone APIs. I cannot restrict access based on HTTP referrers/domain names because these APIs are web service APIs and have to be restricted based on IP address. However, there does not seem to be a way to get the IP address of a Firebase app.
So my question is, are there alternative approaches to using and securing API keys in my app? I am particularly interested in approaches that leverage any inbuilt capabilities of React or Firebase.
An IP restricted API is supposed to only be used in server-side applications.
I suppose you should configure your key restrictions for Android/iOS apps:

How to use a Node.js web server with an Apache Cordova Application

I have designed an Apache Cordova Application that uses a Node.js web server to pull data from a web API and allows the Javascript based project to use data pulled from this API.
Is there a way that I can use this Node web server across an iphone implementation of this cordova application? I am currently testing the application by pulling data from the website's API, hosting in on a node (ex. localhost:3000) and then pulling the data from that address in the JS file in my project.
How can I implement this server so that it can be used on an iOS mobile device?
If you want to host your Node server somewhere so that devices can see it on a network, then Amazon AWS Elastic Beanstalk has an easy solution for that - just upload your Node project in a Zip file and they manage the server environment for you.
There's several other options out there depending on your needs, for example Heroku may be a good alternative.

how to connect with azure service bus topic with javascript

I am creating a mobile application with cordova(phone gap). I would like my app to talk with an azure service bus to post messages to a topic and read messages from a subscription.
I have found all kinds of details on how to do this with c#, java, python, node.js. However I haven't found any details on how to do this with pure javascript.
Is this possible? or must I use Azure mobile services and configure it to communicate with the service bus?
CORS - Cross-Origin Resource Sharing is now supported in windows azure for storage ,table and queues. So you access the REST api of these from javascript. Topics and Subscriptions are not mentioned here though. http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx
Also if you have not already check out Azure notification hubs which may help in your requirement. But mostly for notifications to cross platform devices.
You can use REST API to enqueue messages to a topic: http://msdn.microsoft.com/en-us/library/windowsazure/hh780786.aspx
Microsoft provides Service Bus REST API
https://msdn.microsoft.com/en-us/library/azure/hh780717.aspx
Microsoft provides two ways to authenticate
1. Azure Active Directory (Cordova project sample that uses AD)
2. Using certificates
If you want to do it using certificates, you need to generate the .cer and .pem files and upload the .cer file to your Azure portal -> Settings -> Management Certificate
You can then trigger a http request by passing your .pem file to authenticate your application

Categories

Resources