Coder Perfect

Bicep – How to initialize app files of PowerShell Azure Function (e.g. requirements.psd1)?


Bicep is being used to build an Azure Function App that runs a PowerShell function. Except for one little problem, this works well.

App files that we need to initialize upon construction, specifically needs, are part of the function app definition. psd1, where the following modules are required:

Is it possible to accomplish this in a Biceps file? If so, how? If not, what is the best approach to go about it?

(We use Azure CLI with Bicep (az bicep), so a solution for that would be helpful.)

Asked by Heinrich Ulbricht

Solution #1

For the time being, I’m relying on deploying the requirements. After the Bicep deployment, save the psd1 file. (Note that every deployment of Bicep resets the file content.)

The Azure CLI command is as follows:

az webapp deploy --resource-group rg-contoso-test-westeurope --name func-contoso-test-westeurope --src-path "../../Azure/Functions/ContosoFunc/requirements.psd1" --clean false --target-path "/home/site/wwwroot/requirements.psd1" --type static

Answered by Heinrich Ulbricht

Post is based on