Using firebase admin node.js SDK via edge.js (c#)

161 Views Asked by At

I have web service that writing in C# , and host in azure . As part of my processing I want to use the fire-base admin via my C# code. After I looking in the web I found the edge.js package that let you to run node.js scripts under C# , I install the package and success to run different node.js scripts via C# . The problem start when I try to use the firebase admin SDK . I install the firebase lib via npm (npm install firebase-admin -g) as global package. Then I try to use it for calling the firebase lib , I try only to load the lib and I received error.

 var func = Edge.Func(@"

return function(data,callback)
{
var admin = require('firebase - admin');
callback(null, 'test fcm ' + data);
}

");

The error I received in c# is :

An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll

So I have several question : 1. May someone success to work with the fire-base lib via edge.js ?

  1. How I can debug the error ?

  2. May someone have different method for calling the firebase admin nodejs sdk via C# ?

  3. May someone have any method for calling the firebase admin via C# code ?

Thanks , MAK

1

There are 1 best solutions below

0
Aaron Chen On

To avoid this error, you'd need to run the command npm install firebase-admin in the root of your c# project, it will install the dependencies in the node_modules folder for your project.

You also need to remove spaces from the package name as below:

var admin = require('firebase-admin');