1

I have an external application which I want to launch and wait for a response from using an azure function, i.e. allowing me to execute it from PowerApps and Microsoft Logic.

I cobbled together some C# code (below - it is probably wrong) which should execute the process with the params supplied and report the STDOUT.

namespace FunctionApp1
{
    public static class Function1
    {
        [FunctionName("GetInfos")]
        public static void Run(string param, ILogger log){
            var process = System.Diagnostics.Process.Start("Obscure_Application.exe", param);
            var output = process.StandardOutput.ReadToEnd();
            process.WaitForExit();
            log.LogInformation(output);
        }
    }
}

I realize that if this application were to run it would have to:

  1. Be running on a machine with Windows OS.
  2. Have the application installed.

As far as I understand the Azure Function hosts the runtime. How do you therefore:

  1. Ensure it is running on the correct OS?
  2. Ensure it has the correct applications installed?

Edit:

This is different from Run EXE in Azure Functions, because a specific requirement is that the software is installed. The solution given in that question is strictly regarding self-contained exe files. If software is supplied as an installable msi, the above solution will not work.

Sancarn
  • 2,575
  • 20
  • 45
  • 1
    I assume that you know that you won't be able to use the Azure-hosted Functions, correct? You can, however, do all this when hosting the Functions yourself. For example in a container – silent Dec 02 '19 at 14:01
  • @silent I didn't know that at all no! Is that so? I mean, it would make sense to me if that were the case, but I didn't know that at all. I had hoped the hosted functions could accommodate for this. But thanks that is very helpful to know. – Sancarn Dec 02 '19 at 14:03
  • Does this answer your question? [Run .exe executable file in Azure Function](https://stackoverflow.com/questions/45348498/run-exe-executable-file-in-azure-function) – Murray Foxcroft Dec 02 '19 at 14:06
  • If your application is a simple, self-contained .exe, then this might still be feasible. Similar to what @MurrayFoxcroft pointed out: https://learn.microsoft.com/en-us/samples/azure-samples/functions-dotnet-migrating-console-apps/run-console-apps-on-azure-functions/ – silent Dec 02 '19 at 14:11
  • However, you said "application installed". Installing any tools in the hosted Functions environment is not possible. – silent Dec 02 '19 at 14:12
  • Yeah I did mean fully installed. E.g. custom software from a 3rd party which installs from an *.MSI. So in these cases you need to self-host a server and build a REST API I suspect? – Sancarn Dec 02 '19 at 14:15
  • 1
    yeah you could do that, or perhaps simplify it by wrapping it in a container and then deploying to a container service. But certainly, using something like Functions will never work - the whole point of them is that they're a "serverless" environment, where you don't have to know or care about the underlying server environments. The tradeoff of that is that you don't have any access or control over the server either, so you can only do what is permitted by the service provider. – ADyson Dec 02 '19 at 14:19
  • @ADyson "something like Functions will never work" is not quite correct. You can host the Azure Functions runtime anywhere. There you can indeed install any software alongside your Function on the same host, if you have that control over it. – silent Dec 02 '19 at 14:43
  • @silent true, but I suppose I was talking about the conventional scenario (which OP was referring to I think) where you simply run it in the standard Azure environment – ADyson Dec 02 '19 at 15:12

1 Answers1

3

As discussed in the comments:

When the requirement is to actually install software (.msi etc.), you cannot use the the Azure-hosted version of Azure Functions since you do not have that kind of control over the environment there.

If you would still like to use Azure Functions, you can though: By hosting the Functions runtime in a container and add your applications to it as well. In this case, the Function code can access anything on the host just as any other application code could.

There was also a non-container based version of self-hosted Functions but it looks like that preview is not updated anymore.

silent
  • 14,494
  • 4
  • 46
  • 86