Creating PowerShell Azure Functions and deploying them with Bicep

Albert Starreveld
5 min readAug 9, 2022

Azure Functions supports various runtimes. One of them is PowerShell. Not all workloads of an Azure Function are complex. In that case, a PowerShell Azure Function might be useful to execute small tasks.

In this article, I’m creating an Azure Function based on PowerShell. I’m coding the required infrastructure with Bicep so that it can be deployed continuously too. As a result, with a couple of files, you can deploy the Azure Function and the changes we’ve made to it repeatedly, continuously.

Prerequisites

Azure Functions did not always support PowerShell. It was introduced in 2019. As a result, you need to make sure you’re using tooling that’s been introduced after 2019 to make sure you can use the Azure Functions PowerShell functionality locally.

To create and run PowerShell Azure Functions locally make sure to have installed the following tools:

  • Install PowerShell Core version > 7.x.x (Mac/Windows). Make sure the correct version has been installed by executing the following command:
pwsh
$PSversionTable
  • Install Azure-Function-Core-Tools version > 4.x.x. Make sure the correct version has been installed by executing the following command:
func --version

How to create a PowerShell Azure Function

To get started, create a blank PowerShell Function. The Azure Functions extension in Visual Studio Code can create all the files you need.

Install the Azure Functions extension in VS Code:

Install the Azure Functions extension in VS Code

In the menu pane on the left, an Azure symbol appears, click it:

Open the “WORKSPACE” tab and click the + icon. This will create a new Azure Function. Select the “PowerShell” runtime:

--

--

Albert Starreveld

Passionate about cloud native software development. Only by sharing knowledge and code we can take software development to the next level!