[英]Azure Function using Python - Blob trigger not firing
我正在研究 Azure Function 中的一個,它寫在 Python 中,它應該根據 Blob 觸發事件被調用。 但是,當我在 azure function 應該監視的 blob 容器中上傳 zip 文件時,觸發器沒有觸發。
以下是 local.settings.json 文件 -
{
"IsEncrypted": false,
"Values":
{
"AzureWebJobsStorage": "blob (connection string) that was created when Azure function is created",
"FUNCTIONS_WORKER_RUNTIME": "python",
"My_STORAGE": "blob (connection string) that function should monitor"
}
}
以下是 function.json 文件 -
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "mycontainer/{name}",
"connection": "My_STORAGE"
}
]
}
以下是我的代碼init .py -(test_func 是用戶定義的 function 來執行一些業務邏輯)
def main(myblob: func.InputStream):
test_func(myblob.name)
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
當我在“mycontainer”容器中上傳 zip 文件時,azure function 沒有觸發。
StorageV2(通用 v2)帳戶類型的“mycontainer”。 我正在使用Python 3.8版本。
這個“mycontainer”已經自動創建了一個名為 $logs 的容器,它有一個 day wise 文件夾,其中包含一個日志文件,其中提到了我在“mycontainer”中上傳的文件,但是,在 Azure function 上沒有 blob 觸發事件的跡象。
在 Azure 功能的配置設置中添加“My_STORAGE”作為應用程序設置。 我在 Azure Function 部署后上傳本地設置。
知道出了什么問題嗎?
謝謝你。
我遇到過類似的問題。 通過在 Function App->Configuration->Settings 中的 Application Settings 添加連接字符串作為鍵值對來解決。 我假設如果 Azure Functions Apps 部署在不同的存儲容器中,則必須這樣做,為此需要不同的連接字符串。
問題是由連接字符串錯誤引起的。 連接字符串中的AccountName
應該是存儲帳戶名稱,而不是容器名稱。
因此,只需將AccountName=mycontainer
更改為AccountName=<storage account name>
即可。
順便說一下:
連接字符串應為: DefaultEndpointsProtocol=https;AccountName=<storage account name>;AccountKey=xxxxxxxxxx==;EndpointSuffix=core.windows.net
“function.json”中的“路徑”應該是: "path": "<container name>/{name}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.