SeaDude
SeaDude

Reputation: 4385

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...

...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?

Upvotes: 5

Views: 14153

Answers (6)

Ahmad Waleed
Ahmad Waleed

Reputation: 1

Deployment from vs code only works when you create function app from vs code first using + sign with Azure account extension enabled. If you want to deploy from vs code to an existing function app. Go to your function app settings > environment variables and add 'AzureWebJobsStorage' key with value of a storage account connection string from storage account access keys. Then deploy and it will work.

Upvotes: 0

vayana
vayana

Reputation: 28

When you create the function app + function in VScode with the Azure Resources and Azure account extension enabled, deploying works fine.

If you create the function App in the Azure portal first and then try to create and deploy the function with VScode, you will get the error "Malformed SCM_RUN_FROM_PACKAGE when uploading built content" when you try to deploy it.

I've tried the solutions above and some others as well, but none of them worked and the solution was simple: Create a resource (function app) with the Azure resources extension first by clicking the + and when that's done, in the local workspace below that create a function by clicking the little lightning icon.

Code your function and click deploy to function app and it will work fine.

Upvotes: 0

ravibhat
ravibhat

Reputation: 931

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

Upvotes: 2

JordanBean
JordanBean

Reputation: 2791

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

Upvotes: 4

skuhns
skuhns

Reputation: 11

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.

Upvotes: 0

Hury Shen
Hury Shen

Reputation: 15754

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~

Upvotes: 3

Related Questions