Dude, where's my PowerShell (Azure Function)?

I'm writing this blog because for the last couple of days I've been driving myself mad trying to create a new Azure Function. It's not been a case that I've not been able to create one, I just haven't been able to create one which is immediately geared up to run with PowerShell. Admittedly I may have missed an announcement from Microsoft with regards to the changes that I'm about to describe, however I'm sure I'm not the only one who will be looking at the portal trying to figure out why I can't develop something with my beloved PowerShell.

EDIT: Whilst writing this Blog I conducted a more informed search (now that I understand what to search for...) and have found this really useful page from Microsoft: https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions

I admit I'm quite late to the game in terms of adopting Azure Functions. I always understood the benefits, but now I'm using them in anger as much as I can in support of my developments in Flow, PowerApps and SharePoint. The whole concept of just throwing small snippets of code up into Azure which I can call as and when I need is brilliant, and if you're not already exploiting this then would really suggest your spend some time getting to grips with Azure Functions. It doesn't really matter what your choice of script is either as there's support for most of the modern scripting languages, including PowerShell which is a major benefit to my team of Consultants and I as I don't specifically need a developer to work on them.

Previously, however, it was quite easy to create a PowerShell Function, once you knew where to look, as PowerShell was always considered to be "experimental"! But since Microsoft have updated the Function creation wizard in the Azure Portal, it's even more tucked away, and I couldn't find anything which really explained what was going on.

When I go to the Azure Portal (portal.azure.com) and create a new Function App now, there are a few differences. Don't get me wrong, I really like what Microsoft have done here and I'll start to illustrate what's changed.

Create the App - This hasn't changed, so I'm not going to document this part as it's still a case of fill in the name of your app, select your desired location etc and provision your new resource.

The Function App overview panel hasn't changed much other than the big "+ New Function", however this is where the big changes start to surface.

You are now effectively working through a wizard to set up your Azure Function which starts with selecting what your development environment is, and depending on what you select you will see a list of instructions of how to create your function. If you're selecting "In-portal" then you can select your Function template, be it Timer, HTTP Trigger, Queue trigger etc. No matter what you choose, you will create a .NET Core function with C#.
 
After some digging around the portal, I finally found out why this is. The default Runtime version for the Function Apps is now version 2, which at the moment only has support for .NET Core. You can however change it back to use Runtime version 1, by going back to your Overview panel, and then selecting Function App Settings. You will notice that ~2 is the selected option, change this back to ~1. This may take several seconds to take effect.
Now that I've changed it back to version 1, you can go and add a new function again.
Now I can follow the same process to create a PowerShell based Function as I did previously, which is to select "Create your custom function",  which will then show me the gallery of possible Triggers which I can select. Don't forget that you need to toggle the "Experimental language support" at the top of the screen to see PowerShell.

Once you've created the Function from your template, you are then good to go.

I hope that helps and saves others a bit of time next time you create an Azure Function.

Comments