Azure / Azure/azure-functions-core-tools

"Permission denied" when publishing python codebase to linux host from ubuntu build agent

Open
#1,899 9 comments 2 reactions 0 assignees View on GitHub
investigate
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

The Azure Function is a python worker based on the codebase [described in this Microsoft doc](https://docs.microsoft.com/en-us/azure/azure-functions/functions-machine-learning-tensorflow?tabs=bash).
Deployment target running on consumption Y1 SKU, functionapp,linux website kind, python 3.7.

The codebase is hosted in Azure DevOps git. The following Azure DevOps build pipeline is used (currently configured to run on `ubuntu-latest`):
``` yaml
trigger:
- master

variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: 'myAzureConnection'
# Function app name
functionAppName: 'myAzure-azfn'
# Agent VM image name. Change the following to 'windows-latest' to work
vmImageName: 'ubuntu-latest' # 'windows-latest'
# Working Directory
workingDirectory: '$(System.DefaultWorkingDirectory)/__app__'
# Python Version
pythonVersion: 3.7

stages:
- stage: Package
displayName: Package stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(workingDirectory)'
artifact: 'drop'
publishLocation: 'pipeline'

- stage: Deploy
displayName: Deploy stage
dependsOn: Package
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'development'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: FuncToolsInstaller@0
inputs:
version: 'latest'
- download: current
artifact: drop
- task: AzureCLI@2
displayName: 'Verify that we can read existing deployed functions'
inputs:
azureSubscription: $(azureSubscription)
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'func azure functionapp list-functions $(functionAppName)'
workingDirectory: '$(Pipeline.Workspace)/drop/'
- task: AzureCLI@2
displayName: 'Deploy new version of codebase'
inputs:
azureSubscription: $(azureSubscription)
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'func azure functionapp publish $(functionAppName) --python'
workingDirectory: '$(Pipeline.Workspace)/drop/'
```
This pipeline fails. The pipeline runs using Hosted Agent: Ubuntu16. From the logs of the installing latest func tools:
``` shell
Finding latest func tools version...
Downloading: https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest
Latest version is 3.0.2358
```

The error occurs in the last command `func azure functionapp publish $(functionAppName) --python` with the following error log:
``` shell
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/home/vsts/work/_temp/azureclitaskscript1584291143449.ps1'
Getting site publishing info...
Creating archive for current directory...
Performing remote build for functions project.
Permission denied
##[error]Script failed with error: Error: The process '/usr/bin/pwsh' failed with exit code 1
```

If I change the agent to Hosted Agent: windows-2019-vs2019 (using windows-latest), everything works as expected.

On the ubuntu worker, I tried upgrading azure CLI to latest but there was no difference.

Is it a possible regression of #1779 ?

Contributor guide

Open the contributing guide

Research direction

Start with the FuncToolsInstaller@0 setup and the AzureCLI@2 step running `func azure functionapp publish ... --python` from `$(Pipeline.Workspace)/drop/` on the Ubuntu agent. Compare the failing Ubuntu16 run with the working Windows run and determine why the publish command reports `Permission denied`; done means the documented pipeline publishes successfully on Ubuntu without changing the application code.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, linux, powershell, python
Domain
ci-cd, cloud, devops, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.