0

I have already written Azure Functions in Python, and know there's also official support for other popular dialects - JS, Java, .NET, etc. BUT, I have a special scenario, where I wish to execute some functions originally written in bash, or to be able to access such *nix utilities as calc, sed, awk and more.

I know that Azure Functions are meant to abstract away the server and even environment(?), but is there a way one can still install and run *nix like utilities or for that matter any exes (since *nix can port).

Some ideas am toying with:

  • include binaries in /bin folder of my python project,
  • and then invoke it using something like:

    from subprocess import call
    
    call(["cal", "-y"])
    

Problem; Can I do this without having to deploy my own binaries?

TL;DR: How to execute own binaries and access Shell inside Azure Functions?

1 Answer 1

1

Obviously, Azure function is running on Windows Server.

After my research, I found that the azure server was pre-loaded with git bash.

You can find the following path on the Kudu:

D:\Program Files (x86)\Git

If you want to run *nix command calc on windows, you need to download calc for Windows execution files and upload it to Kudu.

enter image description here

enter image description here

Then add the current directory to the environment variable.

D:\home\site\mybin>set PATH=D:\home\site\mybin;%PATH%

enter image description here

Please make sure you add your environment variable in front of the variable D: \Windows\System32; so that you can overwrite Windows own calc command.

Verify:

enter image description here

When you execute calc commands in Python, please use the os.environ and os.putenv to set your own environment variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.