We are using Bicep to create an Azure Function App running a PowerShell function. This works well, except one detail.
Part of the function app definition are app files that we need to initialize upon creation, specifically requirements.psd1, where required modules are listed:
Can this be done in a Bicep file? If yes: how? If not: what is the recommended way of doing it?
(We are using Azure CLI with Bicep (az bicep), so a solution in that context would be nice.)
2 Answers
I'm for now resorting to deploying the requirements.psd1 file after the Bicep deployment. (Note: the Bicep deployment resets the file content on every deployment.)
Here's the Azure CLI command:
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 Late but I've actually found an solution for this:
resource function ' = { parent: azureFunctionApp name: 'BackupTable' properties: { ... files: { 'run.ps1' : loadTextContent('../FunctionApp/DailyBackup/run.ps1') '../requirements.psd1' : loadTextContent('../FunctionApp/requirements.psd1') } }
}Add the 'requirements.psd1' in the files of your function and it will work! For me at least.. i hope for others too.