2 回答

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊
如下:
ICollector 和 IAsyncCollector 可用作存儲隊(duì)列輸出綁定的參數(shù)類型。
目前,azure 函數(shù)綁定僅支持輸出綁定以將消息寫入隊(duì)列?;蛘撸绻恍枰褂?HTTP 請求調(diào)用隊(duì)列觸發(fā)器,則可以使用隊(duì)列觸發(fā)器來檢索消息。
如果您必須使用 HTTP 請求,假設(shè)您必須創(chuàng)建一個(gè) HTTP 觸發(fā)函數(shù),然后檢索并刪除隊(duì)列以實(shí)現(xiàn)出隊(duì)操作,如下面的代碼。
public static async Task<IActionResult> Run(
? ? ? ? [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
? ? ? ? ILogger log)
? ? {
? ? ? ? log.LogInformation("C# HTTP trigger function processed a request.");
? ? ? ? // Parse the connection string and return a reference to the storage account.
? ? ? ? CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("AzureWebJobsStorage"));
? ? ? ? CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
? ? ? ? // Retrieve a reference to a queue
? ? ? ? CloudQueue queue = queueClient.GetQueueReference("myqueue");
? ? ? ? // Async dequeue the message
? ? ? ? CloudQueueMessage retrievedMessage = await queue.GetMessageAsync();
? ? ? ? Console.WriteLine("Retrieved message with content '{0}'", retrievedMessage.AsString);
? ? ? ? //Process the message in less than 30 seconds, and then delete the message
? ? ? ? await queue.DeleteMessageAsync(retrievedMessage);
? ? ? ? return? (ActionResult)new OkObjectResult(retrievedMessage.AsString);
? ? }

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊
為什么不創(chuàng)建一個(gè)應(yīng)用程序調(diào)用的 Webhook 函數(shù),然后在該函數(shù)中,您可以根據(jù)需要使用適用于您使用的任何語言的標(biāo)準(zhǔn)存儲隊(duì)列 API 將項(xiàng)目出列。
- 2 回答
- 0 關(guān)注
- 171 瀏覽
添加回答
舉報(bào)