A Jenkins plugin to deploy an Azure Function.
You can install/update this plugin in Jenkins update center (Manage Jenkins -> Manage Plugins, search Azure Function Plugin).
You can also manually install the plugin if you want to try the latest feature before it's officially released. To manually install the plugin:
- Clone the repo and build:
mvn package
- Open your Jenkins dashboard, go to Manage Jenkins -> Manage Plugins.
- Go to Advanced tab, under Upload Plugin section, click Choose File.
- Select
azure-function.hpi
intarget
folder of your repo, click Upload. - Restart your Jenkins instance after install is completed.
To use this plugin to deploy to Azure Function, first you need to have an Azure Service Principal in your Jenkins instance.
- Create an Azure Service Principal through Azure CLI or Azure portal.
- Open Jenkins dashboard, go to Credentials, add a new Microsoft Azure Service Principal with the credential information you just created.
Then create a Function in Azure portal or through Azure CLI.
You can deploy your project to Azure Function by uploading your build artifacts using Git or FTP.
- Create a new freestyle project in Jenkins, add necessary build steps to build your code.
- Add a post-build action 'Publish an Azure Function'.
- Select your Azure credential in Azure Profile Configuration section.
- In App Configuration section, choose the resource group and function app in your subscription, and also fill in the files you want to deploy (for example, a jar package if you're using Java).
- There are two optional parameters Source Directory and Target Directory that allows you to specify source and target folders when uploading files.
- Save the project and build it, your function app will be deployed to Azure when build is completed.
You can also use this plugin in pipeline (Jenkinsfile). Here are some samples to use the plugin in pipeline script:
To deploy a NodeJS function app:
azureFunctionAppPublish azureCredentialsId: '<credential_id>',
resourceGroup: '<resource_group_name>', appName: '<app_name>',
filePath: '**/*.js,**/*.json'
For advanced options, you can use Jenkins Pipeline Syntax tool to generate a sample script.
Azure Function Plugin collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more.
You can turn off usage data collection in Manage Jenkins -> Configure System -> Azure -> Help make Azure Jenkins plugins better by sending anonymous usage statistics to Azure Application Insights.