I am moving from a python function app to a powershell function app. I have a build and release pipeline for this. The following code below is the build for a python function app. how would i do this for a powershell function app.
#------------------------------------------------------------------------------------
#parametrise service connection detials
#------------------------------------------------------------------------------------
variables:
azureServiceConnection: 'my-service-connection'
# -------------------------------------------------------------------------------------
# What VM OS will run this pipeline
# -------------------------------------------------------------------------------------
pool:
vmImage: 'ubuntu-latest'
# -------------------------------------------------------------------------------------
# A Build pipeline is definined in a hierarchy of Stages > Jobs > Steps,
# This example has a single stage and job and therefore those don't need to be listed
# -------------------------------------------------------------------------------------
steps:
- bash: |
if [ -f extensions.csproj ]
then
dotnet build extensions.csproj --output ./bin
fi
displayName: 'Build extensions'
- task: UsePythonVersion@0
displayName: Use Python 3.8
inputs:
versionSpec: '3.8'
addToPath: true
# -------------------------------------------------------------------------------------
#Run Pip installer for any prerequisite libraries
# -------------------------------------------------------------------------------------
- bash: 'pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt'
displayName: 'Install Application Dependencies'
# -------------------------------------------------------------------------------------
#Archieve all files
# -------------------------------------------------------------------------------------
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
# -------------------------------------------------------------------------------------
#drop files copied to artifact staging directory
# -------------------------------------------------------------------------------------
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
2
Answers
For a powershell function app, you can simply deploy using the
AzureFunctionApp@2
task. See docs here.Here is my example pipeline that I use to deploy to a powershell function app, there is no release pipeline necessary.
For me, the
package
input paths directly to my function app folder that looks like this:If you would prefer to have this as a release pipeline, you should also be able to find that same task in the release pipeline, and then you can include your repostiroy as an artifact, and set up a trigger to deploy when code is merged to your master/main branch.
Based on your requirement, you need to deploy the files to the PowerShell Azure Function.
When deploying the Powershell function app, we can directly deploy the Powershell file without compiling the .ps1 file.
Since you need to include the build and release pipelines, you can directly package the relevant powershell files in the build pipeline and then use them for release pipeline deployment.
You can use the following Yaml sample in Build Pipeline to package your powershell project.
Release Pipeline: The configuration is same as the steps to deploy python function app.
In order to create a Pipeline workflow more conveniently, you can also directly use the Yaml Template in Pipelines -> New Pipelines -> Azure Repos Git(YAML) -> select repo -> find template: PowerShell Function App to Windows on Azure at configure step.
It can automatically help you create a complete build and deployment process.
For more detailed info, you can refer to this blog: Integrate your PowerShell Azure Function with Azure DevOps