skip to Main Content

I am deploying Azure Python function App through CI-CD pipeline on azure subscription. But post deployment, I am getting issue within Azure Function portal

Your app is currently in read only mode because you are running from a package file. To make any changes update the content in your zip file and WEBSITE_RUN_FROM_PACKAGE app setting. When I deploy function app through VsCode I dont get the error. I have tried to change application settings to remove WEBSITE_RUN_FROM_PACKAGE issue, but it persists. Is there a shortcoming with Consumtion type app to deploy through CICD portal

                                                    parameters:
                              - name: environment
                                type: string
                                default: D
                                values:
                                  - D
                                  - Q
                                  - P
                            
                            trigger:
                            - none
                            variables:
                              azureSubscription: 'xxxx'
                              buildPlatform: 'Any CPU'
                              buildConfiguration: 'Release'
                              appName: 'xxxxxx'
                              
                            resources:
                              repositories:
                              - repository: self
                                type: git
                                ref: refs/heads/feature-cdqpipeline_upd
                            jobs:
                            - job: Job_1
                              displayName: Agent job 1
                              pool:
                                vmImage: ubuntu-latest
                              steps:
                              - checkout: self
                                fetchDepth: 1
                              - task: Bash@3
                                displayName: Build extensions
                                inputs:
                                  targetType: inline
                                  script: >-
                                    if [ -f extensions.csproj ]
                            
                                    then
                                        dotnet build extensions.csproj --output ./bin
                                    fi
                              - task: UsePythonVersion@0
                                displayName: Use Python 3.9
                                inputs:
                                  versionSpec: 3.9
                                  allowUnstable: true
                              - task: Bash@3
                                displayName: Install Application Dependencies
                                inputs:
                                  targetType: inline
                                  script: >-
                                    python3.9 -m venv worker_venv
                            
                                    source worker_venv/bin/activate
                            
                                    pip3.9 install setuptools
                            
                                    pip3.9 install -r requirements.txt
                              - task: ArchiveFiles@2
                                displayName: Archive files
                                inputs:
                                  rootFolderOrFile: AzFunct
                                  includeRootFolder: false
                                  
                              - task: PublishBuildArtifacts@1
                                displayName: 'Publish Artifact: drop'
                               
                              - task: AzureFunctionApp@1 # Add this at the end of your file
                                inputs:
                                  azureSubscription: '${{variables.azureSubscription}}'
                                  appType: functionAppLinux # default is functionApp
                                  appName: 'xxxxxxxx'
                                  
                                  package: $(System.ArtifactsDirectory)/**/*.zip
                                  deploymentMethod: 'zipDeploy'
                                #Uncomment the next lines to deploy to a deployment slot
                                #Note that deployment slots is not supported for Linux                                          #deployToSlotOrASE: true
                                #resourceGroupName: '<Resource Group Name>'
                                #slotName: '<Slot name>'    
                            ...
                            

2

Answers


  1. This is not an error:

    enter image description here

    this message just says you may update your function app through this step in your build pipeline:

     - task: AzureFunctionApp@1 # Add this at the end of your file
       inputs:
         azureSubscription: '${{variables.azureSubscription}}'
         appType: functionAppLinux # default is functionApp
         appName: 'xxxxxxxx'
         package: $(System.ArtifactsDirectory)/**/*.zip
         deploymentMethod: 'zipDeploy'
    
    Login or Signup to reply.
  2. I agree with @Shamrai Aleksander, This warning is the warning and not an error.

    For your error message that you shared in the comments:-

    Failure Exception: ModuleNotFoundError: No module named ‘requests

    Make sure the requests package is present in your requirements.txt before deploying the Function app. also, If its present and the deployment is causing an error, Remove it from requirements.txt and perform the CI/CD pipeline deployment again. I tried adding requests package in my requirements.txt and deployed the Http Trigger Function with the YAML script below it ran successfully.

    My requirements.txt:-

    azure-functions
    requests
    

    In addition to this, Try to use the below YAML script to deploy your Function, In this script all the dependencies from requirements.txt are installed properly:-

    trigger:
    - master
    
    variables:
      # Azure Resource Manager connection created during pipeline creation
      azureSubscription: 'subid'
    
      # Function app name
      functionAppName: 'siliconfunc32'
    
      # Agent VM image name
      vmImageName: 'ubuntu-latest'
    
      # Working Directory
      workingDirectory: '$(System.DefaultWorkingDirectory)'
    
    stages:
    - stage: Build
      displayName: Build stage
    
      jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)
    
        steps:
        - bash: |
            if [ -f extensions.csproj ]
            then
                dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
            fi
          workingDirectory: $(workingDirectory)
          displayName: 'Build extensions'
    
        - task: UsePythonVersion@0
          displayName: 'Use Python 3.10'
          inputs:
            versionSpec: 3.10 # Functions V2 supports Python 3.6 as of today
    
        - bash: |
            pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
          workingDirectory: $(workingDirectory)
          displayName: 'Install application dependencies'
    
        - task: ArchiveFiles@2
          displayName: 'Archive files'
          inputs:
            rootFolderOrFile: '$(workingDirectory)'
            includeRootFolder: false
            archiveType: zip
            archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
            replaceExistingArchive: true
    
        - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          artifact: drop
    
    - stage: Deploy
      displayName: Deploy stage
      dependsOn: Build
      condition: succeeded()
    
      jobs:
      - deployment: Deploy
        displayName: Deploy
        environment: 'development'
        pool:
          vmImage: $(vmImageName)
    
        strategy:
          runOnce:
            deploy:
    
              steps:
              - task: AzureFunctionApp@1
                displayName: 'Azure functions app deploy'
                inputs:
                  azureSubscription: '$(azureSubscription)'
                  appType: functionAppLinux
                  appName: $(functionAppName)
                  package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
    

    Output:-

    enter image description here

    My Function got deployed with the warning, But still the function with Code + Test and ran successfully, Refer below:-

    enter image description here

    enter image description here

    enter image description here

    If the error persists, Check your init.py code and validate if the requests module is imported correctly if you are using a custom code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search