繁体   English   中英

Azure Function 应用程序 HTTP 触发函数在部署时不显示

[英]Azure Function App HTTP Trigger Functions don't show when deployed

我用的是Python 3.9(Python编程model v2),我根据官方的例子创建了一个HTTP Function。 当我使用 visual studio code 进行部署时,我收到这条 output 消息,但我不知道如何调用 function。在我的本地调试环境中一切正常。 当我部署时,应用程序创建成功,文件被复制并安装了所有要求,但这些功能没有显示在 visual studio 的资源选项卡或 web 门户中。

仅供参考 - 在部署 output 中,我将我的实际应用名称更改为“appname”。

8:21:09 PM appname: Starting deployment...
8:21:11 PM appname: Creating zip package...
8:21:11 PM appname: Zip package size: 4.7 kB
8:21:12 PM appname: Fetching changes.
8:21:13 PM appname: Cleaning up temp folders from previous zip deployments and extracting pushed zip file /tmp/zipdeploy/81dc1e42-91a5-41cb-aece-4630ea2b692c.zip (0.00 MB) to /tmp/zipdeploy/extracted
8:21:15 PM appname: Updating submodules.
8:21:16 PM appname: Preparing deployment for commit id '1c897f2e-2'.
8:21:16 PM appname: PreDeployment: context.CleanOutputPath False
8:21:16 PM appname: PreDeployment: context.OutputPath /home/site/wwwroot
8:21:16 PM appname: Repository path is /tmp/zipdeploy/extracted
8:21:16 PM appname: Running oryx build...
8:21:16 PM appname: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.9.7 -p packagedir=.python_packages/lib/site-packages
8:21:17 PM appname: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
8:21:17 PM appname: You can report issues at https://github.com/Microsoft/Oryx/issues
8:21:17 PM appname: Oryx Version: 0.2.20210120.1, Commit: 66c7820d7df527aaffabd2563a49ad57930999c9, ReleaseTagName: 20210120.1
8:21:17 PM appname: Build Operation ID: |uRPGYFCvdWE=.f9456c76_
8:21:17 PM appname: Repository Commit : 1c897f2e-229f-463a-9f2e-a3357f68a89b
8:21:17 PM appname: Detecting platforms...
8:21:18 PM appname: Detected following platforms:
8:21:18 PM appname:   python: 3.9.7
8:21:18 PM appname: Version '3.9.7' of platform 'python' is not installed. Generating script to install it...
8:21:18 PM appname: Source directory     : /tmp/zipdeploy/extracted
8:21:18 PM appname: Destination directory: /home/site/wwwroot
8:21:18 PM appname: Downloading and extracting 'python' version '3.9.7' to '/tmp/oryx/platforms/python/3.9.7'...
8:21:20 PM appname: Downloaded in 2 sec(s).
8:21:20 PM appname: Verifying checksum...
8:21:21 PM appname: Extracting contents...
8:21:24 PM appname: Done in 6 sec(s).
8:21:24 PM appname: Python Version: /tmp/oryx/platforms/python/3.9.7/bin/python3.9
8:21:24 PM appname: Running pip install...
8:21:25 PM appname: [04:21:25+0000] Collecting azure-functions
8:21:25 PM appname: [04:21:25+0000]   Downloading azure_functions-1.12.0-py3-none-any.whl (160 kB)
8:21:25 PM appname: [04:21:25+0000] Collecting discord
8:21:25 PM appname: [04:21:25+0000]   Downloading discord-2.1.0-py3-none-any.whl (1.1 kB)
8:21:25 PM appname: [04:21:25+0000] Collecting requests
8:21:25 PM appname: [04:21:25+0000]   Downloading requests-2.28.1-py3-none-any.whl (62 kB)
8:21:25 PM appname: [04:21:25+0000] Collecting datetime
8:21:25 PM appname: [04:21:25+0000]   Downloading DateTime-4.7-py2.py3-none-any.whl (52 kB)
8:21:25 PM appname: [04:21:25+0000] Collecting discord.py>=2.1.0
8:21:25 PM appname: [04:21:25+0000]   Downloading discord.py-2.1.0-py3-none-any.whl (1.1 MB)
8:21:26 PM appname: [04:21:26+0000] Collecting charset-normalizer<3,>=2
8:21:26 PM appname: [04:21:26+0000]   Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
8:21:26 PM appname: [04:21:26+0000] Collecting idna<4,>=2.5
8:21:26 PM appname: [04:21:26+0000]   Downloading idna-3.4-py3-none-any.whl (61 kB)
8:21:26 PM appname: [04:21:26+0000] Collecting certifi>=2017.4.17
8:21:26 PM appname: [04:21:26+0000]   Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)
8:21:26 PM appname: [04:21:26+0000] Collecting urllib3<1.27,>=1.21.1
8:21:26 PM appname: [04:21:26+0000]   Downloading urllib3-1.26.13-py2.py3-none-any.whl (140 kB)
8:21:26 PM appname: [04:21:26+0000] Collecting pytz
8:21:26 PM appname: [04:21:26+0000]   Downloading pytz-2022.6-py2.py3-none-any.whl (498 kB)
8:21:27 PM appname: [04:21:27+0000] Collecting zope.interface
8:21:27 PM appname: [04:21:27+0000]   Downloading zope.interface-5.5.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (257 kB)
8:21:28 PM appname: [04:21:28+0000] Collecting aiohttp<4,>=3.7.4
8:21:28 PM appname: [04:21:28+0000]   Downloading aiohttp-3.8.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB)
8:21:29 PM appname: [04:21:29+0000] Collecting setuptools
8:21:29 PM appname: [04:21:29+0000]   Downloading setuptools-65.6.3-py3-none-any.whl (1.2 MB)
8:21:29 PM appname: [04:21:29+0000] Collecting aiosignal>=1.1.2
8:21:29 PM appname: [04:21:29+0000]   Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
8:21:30 PM appname: [04:21:30+0000] Collecting multidict<7.0,>=4.5
8:21:30 PM appname: [04:21:30+0000]   Downloading multidict-6.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (114 kB)
8:21:31 PM appname: [04:21:31+0000] Collecting yarl<2.0,>=1.0
8:21:31 PM appname: [04:21:31+0000]   Downloading yarl-1.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (264 kB)
8:21:31 PM appname: [04:21:31+0000] Collecting frozenlist>=1.1.1
8:21:31 PM appname: [04:21:31+0000]   Downloading frozenlist-1.3.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (158 kB)
8:21:31 PM appname: [04:21:31+0000] Collecting attrs>=17.3.0
8:21:31 PM appname: [04:21:31+0000]   Downloading attrs-22.1.0-py2.py3-none-any.whl (58 kB)
8:21:31 PM appname: [04:21:31+0000] Collecting async-timeout<5.0,>=4.0.0a3
8:21:31 PM appname: [04:21:31+0000]   Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
8:21:31 PM appname: [04:21:31+0000] Installing collected packages: azure-functions, charset-normalizer, frozenlist, aiosignal, multidict, idna, yarl, attrs, async-timeout, aiohttp, discord.py, discord, certifi, urllib3, requests, pytz, setuptools, zope.interface, datetime
8:21:34 PM appname: [04:21:34+0000] Successfully installed aiohttp-3.8.3 aiosignal-1.3.1 async-timeout-4.0.2 attrs-22.1.0 azure-functions-1.12.0 certifi-2022.9.24 charset-normalizer-2.1.1 datetime-4.7 discord-2.1.0 discord.py-2.1.0 frozenlist-1.3.3 idna-3.4 multidict-6.0.3 pytz-2022.6 requests-2.28.1 setuptools-65.6.3 urllib3-1.26.13 yarl-1.8.2 zope.interface-5.5.2
8:21:34 PM appname: WARNING: You are using pip version 20.2.3; however, version 22.3.1 is available.
8:21:34 PM appname: You should consider upgrading via the '/tmp/oryx/platforms/python/3.9.7/bin/python3.9 -m pip install --upgrade pip' command.
8:21:34 PM appname: Done in 10 sec(s).
8:21:34 PM appname: Preparing output...
8:21:34 PM appname: Copying files to destination directory '/home/site/wwwroot'...
8:21:35 PM appname: Done in 1 sec(s).
8:21:35 PM appname: Removing existing manifest file
8:21:35 PM appname: Creating a manifest file...
8:21:35 PM appname: Manifest file created.
8:21:35 PM appname: Done in 17 sec(s).
8:21:36 PM appname: Running post deployment command(s)...
8:21:36 PM appname: Generating summary of Oryx build
8:21:36 PM appname: Deployment Log file does not exist in /tmp/oryx-build.log
8:21:36 PM appname: The logfile at /tmp/oryx-build.log is empty. Unable to fetch the summary of build
8:21:36 PM appname: Triggering recycle (preview mode disabled).
8:21:36 PM appname: Linux Consumption plan has a 1.5 GB memory limit on a remote build container.
8:21:36 PM appname: To check our service limit, please visit https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale#service-limits
8:21:36 PM appname: Writing the artifacts to a squashfs file
8:21:41 PM appname: Parallel mksquashfs: Using 1 processor
8:21:41 PM appname: Creating 4.0 filesystem on /home/site/artifacts/functionappartifact.squashfs, block size 131072.
8:21:43 PM appname: [=============================================================-] 2066/2066 100%
8:21:43 PM appname: Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
8:21:43 PM appname:     compressed data, compressed metadata, compressed fragments, compressed xattrs
8:21:43 PM appname:     duplicates are removed
8:21:43 PM appname: Filesystem size 7135.95 Kbytes (6.97 Mbytes)
8:21:43 PM appname:     28.88% of uncompressed filesystem size (24705.52 Kbytes)
8:21:43 PM appname: Inode table size 19443 bytes (18.99 Kbytes)
8:21:43 PM appname:     27.24% of uncompressed inode table size (71382 bytes)
8:21:43 PM appname: Directory table size 21266 bytes (20.77 Kbytes)
8:21:43 PM appname:     42.06% of uncompressed directory table size (50567 bytes)
8:21:43 PM appname: Number of duplicate files found 330
8:21:43 PM appname: Number of inodes 2221
8:21:43 PM appname: Number of files 2036
8:21:43 PM appname: Number of fragments 148
8:21:43 PM appname: Number of symbolic links  0
8:21:43 PM appname: Number of device nodes 0
8:21:43 PM appname: Number of fifo nodes 0
8:21:43 PM appname: Number of socket nodes 0
8:21:43 PM appname: Number of directories 185
8:21:43 PM appname: Number of ids (unique uids + gids) 1
8:21:43 PM appname: Number of uids 1
8:21:43 PM appname:     root (0)
8:21:43 PM appname: Number of gids 1
8:21:43 PM appname:     root (0)
8:21:43 PM appname: Creating placeholder blob for linux consumption function app...
8:21:43 PM appname: SCM_RUN_FROM_PACKAGE placeholder blob scm-latest-appname.zip located
8:21:43 PM appname: Uploading built content /home/site/artifacts/functionappartifact.squashfs for linux consumption function app...
8:21:43 PM appname: Resetting all workers for appname.azurewebsites.net
8:21:44 PM appname: Deployment successful. deployer = ms-azuretools-vscode deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.
8:21:56 PM appname: Syncing triggers...
8:21:58 PM appname: Querying triggers...
8:21:59 PM appname: No HTTP triggers found.

