'Azure Function Deployment Failed: `Malformed SCM_RUN_FROM_PACKAGE when uploading built content.`

Trying to deploy a python-runtime (v3.6.9) Azure function using the VS Code Azure Functions extension.

I created the function just fine, then...

  1. Clicked Upload from the extension
  2. Create new function app in Azure (advanced)
  3. Entered a globally unique function name
  4. Selected Python 3.6 as runtime
  5. Selected Consumption hosting plan
  6. Selected an existing resource group (created just for this project)
  7. Selected an existing storage account (created just for this project)
  8. Selected Skip for now for App Insights
  9. Output window shows "creating new function app"

...but the process errors out with:

11:36:47 PM azblobtoawss3: Creating zip package...
11:36:47 PM azblobtoawss3: Starting deployment...
11:36:49 PM azblobtoawss3: Updating submodules.
11:36:49 PM azblobtoawss3: Preparing deployment for commit id '3a4998bc20'.
11:36:49 PM azblobtoawss3: Repository path is /tmp/zipdeploy/extracted
11:36:49 PM azblobtoawss3: Running oryx build...
11:36:49 PM azblobtoawss3: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.6 -p packagedir=.python_packages/lib/python3.6/site-packages
11:36:50 PM azblobtoawss3: Build orchestrated by Microsoft Oryx, https://github.com/Microsoft/Oryx
11:36:51 PM azblobtoawss3: You can report issues at https://github.com/Microsoft/Oryx/issues
11:36:51 PM azblobtoawss3: Oryx Version      : 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
11:36:51 PM azblobtoawss3: Build Operation ID: |MIqvQZRaiqA=.6dffab29_
11:36:51 PM azblobtoawss3: Repository Commit : 3a4998bc205144f9998de05338412208
11:36:51 PM azblobtoawss3: Warning: An outdated version of python was detected (3.6.9). Consider updating.\nVersions supported by Oryx: https://github.com/microsoft/Oryx
11:36:51 PM azblobtoawss3: Source directory     : /tmp/zipdeploy/extracted
11:36:51 PM azblobtoawss3: Destination directory: /home/site/wwwroot
11:36:51 PM azblobtoawss3: Python Version: /opt/python/3.6.9/bin/python3
11:36:51 PM azblobtoawss3: Running pip install...
11:36:51 PM azblobtoawss3: [06:36:51+0000] Collecting azure-functions
11:36:51 PM azblobtoawss3: [06:36:51+0000]   Using cached https://files.pythonhosted.org/packages/5b/6d/67a219c38be7e4eae7c001a9bf83ab059dcf497644ccc6c5f696ea4155fa/azure_functions-1.2.1-py3-none-any.whl
11:36:51 PM azblobtoawss3: [06:36:51+0000] Installing collected packages: azure-functions
11:36:51 PM azblobtoawss3: [06:36:51+0000] Successfully installed azure-functions-1.2.1
11:36:51 PM azblobtoawss3: WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
11:36:51 PM azblobtoawss3: You should consider upgrading via the 'pip install --upgrade pip' command.
11:36:51 PM azblobtoawss3: [06:36:51+0000] Cleaning up...
11:36:51 PM azblobtoawss3: Done in 1 sec(s).
11:36:51 PM azblobtoawss3: Done running pip install.
11:36:51 PM azblobtoawss3: Copying files to destination directory '/home/site/wwwroot'...
11:36:51 PM azblobtoawss3: Done in 0 sec(s).
11:36:51 PM azblobtoawss3: Removing existing manifest file
11:36:51 PM azblobtoawss3: Creating a manifest file...
11:36:51 PM azblobtoawss3: Manifest file created.
11:36:51 PM azblobtoawss3: Done in 1 sec(s).
11:36:53 PM azblobtoawss3: Running post deployment command(s)...
11:36:53 PM azblobtoawss3: Triggering recycle (preview mode disabled).
11:36:53 PM azblobtoawss3: Creating placeholder blob for linux consumption function app...
11:36:53 PM azblobtoawss3: **Malformed SCM_RUN_FROM_PACKAGE when uploading built content**.
11:37:04 PM azblobtoawss3: **Deployment failed**.

