0

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>'    
                            ...
                            
8
  • I beleive this is just a warning 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 it's not actually affecting the function of your app right? Commented Jul 17, 2023 at 11:53
  • Azure Devops AzureFunctionApp@1 will deploy your function artifact as a a zip thus this warning states Your app is currently in read only mode because you are running from a package file occurs, You need to add WEBSITE_RUN_FROM_PACKAGE=1 Commented Jul 17, 2023 at 11:53
  • Its affecting the function of my app, I can't run the function as it starts throwing Internal Server Error on Azure portal @Nick.McDermaid Commented Jul 17, 2023 at 12:00
  • Add this setting > WEBSITE_RUN_FROM_PACKAGE=1 in your function app configuration . Also, Internal server error is due to the mis-configuration in Function code. did you check the logs ? While running it from Code + Test section in order to get insight into Internal server error? Commented Jul 17, 2023 at 12:02
  • I start to get below error when I run through Portal by CI/CD pipeline, however it works fine when deployed through VsCode portal Result: Failure Exception: ModuleNotFoundError: No module named 'requests' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", Commented Jul 17, 2023 at 12:23

2 Answers 2

0

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'
Sign up to request clarification or add additional context in comments.

1 Comment

I start to get below error when I run through Portal by CI/CD pipeline, however it works fine when deployed through VsCode portal Result: Failure Exception: ModuleNotFoundError: No module named 'requests' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py"
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.