Home > Net >  Azure YAML Pipeline: deploy to Function App without overwriting existing function
Azure YAML Pipeline: deploy to Function App without overwriting existing function

Time:11-30

I have one Function App, already created in Azure, to which I need to deploy two separate Azure Functions hosted in different repos:

  • (A) HttpTrigger
  • (B) QueueTrigger

I would like to do this using a YAML pipeline.

Each Azure Function has its separate YAML pipeline, but every time I run pipeline B, the deployment works ok but function A is overwritten by function B.

Is there a way to keep both?

Below is the deployment to DEV, which appears in both pipelines. I thought there was a flag to say "don't delete anything you find deployed", but there isn't.

What am I missing?

#Deploy to DEV
- stage: DEV
  displayName: Deploy to DEV
  dependsOn: Build
  variables:
  - group: my-dev-variables 
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
  jobs:
  - job: Deploy
    steps:

      #Download artifact to make it available to this stage
      - task: DownloadPipelineArtifact@2
        inputs:
          source: 'current'
          path: '$(Pipeline.Workspace)' 

      #Deploy
      - task: AzureFunctionApp@1
        displayName: Deploy Linux function app
        inputs:
          azureSubscription: $(azureRmConnection.Id)
          appType: 'functionAppLinux'
          appName: $(functionAppName)
          package: '$(Pipeline.Workspace)/**/*.zip'
          deploymentMethod: auto

CodePudding user response:

I’m not sure how projects are structured in Python, but I think what you are trying to do is not possible by having separate repos that you deploy from. However, you should be able to achieve what you want by adding the both functions to the same project and then deploy them from the same repo.

Depending on the app service plan you are running (and your needs), you could also consider having two separate function apps and run them both on the same app service plan.

  • Related