I also tried...

  • Right click on Function project
  • Deploy to Azure

...same outcome.

EDIT1: Also tried performing a remote build from the cli per @hury-shen's recommendations:

(.venv) user@system:~/Documents/azureBlobToS3$ func azure functionapp publish azureblobtoawss3 --build remote

Getting site publishing info...
Remote build is a new feature added to function apps.
Your function app azureblobtoawss3 does not support remote build as it was created before August 1st, 2019.
Please use '--build local' or '--build-native-deps'.
For more information, please visit https://aka.ms/remotebuild

I then proceeded to update the application using az functionapp update -g <RESOURCE_GROUP_NAME> -n <APP_NAME>. Same result.

I also added the Application Settings listed here to enable remote build on Linux. Same result.

I then tried running func azure functionapp publish <APP_NAME> --build local instead and get the error:

There was an error restoring dependencies.   Could not find a version that satisfies the requirement pkg-resources (from -r /home/user/Documents/azureBlobToS3/requirements.txt (line 19)) (from versions: )
No matching distribution found for pkg-resources (from -r /home/user/Documents/azureBlobToS3/requirements.txt (line 19))
ERROR: ['/home/user/Documents/azureBlobToS3/.venv/bin/python3', '-m', 'pip', 'download', '-r', '/home/user/Documents/azureBlobToS3/requirements.txt', '--dest', '/tmp/azureworkerjv2xkb_k'] failed with exit code 1

Yet pip shows the pkg-resources dependency being met!

(.venv) user@system:~/Documents/azureBlobToS3$ pip install pkg-resources

Requirement already satisfied: pkg-resources in ./.venv/lib/python3.6/site-packages

EDIT2: Removed pkg-resources from requirements.txt just to test

I'm stuck in a loop here. Unable to build remote, unable to build locally.

There was an error restoring dependencies. ERROR: cannot install cryptography-2.9.2 dependency: binary dependencies without wheels are not supported when building locally. Use the "--build remote" option to build dependencies on the Azure Functions build server, or "--build-native-deps" option to automatically build and configure the dependencies using a Docker container. More information at https://aka.ms/func-python-publish

Has anyone else see this error? How do I troubleshoot?



Solution 1:[1]

Deploy the python function by extension often occurs some problem, so I suggest you to use command to deploy the python function from local to azure. Please refer to the steps below:

1. Go to azure portal and create a function app(python).

2. Click "Terminal" button in your VS code to open the "TERMINAL" window and run the command below to generate the "requirements.txt" which includes all of the modules installed in your function.

pip freeze > requirements.txt

enter image description here

3. Deploy the function from local to azure by running the command below:

func azure functionapp publish <functionAppName> --build remote

enter image description here The <functionAppName> is the name of the function app which you created just now. After running this command, the function code will be deployed from local to azure and azure will install the modules by the content of the "requirements.txt" which we generated above.

Hope it helps~

Solution 2:[2]

I encountered these exact same errors including the edits and followed all recommended steps to resolve. My issue was in VSCode, I was building with with Python 3.7 even though 3.6 was installed. Uninstalling Python 3.7 and forcing 3.6 build resolved my issue.

Solution 3:[3]

In my case, it was because the Function App couldn't access the Storage Account. I modified the connection strings stored in the AzureWebJobsStorage & AZURE_STORAGE_CONNECTION_STRING appSettings.

To determine this, I built the function app locally and tried to deploy.

func azure functionapp publish func-durableFuncAci-ussc-demo --build local --build-native-deps

I got the following error, which told me there was an error in the configuration of the Function App.

Error creating a Blob container reference. Please make sure your connection string in "AzureWebJobsStorage" is valid

Solution 4:[4]

Creating and Deploying FunctionApp from VS Code works, VS code will have issues with deploying functions which are created from portal.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hury Shen
Solution 2 skuhns
Solution 3 JordanBean
Solution 4 ravibhat