簡體   English   中英

Azure 函數 blob 觸發 blob 參數錯誤

[英]Azure function blob trigger blob paratemer error

我正在使用 blob 觸發器來讀取 blob 內容,作為 pandas DF 處理並將 blob 附加到我正在使用的 Azure SQL 服務器。

blob 觸發器沒有按預期工作,所以我在 main 函數中定義了所有代碼:

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")
    file = re.sub(r'^(.*?)\/','',myblob.name)
    if file not in processedfiles:
        stream = BytesIO((myblob.read()))
        stream.seek(0)

但是我收到以下錯誤:

Exception: FunctionLoadError: cannot load the BlobFileTrigger function: 
binding myblob has invalid non-type annotation <sqlalchemy.sql.functions._FunctionGenerator object at 0x7faa340f6a00>

有人可以幫我找到這個問題的原因嗎?

function.json 配置如下:

{
  "scriptFile": "__init__.py",
  "disabled": false,
  "bindings": [
      {
          "name": "myblob",
          "type": "blobTrigger",
          "direction": "in",
          "path": "input/{name}",
          "connection":"StorageConnection"
      }
  ]
}
  • 配置好的function.json文件就可以了。

  • 如果你得到一個空字節字符串,那么首先使用seek(0)方法,然后是stream中的Read()

  • 確保已處理文件的條件是否正確,因為如果在已處理if processedfiles未找到任何文件,則只會執行您的案例。

    即:- stream = BytesIO((myblob.read()))

參考: Python io.BytesIO 的 read() 和 getvalue() 方法

在 Python 中使用 Blobtrigger 的 Azure Functions

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM