0

I am trying to upload a blob in the Azure storage and it uploads successfully. Now the next step is to process the blob with C++ code. Since Azure function does not support C++ how can I process the blob?

Yatin Gaikwad
  • 1,140
  • 1
  • 13
  • 23
  • 1
    you'd have to first build your binaries and ensure that you are able to run them from .net/python/javascript code. once you are able to do that, now you can upload those binaries together wherever you've published your azure function. – Alex Gordon Jun 03 '19 at 17:22

2 Answers2

1

Azure Function support running .exe executable file. So I suggest generating your cpp program exe file, then upload it to Azure Function and run the below sample code.

enter image description here

using System;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    System.Diagnostics.Process process = new System.Diagnostics.Process();
    process.StartInfo.FileName = @"D:\home\site\wwwroot\TimerTriggerCSharp1\testfunc.exe";
    process.StartInfo.Arguments = "";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.Start();
    string output = process.StandardOutput.ReadToEnd();
    string err = process.StandardError.ReadToEnd();
    process.WaitForExit();

    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
}
George Chen
  • 13,703
  • 2
  • 11
  • 26
1

By now on Azure Functions as the comment said, there are .NET, Python, Node.js, Java supported, no C++.

However, if you are working on Linux, you can consider for calling C++ in Python or Node.js, such as following the documents for Python with Extending Python with C or C++ or for Node.js with C++ Addons. I think there are simpler for you to use event grid with Azure Function.

And there is an existing SO thread about Calling C/C++ from Python? that you can refer to.

Or else for working on Windows, the other solution is to compile your C++ code to a dynamic library in Visual Studio, and then you can invoke the dll lib in C++ from C# code. Please refer to the MSDN document Calling Native Functions from Managed Code to know it, or refer to the SO thread Possible to call C++ code from C#?.

Hope it helps.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43