我创建了一个示例 Blobtrigger Azure 函数,并希望在 VScode 中使用 Azurite 对其进行调试。但是,它总是在调试会话启动后抛出相同的错误。
我正在使用 Azurite 来模拟 Azure 中的 Blob 服务。
码头工人命令:
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
我在存储库中的代码如下:
local.settings.json,带有到 Azurite 的默认连接字符串
{"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
},
__init__.py
import logging
import azure.functions as func
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
和function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "cleansed-zone/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
在 VSCode 中点击运行调试后,总是抛出异常。
Azure.Core: An error occurred while sending the request.
由于某些环境限制,我无法在 Azurite Docker 上设置 HTTPS,也无法验证错误的根本原因。
Azurite 和 Function App 本地项目的任何工作设置指南将不胜感激。
编辑:将连接字符串替换为 Azure 上运行的云存储帐户,没有任何问题。将示例文件上传到 Azurite 时,存储资源管理器也可以正常工作。然而,docker 在调试时不断抛出多个 404 错误,并且未能创建一些函数应用程序必须的 blob/queues/tables
172.17.0.1 - - [19/Jan/2022:11:22:53 +0000] "HEAD /devstoreaccount1/azure-webjobs-blobtrigger-lex10242-1234567890?comp=metadata HTTP/1.1" 404
172.17.0.1 - - [19/Jan/2022:12:47:49 +0000] "PUT /devstoreaccount1/azure-webjobs-hosts/locks/lez10242-1234567890/WebJobs.Internal.Blobs.Listener?comp=lease HTTP/1.1" 404 -