Today started out with some awesome Azure Functions news that Linux and Mac are now supported for running and debugging locally. As an avid Linux user and huge proponent of Azure Functions (and all things serverless, for that matter!), the timing was great. I needed to do a little work on Sherlock (an integration testing sandbox environment provisioning tool for Azure, written on top of Azure Functions).
For what it’s worth, I’m running Fedora 26.
Getting Azure Functions installed and running locally
I followed this great guide from Donna how to set it up and get rolling with a sample HTTP triggered Azure Function App. For the most part, this went well but there were a few extra things I had to do.
For the initial installation, I tried to run
npm install -g azure-functions-core@core as root, but I kept getting
Error: EACCESS: permission denied, mkdir '/root/.azurefunctions. Seeing the Mac instructions to add on
--unsafe-perm to the
npm install I gave that a shot and that seemed to install it correctly.
I then needed to install .NET Core for Fedora.
For what it’s worth, because I ran the npm install as root it appears as though I need to run all of my
func commands as root.
sudo func host start. I was greeted by familiar (from the Portal) and comforting feedback in my terminal:
I ran a quick curl on the URL that was displayed:
I chose to use Chrome to debug my node.js Azure Function (Donna showed how to use VS Code in her post, so if you are a VS Code user reference that. My preferred editor is Vim, so instead of using a different editor I chose to use Chrome for the debugging piece). In Chrome, I navigated to
chrome://inspect and selected
Configure.... I then added
localhost:5858 to the remote targets (as described in the blog post as well as displayed in the output when I ran
func host start).
chrome://inspect, the remote targets section was now populated with the nodejsWorker.js that Azure Functions was running. Clicking the inspect link opened up the source for the Azure Function. Almost there! I set a breakpoint and then ran the curl again. Sure enough! Breakpoint hit… success!
This is awesome. Glad to see that us Linux (and Mac) users can now work with Azure Functions locally!