how to set pipeline for azure functions http trigger for phthon

Harshad Sadanand Hindlekar 0 Reputation points
2024-03-04T04:36:26.1866667+00:00

below yaml pipiline duild and deploy with no errors but their is no signs of deployement in respected azure functions portal


trigger:
- main
- staging

stages:
- stage: Build
  displayName: Build stage

  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - bash: |
        python -m venv venv
        source venv/bin/activate
        pip install -r requirements.txt
        zip -r $(Build.ArtifactStagingDirectory)/release.zip ./* -x venv/\*
      workingDirectory: $(System.DefaultWorkingDirectory)
      displayName: 'Build and package Python application'

    - publish: $(Build.ArtifactStagingDirectory)/release.zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()

  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: '$(Environment)'
    pool:
      vmImage: $(vmImageName)

      steps:
      - download: current
        artifact: drop
        displayName: 'Download artifact'

      - script: |
          # Set appName based on trigger (main or staging)
          if [[ $(Build.SourceBranchName) == "staging" ]]; then
            appName="staging-northstar"
          else
            appName="NorthStar"
          fi

          echo "##vso[task.setvariable variable=functionAppName]$appName"
        displayName: 'Set appName based on trigger'

      - task: AzureFunctionApp@1
        displayName: 'Azure functions app deploy'
        inputs:
          azureSubscription: '$(AZURESUBSCRIPTION)'
          appType: 'functionAppLinux'
          appName: '$(functionAppName)'  # Use the dynamically set variable
          package: '$(Pipeline.Workspace)/drop/release.zip'
          runtimeStack: 'PYTHON|3.10'
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,902 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 27,851 Reputation points Microsoft Employee
    2024-03-05T00:44:30.74+00:00

    Hey @Harshad Sadanand Hindlekar

    Since you're deploying a zip deploy, make sure that SCM_DO_BUILD_DURING_DEPLOYMENT=true is set as application setting. Not doing this, the platform more than likely is mounting your zip file as the source which expects all dependencies to configured and the program to be able to run. Also check drop folder to ensure that release.zip does contains the files as you expect. Deployment Center in the Azure Function will also show the incoming file and how gets unzipped or mounted, so you can also check that to make sure the zip has/shows contents. Having said that, you can refer to Continuously update function app code using Azure Pipelines | Microsoft Learn to compare and contrast against your pipeline.


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.