Is it possible to deploy just one function in an Azure function app when there are multiple functions?

Viewed 1992

I'm setting up a deployment pipeline for a new Azure function that I'm creating. As we already use TeamCity and Octopus deploy at work for deployments, I'm thinking of using the KUDU REST API to deploy the Azure function as detailed here where the Powershell commands are run from Octopus deploy.

As Azure functions reside in an Azure function app and an app can have multiple functions, is it possible to just deploy one function within the app at a time?

4 Answers

For anyone wanting to do this using a powershell script that calls the KUDU API and is executed by Octopus deploy you can follow the steps in my answer here (You can also refer to other answers on this question for some interesting approaches)

Here is the relevant portion for deploying only one function to a function app.

Get your publish profile username and password as described here

$creds = Invoke-AzureRmResourceAction -ResourceGroupName YourResourceGroup -ResourceType Microsoft.Web/sites/config -ResourceName YourWebApp/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force    
$username = $creds.Properties.PublishingUserName
$password = $creds.Properties.PublishingPassword

Invoke the Kudu REST API to push your function to the function app

$username = '<publish username>' #IMPORTANT: use single quotes as username may contain $
$password = "<publish password>"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$apiUrl = "https://<yourFunctionApp>.scm.azurewebsites.net/api/zip/site/wwwroot"
$filePath = "<yourFunctionName>.zip"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method PUT -InFile $filePath -ContentType "multipart/form-data"
Related