[英]Message not added to Azurite Queue from Azure Function
Following the documentation below I trying to create an azure function which adds a message to a queue.按照下面的文档,我尝试创建一个 azure function ,它将消息添加到队列中。
https://docs.microsoft.com/en-us/azure/azure-functions/functions-add-output-binding-storage-queue-vs?tabs=in-process#add-an-output-binding https://docs.microsoft.com/en-us/azure/azure-functions/functions-add-output-binding-storage-queue-vs?tabs=in-process#add-an-output-binding
The code gets triggered and executes with out an error, but I could not see any message in the Azure Storage Explorer Queue.代码被触发并在没有错误的情况下执行,但我在 Azure 存储资源管理器队列中看不到任何消息。
I added Azurite Storage account to my local Storage Explorer.我将 Azurite Storage 帐户添加到本地存储资源管理器。 But the queue does not get created and the message is not getting added.
但是没有创建队列,也没有添加消息。
AzureWebJobsStorage is set to "UseDevelopmentStorage=true". AzureWebJobsStorage 设置为“UseDevelopmentStorage=true”。
How do I test this locally in the storage explorer?如何在存储资源管理器中进行本地测试? What are the steps and what all do I need?
步骤是什么,我需要什么?
I tried to reproduce the issue by following steps:我尝试通过以下步骤重现该问题:
Microsoft.Azure.WebJobs.Extensions.Storage
through Nuget Package Solution to the Project. Microsoft.Azure.WebJobs.Extensions.Storage
through Nuget Package Solution to the Project. public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, [Queue("outqueue"), StorageAccount("AzureWebJobsStorage")] ICollector<string> msg, ILogger log)
Added the code which writes the passed parameter in the function URL to the output queue (before parsing the response message code):在 output 队列中添加了将 function URL 中写入传递参数的代码(在解析响应消息代码之前):
if (!string.IsNullOrEmpty(name))
{
// Add a message to the output collection.
msg.Add(string.Format("Name passed to the function: {0}", name));
}
Now the full code looks is:现在完整的代码看起来是:
local.settings.json local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
Run the function locally and copy the function URL that comes in the console to the browser along with parameters like: http://localhost:7071/api/Function1?name=HariKrishna
Then it should be displayed in the browser as Hello, HariKrishna. This HTTP triggered function executed successfully.
Run the function locally and copy the function URL that comes in the console to the browser along with parameters like:
http://localhost:7071/api/Function1?name=HariKrishna
Then it should be displayed in the browser as Hello, HariKrishna. This HTTP triggered function executed successfully.
Hello, HariKrishna. This HTTP triggered function executed successfully.
Go to the Storage Explorer > Expand Queues and refresh it ( right-click on queues and click refresh ) to see the queue created by functions runtime while a function is running and refresh the output queue also to see the messages as you can the console output, browser output and Queue messages in below screenshot: Go to the Storage Explorer > Expand Queues and refresh it ( right-click on queues and click refresh ) to see the queue created by functions runtime while a function is running and refresh the output queue also to see the messages as you can the console output ,浏览器 output 和队列消息在下面的截图:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.