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 ?
How I can debug the error ?
May someone have different method for calling the firebase admin nodejs sdk via C# ?
May someone have any method for calling the firebase admin via C# code ?
Thanks ,
MAK
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');
Related
I am trying to follow this tutorial to run azure function app using C# using vscode.
But when I click the run button, it shows "You must have the Azure Functions Core Tools installed to debug your local functions." But I have actually installed it in my mac. When I click the install button, it shows errors like follows:
/bin/bash: func: command not foundThe terminal process "/bin/bash '-c', 'func host start'" failed to launch (exit code: 127).
And on the right bottom there is a small window showing:
Error exists after running preLaunchTask "host start". View task output for more information.
But when I use the command func host start in my local terminal, it can run smoothly.
We have tried the same but on Windows(OS) , Below are the workaround to resolve the above issue.
Created a new Azure function with HTTP Trigger using .net 6
Before debugging we have started the Azure storage Emulator/Azurite on local.
Or Alternatively, We can add "AzureWebJobsStorage": "UseDevelopmentStorage=true", in our localsettings.json and tried to debug by using .net Function.
OUTPUT DETAILS FOR REFERENCE:-
NOTE:- To run function locally based on the given MICROSOFT DOCUMENTATION:-
Click on Ctrl - (macOS) the HttpExample function and choose Execute
Function Now
Or, we can add a breakpoint over our function.cs file and type start debug as shown below :-
For more information regarding VS CODE on macos configuration Please refer this SO THREAD discussions .
So, I created an app with firebase authorization (Google Sign In), and I got it working perfectly. Now, I needed to import Firestore package, so I did it, tried my app once again after importing, and suddenly, my app gets stuck on following code (the code is from authorization, and was working before importing a new SDK package):
Firebase.Auth.Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(idToken: idToken1, accessToken: null);
It just executes this line of code and never finishes! I still get GoogleID token, but it just gets stuck on that line of code. There are some errors in logcat but I don't know if it affects my app:
Error Not starting debugger since the process cannot load the jdwp agent.
Error libprocessgroup set_timerslack_ns write failed: Operation not permitted
I've updated google-services.json file after creating the database.
I am using Unity 2021.3.2f1, Firebase 9.0 SDK, tried with the latest version of sdk and still getting the same results.
I searched about this, but couldn't find anything useful. If anyone has any idea what I need to do to fix this, please help. Thanks
My solution uses the latest version of .net which is 4.8. However, I see the following error message that complaints about a version 4.0 in Azure Pipelines. Can someone let me know how I could resolve this please ?
The error message indicates I need to install 4.0 but I don't think that's the solution. I also opened up the file Microsoft.Common.CurrentVersion.targets and line 1221 has the following. However, I know it is not advisable to edit this file.
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
The error message:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1221,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Note: There are many similar post in SO that suggest to install VS2019. However, I am getting this message while running the application on Azure Pipelines.
Update
From your description, you are using the Microsoft host agent and the pipeline pop out issue 'cannot found NETFramework,Version=v4.0'.
Your environment looks like this:
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#net-framework
or
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md#net-framework
You can see that the Microsoft host agent does not have the environment you mentioned.
Although you can install what you need at the beginning of the pipeline startup, I do not recommend this practice. Because when you choose microsoft host agent, every time you start the pipeline, you will be assigned a brand new azure VM machine, which means you need to install the relevant environment every time.
The recommended approach is to use a self-host agent. Please create a self-host agent based on your local machine (or another machine with the relevant environment), the steps are as follows:
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
Provided above are the installation steps of windows self host agent, the steps should be very simple, if you encounter any problems please let me know.
And after that, you can run your pipeline based on that self host agent like this:
pool:
name: <your agent pool name>
If you are using classic pipeline, just click and select:
(If you run successfully on local, then the agent based on local machine should also be no problem.)
And if this is still unable to solve your issue, could you please remove the in-private information and share the YAML file or JSON file, and let me know at which step you encountered this issue?
I published my c# .NET 5.0 code to azure functions (windows) and im getting this weird error message:
2021-06-21T01:56:53.465 [Error] Executed 'Function1' (Failed, Id=fdefdbba-49a7-44ad-8082-841d2941d90b, Duration=169ms)Unable to load DLL 'libgmp-10.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I tried to see the \wwwroot files on the azure functions console but then i get this error:
3 [main] ls (8392) C:\Program Files\Git\usr\bin\ls.exe: *** fatal error - Couldn't set directory to \\?\PIPE\ temporarily.
Any hints?
It seems that the deployment is not done correctly.
Libgmp-10.dll a DLL (Dynamic Link Library) file which is referred to
essential system files of the Windows OS. It usually contains a set of
procedures and driver functions, which may be applied by Windows.
Please delete the Azure Function and, re-create and deploy a fresh code using Develop and publish .NET 5 functions using Azure Functions OR if you are using ADO, Setting up a CI/CD pipeline for Azure Functions.
Let me know if you have any follow up questions.
I have a C# testing project that uses the Microsoft.PowerShell.SDK NuGet package. I use it to run a cURL command that I can't seem to get to work with an HttpClient (details on that here if you are interested).
It works great, except when I run as a weak user using RunImpersonated. Then I get the following exception:
System.TypeInitializationException : The type initializer for 'Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry' threw an exception.
With an inner exception of:
System.UnauthorizedAccessException : Access to the path 'CreateUniqueUserId' is denied.
I am not sure why my cURL powershell command needs to use Application Insights and I would like to turn it off if possible.
Is it possible to turn off Application Insights with the Powershell NuGet?
From the about_Telemetry help file:
To opt-out of this telemetry, set the environment variable POWERSHELL_TELEMETRY_OPTOUT to true, yes, or 1.
So running this when your application starts should do the trick:
Environment.SetEnvironmentVariable("POWERSHELL_TELEMETRY_OPTOUT", "1");