Can I use Firebase Functions Emulator with GCP Cloud Functions - node.js

I have a GCP project that uses node.js javascript Google Cloud Functions that are triggered by Pub/Sub topics.
When setting up local testing according to this doc, it seems quite complicated.
Using Firebase PubSub emulator and Firebase Functions emulator seems much easier. Can I just use the Firebase Functions Emulator with my GCP Cloud Functions?

No. You can only use the Firebase emulator with functions written using the firebase-functions node module and deployed with the Firebase CLI. It will not work any other way.
The ease of use is part of the value of using the Firebase tools over the core GCP tools, but you do have to choose to use them, as they are not interchangeable.

Related

Is it possible to use file system instead of actual Storage bucket in the cloud for development purposes (Google Cloud Platform)

I'm using #google-cloud/storage npm package to access bucket in GCP storage, everything works fine in production environment, but I would like to use local file system during local development, so that on the one hand any garbage won't appear in prod env on the other hand I won't impact other developers.
If this is not achievable what is the best way to use #google-cloud/storage during local development?
Some services have emulators:
https://cloud.google.com/sdk/gcloud/reference/beta/emulators
It appears there's any emulator with limited (!) Cloud Storage functionally available through Firebase but I've not used it:
https://firebase.google.com/docs/emulator-suite/connect_storage
I'm unclear how you'd use the Cloud Storage emulator from a non-Firebase Storage SDK but it should work as it will implement the underlying API. Perhaps using ClientOptions to override the default service endpoint.

How to upload file to firebase storage from nodejs - client side

I want to write a CLI app in nodejs that authenticates and uploads a file to firebase, I installed the firebase npm package but it is not well suited for NodeJS (client-side) use.
How can I authenticate and upload a file to firebase storage?
There are two Node.js modules for Firebase, one for server-side Node.js code, and another one for client-side Node.js code (like on IoT devices).
If you're running the code on a server, you'll want to use the Firebase Admin SDK to access Cloud Storage. Note that this part of the Admin SDK is a fairly thin wrapper around the regular Node.js SDK for Cloud Storage, so I also recommend keeping the documentation for that package handy.
If you're running the code on a client, unfortunately the Node.js module does not have built-in support for uploading files to Storage. You'll have to look for another way, such as creating a custom API that your code calls and that uses a supported SDK for uploading the file to Storage.

IBM Cloud: Access Cloud Foundry from app using API vs CLI?

I need to create a Node.js program which needs to run cf commands like cf a, cf cs etc.
While searching the web I found this two repos which don't seem official and no longer maintained anymore:
https://github.com/prosociallearnEU/cf-nodejs-client
https://github.com/IBM-Cloud/cf-nodejs-client
My question is, should I use those libraries or I can use a child process to call the cf cli commands (assume that the bin is in the env), what is preferred way?
Do NOT use the Cloud Foundry command line interface (CLI) for interacting with Cloud Foundry from an app. There are well-documented Cloud Foundry APIs for that. The CLI is just a wrapper around those API functions.
The Cloud Foundry API endpoints for IBM Cloud are documented and available for use.

Is it possible to install powershell on a web app hosted by Firebase?

Im hosting a node.js web app with firebase, and i need to run a powershell script. I have installed the node module "node-powershell" which works perfectly locally, however when deployed, it tells me that i need to install powershell (install it in the firebase 'computer'). Is there any way to do this?
Firebase Hosting is a so-called static hosting service. This means it serves the content as is, it does not interpret/execute that content in any way.
So most likely you're using the Cloud Functions integration with Firebase Hosting to run those Node scripts. And that turns this into a question whether Cloud Functions can run Powershell scripts.
I don't immediately seen an answer there, although you could potentially upload the binary yourself if that is available for the platform Cloud Functions runs on (Debian). For an example of this, see Can you call out to FFMPEG in a Firebase Cloud Function

What does the Serverless Framework offers for Azure Functions?

I wonder what are the features/capabilities that Serverless Framework gives me when developing Node.js functions in Azure Functions environment?
When I look to this CLI, there is nothing I cannot do with Kudu and GitHub integration (or for simpler scenarios - directly with IDE built into the portal).
So I wonder if I am missing something (and I will regret in the future), or Serverless Framework at this stage is more useful for AWS Lambdas?
The Serverless Framework is a CLI that offers the following:
Deployment: it will zip your functions/modules and upload to Azure.
Integration: you can integrate with Blob Storage, DocumentDB and create HTTP endpoints with the same configuration file.
Multi-vendor support: if you decide to leave Azure, migrating to AWS or IBM will be easier.
Configuration: YAML syntax is readable and overall configuration is simple.
Logs: you can stream the logs into the terminal.
Environments: you can replicate a dev stage into production.
Plugins: you can extend the framework features by yourself or use things that the community is creating.
When I look to this CLI, there is nothing I cannot do with Kudu and GitHub integration
That's great. If you have already stablished a development workflow to organize and deploy your code, maybe you don't need the Serverless Framework. The framework was created to help new users to deploy stuff, but it it based on Azure tools, so there is no magic happening there. Just some people trying to make things easier than using the Azure CLI.
Serverless Framework at this stage is more useful for AWS Lambdas?
Maybe. Depends if you think that Azure CLI is better or not than AWS CLI. I have tried to implement my own code to deploy AWS Lambda functions and I know how hard it is. There are many configuration steps and things to learn, which are very trivial to configure when using the Serverless Framework.

Resources