簡體   English   中英

Azure Function 部署失敗:`上傳構建內容時 SCM_RUN_FROM_PACKAGE 格式錯誤。`

[英]Azure Function Deployment Failed: `Malformed SCM_RUN_FROM_PACKAGE when uploading built content.`

嘗試使用VS 代碼 Azure 函數擴展部署 python 運行時 ( v3.6.9 ) Azure function。

我創建了 function 就好了,然后......

  1. 從擴展點擊Upload
  2. Create new function app in Azure (advanced)
  3. 輸入了一個全球唯一的 function 名稱
  4. 選擇Python 3.6作為運行時
  5. 選定Consumption托管計划
  6. 選擇了現有資源組(僅為該項目創建)
  7. 選擇了一個現有的存儲帳戶(僅為該項目創建)
  8. 為 App Insights 選擇Skip for now
  9. Output window 顯示“正在創建新的 function 應用程序”

...但過程錯誤:

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

我也試過...

  • 右鍵單擊 Function 項目
  • Deploy to Azure

……同樣的結果。

EDIT1:還嘗試按照@hury-shen 的建議從 cli 執行遠程構建

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

然后我繼續使用az functionapp update -g <RESOURCE_GROUP_NAME> -n <APP_NAME>更新應用程序。 結果相同。

我還添加了此處列出的應用程序設置,以在 Linux 上啟用遠程構建。 結果相同。

然后我嘗試運行func azure functionapp publish <APP_NAME> --build local並得到錯誤:

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

然而 pip 顯示滿足pkg-resources依賴關系!

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

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

EDIT2:從requirements.txt中刪除pkg-resources只是為了測試

我在這里陷入了一個循環。 無法遠程構建,無法在本地構建。

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

有沒有其他人看到這個錯誤? 如何進行故障排除?

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. 請參考以下步驟:

1. Go 到 azure 門戶並創建 function 應用程序(python)。

2.單擊 VS 代碼中的“終端”按鈕打開“終端”window 並運行以下命令生成“requirements.txt”,其中包括安裝在 function 中的所有模塊。

pip freeze > requirements.txt

在此處輸入圖像描述

3.運行以下命令,將 function 從本地部署到 azure:

func azure functionapp publish <functionAppName> --build remote

在此處輸入圖像描述 <functionAppName>是您剛剛創建的 function 應用程序的名稱。 運行此命令后,function 代碼將從本地部署到 azure 和 azure 將安裝我們生成的“requirements.txt”內容的模塊

希望有幫助~

我遇到了這些完全相同的錯誤,包括編輯,並按照所有推薦的步驟來解決。 我的問題出在 VSCode 中,我使用 Python 3.7 構建,即使安裝了 3.6。 卸載 Python 3.7 並強制 3.6 構建解決了我的問題。

就我而言,這是因為 Function 應用程序無法訪問存儲帳戶。 我修改了存儲在AzureWebJobsStorageAZURE_STORAGE_CONNECTION_STRING appSettings 中的連接字符串。

為了確定這一點,我在本地構建了 function 應用程序並嘗試部署。

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

我收到以下錯誤,告訴我 Function 應用程序的配置有錯誤。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM