<bdo id='2bCpq'></bdo><ul id='2bCpq'></ul>

    <tfoot id='2bCpq'></tfoot>

    <i id='2bCpq'><tr id='2bCpq'><dt id='2bCpq'><q id='2bCpq'><span id='2bCpq'><b id='2bCpq'><form id='2bCpq'><ins id='2bCpq'></ins><ul id='2bCpq'></ul><sub id='2bCpq'></sub></form><legend id='2bCpq'></legend><bdo id='2bCpq'><pre id='2bCpq'><center id='2bCpq'></center></pre></bdo></b><th id='2bCpq'></th></span></q></dt></tr></i><div id='2bCpq'><tfoot id='2bCpq'></tfoot><dl id='2bCpq'><fieldset id='2bCpq'></fieldset></dl></div>
  • <legend id='2bCpq'><style id='2bCpq'><dir id='2bCpq'><q id='2bCpq'></q></dir></style></legend>
  • <small id='2bCpq'></small><noframes id='2bCpq'>

        Azure Functions:队列触发器需要 Base-64 消息,但未正确处理它们

        Azure Functions: Queue Trigger is expecting Base-64 messages and doesn#39;t process them correctly(Azure Functions:队列触发器需要 Base-64 消息,但未正确处理它们)

        <tfoot id='xWDAr'></tfoot>
        • <small id='xWDAr'></small><noframes id='xWDAr'>

        • <legend id='xWDAr'><style id='xWDAr'><dir id='xWDAr'><q id='xWDAr'></q></dir></style></legend>

              <tbody id='xWDAr'></tbody>

            <i id='xWDAr'><tr id='xWDAr'><dt id='xWDAr'><q id='xWDAr'><span id='xWDAr'><b id='xWDAr'><form id='xWDAr'><ins id='xWDAr'></ins><ul id='xWDAr'></ul><sub id='xWDAr'></sub></form><legend id='xWDAr'></legend><bdo id='xWDAr'><pre id='xWDAr'><center id='xWDAr'></center></pre></bdo></b><th id='xWDAr'></th></span></q></dt></tr></i><div id='xWDAr'><tfoot id='xWDAr'></tfoot><dl id='xWDAr'><fieldset id='xWDAr'></fieldset></dl></div>
                <bdo id='xWDAr'></bdo><ul id='xWDAr'></ul>

                  本文介绍了Azure Functions:队列触发器需要 Base-64 消息,但未正确处理它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个队列触发器.预期是当我在 Queue 中插入消息时,触发器必须触发并处理出队的消息.

                   [FunctionName("NewPayrollQueueTrigger")]公共异步静态无效运行([QueueTrigger(myqueue",连接="AzureWebJobsStorage")]string myQueueItem,[DurableClient] IDurableOrchestrationClient 启动器,ILogger 日志){log.LogInformation($"C# 队列触发函数处理:{myQueueItem}");await starter.StartNewAsync("NewPayrollOrchestrator", input: myQueueItem);}

                  触发器正在正常激活,但正在发生这种奇怪的行为.该函数显然期望 messageBase-64 编码.

                  <块引用>

                  异常绑定参数'myQueueItem' <--- 输入不是有效的 Base-64 字符串,因为它包含一个非 base 64 字符,多于两个填充字符,或填充中的非法字符字符.

                  我正在使用来自 Azure.Storage.QueuesAzure Queue 库 v.12 中的此方法向队列发送消息,但没有发现对消息进行编码的重载Base-64.请注意,_queue

                  实现此功能的唯一方法是,如果我使用 Azure 存储资源管理器选择通过 UI 对消息进行编码,手动将消息发送到队列.

                  解决方案

                  作为替代方案,您可以通过使用 QueueClientOptions 创建客户端,利用内置功能将消息转换为 Base64MessageEncoding 设置为 QueueMessageEncoding.Base64.

                  例如:

                  _queue = new QueueClient(connectionString, queueName, new QueueClientOptions{MessageEncoding = QueueMessageEncoding.Base64});...var message = "一些消息";等待_queue.SendMessageAsync(消息);//将转换为 Base64.

                  I have this Queue Trigger. The expected is when I insert a message in the Queue, the trigger must fire and process the dequeued message.

                      [FunctionName("NewPayrollQueueTrigger")]
                      public async static void Run([QueueTrigger("myqueue", Connection = 
                      "AzureWebJobsStorage")]string myQueueItem,
                          [DurableClient] IDurableOrchestrationClient starter,
                          ILogger log)
                      {
                          log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
                  
                          await starter.StartNewAsync("NewPayrollOrchestrator", input: myQueueItem);
                  
                      }
                  

                  The trigger is being activated normally, but this weird behavior is happening. The function apparently expects that the message is encoded in Base-64.

                  Exception binding parameter 'myQueueItem' <--- The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

                  I'm sending messages to the queue using this method from the Azure Queue library v.12 from Azure.Storage.Queues and found no overloads that encodes the message to Base-64. Note that _queue is a QueueClient instance.

                   public async Task<Response<SendReceipt>> SendAsync(string message)
                   {
                          return await _queue.SendMessageAsync(message);
                   }
                  

                  So I tried to encode the message by myself...

                   public async Task<Response<SendReceipt>> SendAsBase64Async(string message)
                   {
                        byte[] buffer = Encoding.Unicode.GetBytes(message);
                        string msg = Convert.ToBase64String(buffer);
                  
                        return await _queue.SendMessageAsync(msg);
                  
                   }
                  

                  ... and it doesn't work either. Here's my code passing by that part but throwing error further on, indicating that it could get the message but it was not decoded correctly, since it was a filename of an existing blob in a storage:

                  The only way to get this working is if I manually send a message to the queue using the Azure Storage Explorerchoosing for encode the message via UI.

                  解决方案

                  As an alternative, you can take advantage of the built in functionality for converting the message to Base64 by creating the client with an QueueClientOptions with MessageEncoding set to QueueMessageEncoding.Base64.

                  For example:

                  _queue = new QueueClient(connectionString, queueName, new QueueClientOptions
                  {
                      MessageEncoding = QueueMessageEncoding.Base64
                  });
                  
                  ...
                  
                  var message = "some message";
                  await _queue.SendMessageAsync(message); // Will be converted as Base64.
                  

                  这篇关于Azure Functions:队列触发器需要 Base-64 消息,但未正确处理它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  <i id='cghMT'><tr id='cghMT'><dt id='cghMT'><q id='cghMT'><span id='cghMT'><b id='cghMT'><form id='cghMT'><ins id='cghMT'></ins><ul id='cghMT'></ul><sub id='cghMT'></sub></form><legend id='cghMT'></legend><bdo id='cghMT'><pre id='cghMT'><center id='cghMT'></center></pre></bdo></b><th id='cghMT'></th></span></q></dt></tr></i><div id='cghMT'><tfoot id='cghMT'></tfoot><dl id='cghMT'><fieldset id='cghMT'></fieldset></dl></div>

                    <legend id='cghMT'><style id='cghMT'><dir id='cghMT'><q id='cghMT'></q></dir></style></legend>

                      <bdo id='cghMT'></bdo><ul id='cghMT'></ul>
                      <tfoot id='cghMT'></tfoot>

                        <tbody id='cghMT'></tbody>

                      <small id='cghMT'></small><noframes id='cghMT'>