AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题 / 79582673
Accepted
Manu Chadha
Manu Chadha
Asked: 2025-04-20 01:46:10 +0800 CST2025-04-20 01:46:10 +0800 CST 2025-04-20 01:46:10 +0800 CST

无法使用 git repo 代码在 VS Code 中本地测试和运行 Azure 函数项目

  • 772

该 repo包含 Azure 函数的代码。

我想在 VS Code 中打开 repo,在本地测试它,然后在 Azure 中发布代码。

我下载了 zip 文件并在 VS Code 中打开了解压后的文件夹。

VS Code 检测到该文件夹​​包含 Azure 函数代码,并通过提示语言(在我的情况下是 Python)和解释器进行了相应的优化调整。

我该如何测试代码?当我使用 F5 键开始调试时,出现了错误:

 *  Executing task: .venv\Scripts\python -m pip install -r requirements.txt 

Collecting azure-functions
  Using cached azure_functions-1.23.0-py3-none-any.whl (137 kB)
Collecting azure-ai-projects
  Using cached azure_ai_projects-1.0.0b9-py3-none-any.whl (199 kB)
Collecting azure-identity
  Using cached azure_identity-1.21.0-py3-none-any.whl (189 kB)
Collecting werkzeug~=3.0.6
  Using cached werkzeug-3.0.6-py3-none-any.whl (227 kB)
Collecting MarkupSafe>=2.1.1
  Using cached MarkupSafe-2.1.5-cp38-cp38-win_amd64.whl (17 kB)
Collecting isodate>=0.6.1
  Using cached isodate-0.7.2-py3-none-any.whl (22 kB)
Collecting azure-core>=1.30.0
  Using cached azure_core-1.33.0-py3-none-any.whl (207 kB)
Collecting typing-extensions>=4.12.2
  Using cached typing_extensions-4.13.2-py3-none-any.whl (45 kB)
Collecting six>=1.11.0
  Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)
Collecting requests>=2.21.0
  Using cached requests-2.32.3-py3-none-any.whl (64 kB)
Collecting charset-normalizer<4,>=2
  Using cached charset_normalizer-3.4.1-cp38-cp38-win_amd64.whl (102 kB)
