gpt4 book ai didi

python - 错误 : Could not load file or assembly 'Microsoft. Azure.WebJobs.Script.Abstractions

转载 作者:行者123 更新时间:2023-12-02 07:42:39 33 4
gpt4 key购买 nike

我正在尝试按照 Microsoft 指南在本地运行 Azure 函数: https://learn.microsoft.com/nl-nl/azure/azure-functions/create-first-function-cli-python?tabs=azure-cli%2Cbash%2Cbrowser#create-venv

无论我尝试什么,当我尝试使用“func start”启动该函数时,我都会一遍又一遍地遇到相同的错误:

 Found Python version 3.8.0 (py).

Azure Functions Core Tools
Core Tools Version: 4.0.4544 Commit hash: N/A (64-bit)
Function Runtime Version: 4.3.2.18186

Could not load file or assembly 'Microsoft.Azure.WebJobs.Script.Abstractions,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c5b9424214e8f8c'. The system cannot find
the file specified.

我的文件设置如下

主机.json

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

本地.setting.json

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

需求.txt

azure-functions

函数.json

{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "Anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}

初始化.py

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
)

如有任何帮助,我们将不胜感激!

最佳答案

我也遇到过这个。不确定是什么原因造成的。

但是对我来说解决这个问题的是下载、卸载并重新安装 Azure Functions Core Tools(使用“修复”只是返回一个通用的“由于错误而失败”,我不得不杀死 PowerToys)

<小时/>

不确定是否有必要,但我也清除了我的 nuget 缓存

dotnet nuget locals all -c
dotnet restore # in your sln folder

并重新安装了我的 vscode Azure 插件

关于python - 错误 : Could not load file or assembly 'Microsoft. Azure.WebJobs.Script.Abstractions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72454228/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com