简体   繁体   English

消息未从 Azure Function 添加到 Azurite 队列

[英]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:我尝试通过以下步骤重现该问题:

  1. Created Azure Functions (Stack: .Net Core 3.1 - Http Trigger) in Visual Studio.在 Visual Studio 中创建了 Azure 函数(堆栈:.Net Core 3.1 - Http 触发器)。
  2. Installed this package Microsoft.Azure.WebJobs.Extensions.Storage through Nuget Package Solution to the Project. Installed this package Microsoft.Azure.WebJobs.Extensions.Storage through Nuget Package Solution to the Project.
  3. Added the Output Queue binding to the Task static method like:添加了 Output 队列绑定到任务 static 方法,如:

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"
    }
}
  1. 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.

  2. 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.

相关问题 Azure队列和功能:将消息添加到队列中,但不会自动执行该功能 - Azure Queue and Function : Added message to queue but not automatically execute the function Azure函数的Azure队列/主题消息上的自定义消息属性 - Custom Message Properties on Azure Queue/Topic Message from Azure Function 从Azure函数将消息写入Azure Service Bus队列 - Writing message to Azure Service Bus queue from Azure function 为通过 Azure 函数输出绑定添加到 Azure 队列的消息设置 VisibilityTimeout - Setting the VisibilityTimeout for a Message added to an Azure Queue via Azure Function Output Binding 无法从 Azure 函数向服务总线队列写入消息 - Unable to write message to Service Bus Queue from Azure Function 从 Azure 存储队列到 Function App 的批量消息处理 - Batch message processing from Azure Storage Queue to Function App Azure函数从服务总线两次读取队列消息 - Azure function reading queue message twice from service bus 从Azure功能推迟或放弃消息服务总线队列 - Defer or Abandon message servicebus queue from azure function Azure队列存储消息未保存到正确的队列中 - Azure Queue Storage message not getting saved in the right queue On Azure Function 如何将 Azurite blob 容器用作 Azure Function 内部存储和触发器? - How to use Azurite blob containers as Azure Function internal storage and as trigger?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM