有些人可以发布一个示例代码,该代码教授如何通过队列触发器将文本文件上传到blob,
返回
文本文件。
我试过这个,但是理解
访问https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings?
答案 0 :(得分:1)
如果要通过队列触发器将队列消息存储到azure blob,可以使用cloudAppendblob。以下是演示代码
[FunctionName("TestQueueTrigger")]
public static void Run([QueueTrigger("queueName", Connection = "AzureWebJobsStorage")]string myQueueItem,TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AzureWebJobsStorage"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Create the container if it doesn't already exist.
container.CreateIfNotExists();
var appendBlob = container.GetAppendBlobReference("blobName.txt");
if (!appendBlob.Exists())
{
appendBlob.CreateOrReplace();
appendBlob.AppendText(myQueueItem);
}
else
{
appendBlob.AppendText($",{myQueueItem}");
}
}