Calling Cloud Function with ParseReact - parse-cloud-code

With ParseReact, it is possible to call Parse Query in a reactive way. I try to call user defined function from Parse Cloud Code but I don't see how to do. So do you have example about calling a cloud function in ParseReact

Related

Getting ExecutionContext in other libraries/projects in Azure Function App

The execution context that is injected to a function (https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function), is it possible to get it in some other helper libraries.
I want to get the InvocationId of the current function in some other libraries. For e.g. let's say I have written a logger and I need to add the Invocation ID for every log. One trivial way to achieve this would be to pass the Invocation ID from the function to all the helpers, but it may not be possible especially if one is working with legacy code.
In App services we could solve this problem by getting access to the HttpContext via the IHttpContextAccessor.
Is there any alternative to this in Azure function?

How to make a function as default in azure function app?

I have an azure function app (abc.azurewebsites.net) and have a function named Function1 defined in it. (abc.azurewebsites.net/api/Function1?code=def==)
Is there a way in which, I can define this Function1 as default and all the incoming requests to abc.azurewebsites.net gets routed to my Function1?
Thanks.
You could use proxy to get this.
Follow this tutorial, and the Route template should be /, and then you should change your function authLevel to anonymous like this.
1.Set the application setting add HELLO_HOST(any parameter same as the backend url) with value <YourBackendApp>.azurewebsites.net.
2.Create the proxy.
3.Set your function to anonymous then your function don't need API keys code to call it.
Then below my test result, it's a HTTP trigger function with query string &name=<yourname>.

context.log vs console.log in Azure function apps

In the nodejs examples for Azure function apps, there is a passed in context obj to the function and it is possible to do context.log in the same manner as you can with console.log to output messages.
What is the difference between these two methods and does it matter which you use? Thx.
This documentation should answer your question :)
In Functions, you use the context.log methods to write trace output to the console. In Functions v2.x, trace outputs using console.log are captured at the Function App level. This means that outputs from console.log are not tied to a specific function invocation, and hence aren't displayed in a specific function's logs. They do, however, propagate to Application Insights. In Functions v1.x, you cannot use console.log to write to the console.
Long story short - context.log is best!
You can redirect console.log to context.log with my npm package so you dont have to pass down the context everywhere.
https://www.npmjs.com/package/azure-function-log-intercept
Source here if you just want to create your own module
https://github.com/BrianRosamilia/azure-function-log-intercept/blob/master/index.js

How to do unit testing for a function calling a private function , which makes an external API call in nodejs?

How to do unit testing for a function calling a private function , which makes an external API call in nodejs. What i want is that my test should not be dependent on response from an external call and I thought of mocking the private function through which API call is made but I can't seem to achieve that. What should be a good approach to resolve this?
You can mock/stub the package you are using to call the external API (http, request, etc). By doing that, you don't need to depend on any external resource, and also, you don't need to change you code to expose and override/mock the private function code.

Cloud Functions for Firebase error: "400, Change of function trigger type or event provider is not allowed"

When I run firebase deploy I get this error message:
functions: HTTP Error: 400, Change of function trigger type or event provider is not allowed
TL;DR
firebase functions:delete yourFunction // this can be done via the Firebase Console as well
firebase deploy
Explanation
Basically, Cloud Functions expects the same trigger for every function all the time, i.e. once it is created it has to stick to its original trigger because every function name is connected to a specific trigger. The trigger can therefore only be changed by deleting the function first and then creating it again with a different trigger.
This can now be done easily by using the functions:delete command:
firebase functions:delete yourFunction
The documentation features more advanced use cases as well.
Old solution
Solution of this is basically commenting or cutting out your function and then saving the Functions file and deploying. The function will get deleted in Firebase, but after that you can insert/uncomment your function and it will deploy just fine again. This error occurs when you take a function and change the type of trigger that it uses, i.e. HTTP, database or authentication.
Firstly cut it out
/* exports.yourFunction = someTrigger... */
And then, after deploying ("firebase deploy") replace your trigger
exports.yourFunction = anotherTrigger...
For those who stumble upon this in the future, the Cloud Functions console now offers a delete button.
You can also go to the Cloud Functions panel in the Google Cloud Platform console and delete your function from there. After that you can upload the function normally from firebase CLI. Not sure why they don't have a delete function option in the firebase console.

Resources