How to remove all the functions and then deploy the function app from AZURE DEVOPS PIPELINE?

Viewed 41

I am working on the deployment of the function apps through Azure devops pipeline . I am using like following in order to deploy the pipeline :

  - task: AzureCLI@2
    displayName: 'Deploy function'
    inputs:
      azureSubscription: ${{parameters.serviceConnection}}
      scriptType: 'ps'
      scriptLocation: 'inlineScript'
      inlineScript: |
        az webapp deployment source config-zip -g $(resourceGroup) -n $(functionAppName) --src $(Pipeline.Workspace)\adx-integration-build\drop\azure-function\Integration.zip --subscription $(Subscription) --verbose

This is working fine but when I am deploying the code in the azure , then old functions (functions deployed earlier ) are not getting removed . I would like to know if there is any way to remove all unnecessary functions from function app during deployment using Azure pipelines.

Note : We have an option to remove all the functions and then deploy the functions from visual studio but I want to do it from Azure pipeline .

1 Answers

Please try the task bellow:

    # Start Deploy
    - task: AzureFunctionApp@1
      displayName: "Deploy Functions"
      inputs:
        azureSubscription: "${{ parameters.Subscription }}"
        appName: "${{ parameters.functionName}}"
        package: "$(Agent.BuildDirectory)/${{ parameters.ArtifactName}}/Functions.zip"

There are 3 deployment types:

  • Kudu REST APIs
  • Zip Deploy
  • Run From Package

The package deployment method makes the directory contents read-only and only the package contents are executed.

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-function-app?view=azure-devops#run-from-package

When you run from a package, the wwwroot folder becomes read-only and you'll receive an error when writing files to this directory. Files are also read-only in the Azure portal.

You can't use local cache when running from a deployment package.

Related