Azure Functions Blob 部署
Azure Functions Blob deployment
这是我目前拥有的代码:
function.json
{
"bindings": [
{
"queueName": "myqueue-items",
"connection": "nameofstorageaccount_STORAGE",
"name": "queuemsg",
"type": "queueTrigger",
"direction": "in"
},
{
"name": "inputblob",
"type": "blob",
"dataType": "binary",
"path": "samples-workitems/{queueTrigger}",
"connection": "nameofstorageaccount_STORAGE",
"direction": "in"
},
{
"name": "outputblob",
"type": "blob",
"dataType": "binary",
"path": "samples-workitems/{queueTrigger}-Copy",
"connection": "nameofstorageaccount_STORAGE",
"direction": "out"
}
],
"disabled": false,
"scriptFile": "__init__.py"
}
init.py
import logging
import azure.functions as func
def main(queuemsg: func.QueueMessage, inputblob: bytes, outputblob: func.Out[bytes]):
logging.info(f'Python Queue trigger function processed {len(inputblob)} bytes')
outputblob.set(inputblob)
如果我没理解错的话,这个函数应该在一个 blob 被添加到一个容器时被触发,并且它会在同一个容器中保存那个 blob 的副本。
函数运行,但是当 blob 上传到容器时没有任何反应?我想用正在上传的 blob 触发一些代码,这是我用 Python 和 Blob Trigger.
找到的唯一完整示例
感谢任何帮助,
谢谢! :)
没有。如果您阅读 document
,它指出当消息发送到队列时触发该函数:
The following example shows blob input and output bindings in a
function.json file and Python code that uses the bindings. The
function makes a copy of a blob. The function is triggered by a
queue message that contains the name of the blob to copy. The new
blob is named {originalblobname}-Copy.
如果要在创建 blob 时执行函数,请参阅此处的 Blob Trigger
示例:https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=python.
这是我目前拥有的代码:
function.json
{
"bindings": [
{
"queueName": "myqueue-items",
"connection": "nameofstorageaccount_STORAGE",
"name": "queuemsg",
"type": "queueTrigger",
"direction": "in"
},
{
"name": "inputblob",
"type": "blob",
"dataType": "binary",
"path": "samples-workitems/{queueTrigger}",
"connection": "nameofstorageaccount_STORAGE",
"direction": "in"
},
{
"name": "outputblob",
"type": "blob",
"dataType": "binary",
"path": "samples-workitems/{queueTrigger}-Copy",
"connection": "nameofstorageaccount_STORAGE",
"direction": "out"
}
],
"disabled": false,
"scriptFile": "__init__.py"
}
init.py
import logging
import azure.functions as func
def main(queuemsg: func.QueueMessage, inputblob: bytes, outputblob: func.Out[bytes]):
logging.info(f'Python Queue trigger function processed {len(inputblob)} bytes')
outputblob.set(inputblob)
如果我没理解错的话,这个函数应该在一个 blob 被添加到一个容器时被触发,并且它会在同一个容器中保存那个 blob 的副本。
函数运行,但是当 blob 上传到容器时没有任何反应?我想用正在上传的 blob 触发一些代码,这是我用 Python 和 Blob Trigger.
找到的唯一完整示例感谢任何帮助, 谢谢! :)
没有。如果您阅读 document
,它指出当消息发送到队列时触发该函数:
The following example shows blob input and output bindings in a function.json file and Python code that uses the bindings. The function makes a copy of a blob. The function is triggered by a queue message that contains the name of the blob to copy. The new blob is named {originalblobname}-Copy.
如果要在创建 blob 时执行函数,请参阅此处的 Blob Trigger
示例:https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=python.