我将身份验证设置为匿名以启动...我不确定我需要配置什么。

这是我尝试开始工作的默认值 function:

    @app.function_name(name="HttpTrigger1")
    @app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
    def test_function(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
        )

这是我的 host.json 文件:

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "samplingSettings": {
            "isEnabled": true,
            "excludedTypes": "Request"
          }
        }
      },
      "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[3.15.0, 4.0.0)"
      }
    }

我创建了 Azure 函数 Python 编程 model v2 并且在本地运行时出现了一些错误,即:

在此处输入图像描述

然后我在本地启动了 Azure 存储模拟器,错误已修复。

在本地运行

在此处输入图像描述

部署到 Azure

在此处输入图像描述在此处输入图像描述

Note : After deploying to Azure, update the app settings which is newly added in local.settings.json for Python V2 model to the Azure by pressing F1 on VS Code > Add New Setting on Azure Functions > Add this key value pair - AzureWebJobsFeatureFlags : EnableWorkerIndexing

有关使用 Azure 和 Python V2 model 运行功能的更多信息,请参阅此MS 文档

Hari 的解决方案效果很好。 但是,这可能有点令人困惑。 Azure 函数的 VSCode 教程中描述该问题的精确解决方案。

简而言之,您想将以下设置添加到您的 Azure Function 应用程序设置中:

AzureWebJobsFeatureFlags: EnableWorkerIndexing

它与您可能还添加到本地环境中的条目相同。 Azure也需要设置。 最起码到现在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM