Updating Azure function Code Automatically

Jon Mart 136 Reputation points
2020-09-24T19:25:34.857+00:00

What's the best way to upload updated code to a Azure Function app? I basically want to cron uploading new, updated code on a nightly basis. I imagine there's some CLI method I'm simply unaware of? I can't seem to find the answer to this.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} votes

Accepted answer
  1. sadomovalex 3,636 Reputation points
    2020-09-30T14:53:16.527+00:00

    once you have zip package with published Azure functions which can be automated quite easy as well, you may use zipdeploy Kudu API in order to upload it to your Azure function app:

        $kuduApiAuthorisationToken = Execute-WithRetry -SleepTime 10 { Get-Kudu-Api-Authorisation-Header-Value $RG $webAppName }
    
        $kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/zipdeploy"
    
        Execute-WithRetry -SleepTime 10 {
            Invoke-RestMethod -Uri $kuduApiUrl `
                -Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} `
                -Method POST `
                -InFile $localPath `
                -ContentType "multipart/form-data" | Out-Null
    

    More information can be found e.g. here: Interacting with Azure Web Apps Virtual File System using PowerShell and the Kudu API.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Pramod Valavala 20,656 Reputation points Microsoft Employee Moderator
    2020-09-25T04:59:41.427+00:00

    The recommended way would be to maintain your function code using git (or any version control) and setup continuous deployment or better yet, leverage Azure Pipelines or GitHub Actions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.