Collecting urllib3<3,>=1.21.1
  Using cached urllib3-2.2.3-py3-none-any.whl (126 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.10-py3-none-any.whl (70 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2025.1.31-py3-none-any.whl (166 kB)
Collecting msal-extensions>=1.2.0
  Using cached msal_extensions-1.3.0-py3-none-any.whl (28 kB)
Collecting msal>=1.30.0
  Using cached msal-1.32.0-py3-none-any.whl (114 kB)
Collecting cryptography>=2.5
  Using cached cryptography-44.0.2-cp37-abi3-win_amd64.whl (3.2 MB)
Collecting cffi>=1.12
  Using cached cffi-1.17.1-cp38-cp38-win_amd64.whl (181 kB)
Collecting pycparser
  Using cached pycparser-2.22-py3-none-any.whl (117 kB)
Collecting PyJWT[crypto]<3,>=1.0.0
  Using cached PyJWT-2.9.0-py3-none-any.whl (22 kB)
Installing collected packages: pycparser, cffi, urllib3, PyJWT, idna, cryptography, charset-normalizer, certifi, requests, typing-extensions, six, msal, MarkupSafe, werkzeug, msal-extensions, isodate, azure-core, azure-identity, azure-functions, azure-ai-projects
Successfully installed MarkupSafe-2.1.5 PyJWT-2.9.0 azure-ai-projects-1.0.0b9 azure-core-1.33.0 azure-functions-1.23.0 azure-identity-1.21.0 certifi-2025.1.31 cffi-1.17.1 charset-normalizer-3.4.1 cryptography-44.0.2 idna-3.10 isodate-0.7.2 msal-1.32.0 msal-extensions-1.3.0 pycparser-2.22 requests-2.32.3 six-1.17.0 typing-extensions-4.13.2 urllib3-2.2.3 werkzeug-3.0.6
WARNING: You are using pip version 21.1.1; however, version 25.0.1 is available.
You should consider upgrading via the 'C:\Users\manuchadha\OneDrive - Microsoft\Manu_Personal\programs\2025learnresolution\azure-ai-foundry-agent-main (1)\azure-ai-foundry-agent-main\.venv\Scripts\python.exe -m pip install --upgrade pip' command.
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: .venv\Scripts\activate ; func host start 

Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]

Azure Functions Core Tools
Core Tools Version:       4.0.1 Commit hash: N/A +421f0144b42047aa289ce691dc6db4fc8b6143e6 (32-bit)
Function Runtime Version: 4.834.3.22875

Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--dotnet-isolated, --dotnet, --javascript, --typescript, --java, --python, --powershell, --custom]
[2025-04-19T17:43:47.687Z] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[2025-04-19T17:43:48.552Z] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[2025-04-19T17:43:49.293Z] The 'FUNCTIONS_WORKER_RUNTIME' setting is required. Please specify a valid value. See https://go.microsoft.com/fwlink/?linkid=2257963 for more information. The application will continue to run, but may throw an exception in a future release.
[2025-04-19T17:43:49.513Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
For detailed output, run func with --verbose flag.
[2025-04-19T17:43:54.272Z] Host lock lease acquired by instance ID '0000000000000000000000001CFB97BF'.

在此处输入图片描述

  • 1 1 个回答
  • 68 Views

1 个回答

  • Voted
  1. Best Answer
    2025-04-21T17:59:52+08:002025-04-21T17:59:52+08:00

    无法根据文件确定项目语言。请使用 [--dotnet-isolated、--dotnet、--javascript、--typescript、--java、--python、--powershell、--custom] 之一。“FUNCTIONS_WORKER_RUNTIME”设置是必需的。请指定有效值

    错误日志中的这些警告表明您缺少local.settings.json。

    local.settings.json在函数项目的根目录中添加具有以下配置的文件。

    {
      "IsEncrypted": false,
      "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "python",
        "AzureWebJobsStorage": "UseDevelopmentStorage=true"
      }
    }
    

    我已经克隆了相同的 GitHub 项目,并local.settings.json在下面添加了和launch.json。

    .vscode=>启动.json:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Attach to Python Functions",
                "type": "debugpy",
                "request": "attach",
                "connect": {
                    "host": "localhost",
                    "port": 9091
                },
                "preLaunchTask": "func: host start"
            }
        ]
    }
    

    .vscode=>任务.json:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "type": "func",
                "label": "func: host start",
                "command": "host start",
                "problemMatcher": "$func-python-watch",
                "isBackground": true,
                "dependsOn": "pip install (functions)"
            },
            {
                "label": "pip install (functions)",
                "type": "shell",
                "osx": {
                    "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
                },
                "windows": {
                    "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
                },
                "linux": {
                    "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
                },
                "problemMatcher": []
            }
        ]
    }
    

    .vscode=>设置.json:

    {
        "azureFunctions.deploySubpath": ".",
        "azureFunctions.scmDoBuildDuringDeployment": true,
        "azureFunctions.pythonVenv": ".venv",
        "azureFunctions.projectLanguage": "Python",
        "azureFunctions.projectRuntime": "~4",
        "debug.internalConsoleOptions": "neverOpen",
        "azureFunctions.projectLanguageModel": 2
    }
    

    能够在本地调试该功能:

     *  Executing task: env\Scripts\activate && func host start 
    
    Found Python version 3.11.9 (py).
    
    Azure Functions Core Tools
    Core Tools Version:       4.0.6821 Commit hash: N/A +c09a2033faa7ecf51b3773308283af0ca9a99f83 (64-bit)
    Function Runtime Version: 4.1036.1.23224
    
    [2025-04-21T09:46:27.078Z] 0.03s - Debugger warning: It seems that frozen modules are being used, which may
    [2025-04-21T09:46:27.085Z] 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
    [2025-04-21T09:46:27.087Z] 0.00s - to python to disable frozen modules.
    [2025-04-21T09:46:27.088Z] 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
    [2025-04-21T09:46:27.154Z] Worker process started and initialized.
    
    Functions:
    
            agent_httptrigger:  http://localhost:7071/api/agent_httptrigger
    
    For detailed output, run func with --verbose flag.
    [2025-04-21T09:46:32.250Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.
    [2025-04-21T09:47:15.070Z] Executing 'Functions.agent_httptrigger' (Reason='This function was programmatically called via the host APIs.', Id=1c7d4fa8-5ead-4090-b5bc-2d338f5582f2)
    [2025-04-21T09:47:15.140Z] Python HTTP trigger function processed a request.
    [2025-04-21T09:47:15.193Z] Executed 'Functions.agent_httptrigger' (Succeeded, Id=1c7d4fa8-5ead-4090-b5bc-2d338f5582f2, Duration=144ms)
    
    • 0

相关问题

  • 将复制活动的序列号添加到 Blob

  • Packer 动态源重复工件

  • 选择每组连续 1 的行

  • 图形 API 调用列表 subscribedSkus 状态权限不足,但已授予权限

  • 根据列值创建单独的 DF 的函数

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve