gpt4 book ai didi

python - 我尝试使用 python 函数写入 azure blob 存储时遇到 Value 'func.Out' is unsubscriptable

转载 作者:行者123 更新时间:2023-12-02 23:17:29 25 4
gpt4 key购买 nike

我想使用 Python 中的 Azure Functions 写入 Azure Blob 存储。

我正在使用 Azure Functions 的输出 Blob 存储绑定(bind)。

我的函数.json:

{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"name": "inputblob",
"type": "blob",
"path": "{containerName}/{blobName}.json",
"connection": "MyStorageConnectionAppSetting",
"direction": "in"
},
{
"name": "outputblob",
"type": "blob",
"path": "{containerName}/{blobName}.json",
"connection": "MyStorageConnectionAppSetting",
"direction": "out"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}

我的 Python 代码如下所示:

    import logging
import azure.functions as func
import azure.storage.blob
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
import json, os

def main(req: func.HttpRequest, inputblob: func.InputStream, outputblob: func.Out[func.InputStream]) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

# Initialize variable for tracking any changes
anyChanges= False

# Read JSON file
jsonData= json.loads(inputblob.read())

# Make changes to jsonData (omitted for simplicity) and update anyChanges

# Upload new JSON file
if anyChanges:
outputblob.set(jsonData)

return func.HttpResponse(f"Input data: {jsonData}. Any changes: {anyChanges}.")

但是,这根本不起作用,并抛出以下错误:

Value 'func.Out' is unsubscriptable

12 月的另一个人已经要求解决同一问题,但答案并没有解决问题

最佳答案

同样的问题,使用3.7.0切换到3.6.8解决

关于python - 我尝试使用 python 函数写入 azure blob 存储时遇到 Value 'func.Out' is unsubscriptable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59891847/

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