英文:
Unble to deploy function from Visual Studio Code to Azure Function app
问题
我无法将VS Code中的函数部署到Azure函数应用程序。我收到以下错误:
10:08:30 AM nilee1989: 部署失败。
这是我将从本地计算机部署到Azure函数应用程序(云端)的init.py
文件:
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP触发器函数处理了一个请求。')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"你好,{name}。这个HTTP触发的函数已成功执行。")
else:
return func.HttpResponse(
"这个HTTP触发的函数已成功执行。在查询字符串或请求正文中传递一个名称以获得个性化的响应。",
status_code=200
)
我已经从Azure函数云门户中删除了函数应用,并重新创建,甚至在尝试从其他系统部署相同的代码时仍然遇到相同的错误。
请告诉我如何解决这个问题。
英文:
I am not able to deploy function from VS Code to an Azure Function app. I'm getting the following error:
``
10:07:51 AM nilee1989: Starting deployment...
10:07:51 AM nilee1989: Creating zip package...
10:07:51 AM nilee1989: Zip package size: 2.46 kB
10:07:59 AM nilee1989: Updating submodules.
10:08:00 AM nilee1989: Preparing deployment for commit id '03ee2bab-1'.
10:08:00 AM nilee1989: PreDeployment: context.CleanOutputPath False
10:08:00 AM nilee1989: PreDeployment: context.OutputPath /home/site/wwwroot
10:08:00 AM nilee1989: Repository path is /tmp/zipdeploy/extracted
10:08:00 AM nilee1989: Running oryx build...
10:08:00 AM nilee1989: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.9.7 -p packagedir=.python_packages/lib/site-packages
10:08:02 AM nilee1989: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
10:08:02 AM nilee1989: You can report issues at https://github.com/Microsoft/Oryx/issues
10:08:02 AM nilee1989: Oryx Version: 0.2.20210120.1, Commit: 66c7820d7df527aaffabd2563a49ad57930999c9, ReleaseTagName: 20210120.1
10:08:02 AM nilee1989: Build Operation ID: |PDmxDnGBBJ8=.b82ab75a_
10:08:02 AM nilee1989: Repository Commit : 03ee2bab-16c8-41f0-ab2c-4b613e4a196b
10:08:02 AM nilee1989: Detecting platforms...
10:08:02 AM nilee1989: Detected following platforms:
10:08:02 AM nilee1989: python: 3.9.7
10:08:02 AM nilee1989: Version '3.9.7' of platform 'python' is not installed. Generating script to install it...
10:08:02 AM nilee1989: Source directory : /tmp/zipdeploy/extracted
10:08:02 AM nilee1989: Destination directory: /home/site/wwwroot
10:08:02 AM nilee1989: Downloading and extracting 'python' version '3.9.7' to '/tmp/oryx/platforms/python/3.9.7'...
10:08:04 AM nilee1989: Downloaded in 2 sec(s).
10:08:04 AM nilee1989: Verifying checksum...
10:08:04 AM nilee1989: Extracting contents...
10:08:08 AM nilee1989: Done in 6 sec(s).
10:08:08 AM nilee1989: Python Version: /tmp/oryx/platforms/python/3.9.7/bin/python3.9
10:08:08 AM nilee1989: Running pip install...
10:08:08 AM nilee1989: [04:38:08+0000] Collecting azure-functions
10:08:08 AM nilee1989: [04:38:08+0000] Downloading azure_functions-1.15.0-py3-none-any.whl (165 kB)
10:08:09 AM nilee1989: [04:38:09+0000] Installing collected packages: azure-functions
10:08:09 AM nilee1989: [04:38:09+0000] Successfully installed azure-functions-1.15.0
10:08:09 AM nilee1989: WARNING: You are using pip version 20.2.3; however, version 23.1.2 is available.
10:08:09 AM nilee1989: You should consider upgrading via the '/tmp/oryx/platforms/python/3.9.7/bin/python3.9 -m pip install --upgrade pip' command.
10:08:09 AM nilee1989: Done in 1 sec(s).
10:08:09 AM nilee1989: Preparing output...
10:08:09 AM nilee1989: Copying files to destination directory '/home/site/wwwroot'...
10:08:09 AM nilee1989: Done in 0 sec(s).
10:08:09 AM nilee1989: Removing existing manifest file
10:08:09 AM nilee1989: Creating a manifest file...
10:08:09 AM nilee1989: Manifest file created.
10:08:09 AM nilee1989: Done in 7 sec(s).
10:08:10 AM nilee1989: Running post deployment command(s)...
10:08:10 AM nilee1989: Generating summary of Oryx build
10:08:10 AM nilee1989: Deployment Log file does not exist in /tmp/oryx-build.log
10:08:10 AM nilee1989: The logfile at /tmp/oryx-build.log is empty. Unable to fetch the summary of build
10:08:11 AM nilee1989: Triggering recycle (preview mode disabled).
10:08:11 AM nilee1989: Linux Consumption plan has a 1.5 GB memory limit on a remote build container.
10:08:11 AM nilee1989: To check our service limit, please visit https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale#service-limits
10:08:11 AM nilee1989: Writing the artifacts to a squashfs file
10:08:11 AM nilee1989: Parallel mksquashfs: Using 1 processor
10:08:11 AM nilee1989: Creating 4.0 filesystem on /home/site/artifacts/functionappartifact.squashfs, block size 131072.
10:08:11 AM nilee1989: [===============================================================|] 141/141 100%
10:08:11 AM nilee1989: Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
10:08:11 AM nilee1989: compressed data, compressed metadata, compressed fragments, compressed xattrs
10:08:11 AM nilee1989: duplicates are removed
10:08:11 AM nilee1989: Filesystem size 323.26 Kbytes (0.32 Mbytes)
10:08:11 AM nilee1989: 26.60% of uncompressed filesystem size (1215.22 Kbytes)
10:08:11 AM nilee1989: Inode table size 1492 bytes (1.46 Kbytes)
10:08:11 AM nilee1989: 28.77% of uncompressed inode table size (5186 bytes)
10:08:11 AM nilee1989: Directory table size 1551 bytes (1.51 Kbytes)
10:08:11 AM nilee1989: 37.21% of uncompressed directory table size (4168 bytes)
10:08:11 AM nilee1989: Number of duplicate files found 3
10:08:11 AM nilee1989: Number of inodes 162
10:08:11 AM nilee1989: Number of files 144
10:08:11 AM nilee1989: Number of fragments 11
10:08:11 AM nilee1989: Number of symbolic links 0
10:08:11 AM nilee1989: Number of device nodes 0
10:08:11 AM nilee1989: Number of fifo nodes 0
10:08:11 AM nilee1989: Number of socket nodes 0
10:08:11 AM nilee1989: Number of directories 18
10:08:11 AM nilee1989: Number of ids (unique uids + gids) 1
10:08:11 AM nilee1989: Number of uids 1
10:08:11 AM nilee1989: root (0)
10:08:11 AM nilee1989: Number of gids 1
10:08:11 AM nilee1989: root (0)
10:08:11 AM nilee1989: Creating placeholder blob for linux consumption function app...
10:08:11 AM nilee1989: Malformed SCM_RUN_FROM_PACKAGE when uploading built content.
10:08:11 AM nilee1989: Generating summary of Oryx build
10:08:11 AM nilee1989: Deployment Log file does not exist in /tmp/oryx-build.log
10:08:11 AM nilee1989: The logfile at /tmp/oryx-build.log is empty. Unable to fetch the summary of build
10:08:11 AM nilee1989: Deployment Failed. deployer = ms-azuretools-vscode deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.
10:08:30 AM nilee1989: Deployment failed.
This is the init.py
file which I am going to deploy from local computer to Azure Function app (cloud):
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
I had deleted function app from azure function cloud portal and created again, even when I tried to deploy this same above code from other system, but still getting the same error.
Please sugme how I can solve this problem.
答案1
得分: 0
今天我遇到了完全相同的问题。
对我有帮助的是将 AzureWebJobsStorage
添加到我的函数应用的配置中。
作为值输入来自您存储帐户的存储密钥连接字符串。路径:
存储帐户 -> 访问密钥 -> 密钥1 -> 连接字符串
我对Azure非常不熟悉,但希望这对您有帮助。
英文:
I was having this exact problem today.
What helped me was adding AzureWebJobsStorage
into Configuration of my Function App.
Enter as value the storage key's connection string from your Storage account. The path:
Storage account -> Access keys -> key 1 -> Connection string
I'm very new to Azure but I hope it was helpful.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论