2 回答
TA貢獻1995條經(jīng)驗 獲得超2個贊
如下:
ICollector 和 IAsyncCollector 可用作存儲隊列輸出綁定的參數(shù)類型。
目前,azure 函數(shù)綁定僅支持輸出綁定以將消息寫入隊列?;蛘?,如果您不需要使用 HTTP 請求調(diào)用隊列觸發(fā)器,則可以使用隊列觸發(fā)器來檢索消息。
如果您必須使用 HTTP 請求,假設(shè)您必須創(chuàng)建一個 HTTP 觸發(fā)函數(shù),然后檢索并刪除隊列以實現(xiàn)出隊操作,如下面的代碼。
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貢獻1796條經(jīng)驗 獲得超4個贊
為什么不創(chuàng)建一個應(yīng)用程序調(diào)用的 Webhook 函數(shù),然后在該函數(shù)中,您可以根據(jù)需要使用適用于您使用的任何語言的標準存儲隊列 API 將項目出列。
- 2 回答
- 0 關(guān)注
- 233 瀏覽
添加回答
舉報
