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

      <bdo id='y7olB'></bdo><ul id='y7olB'></ul>
      <tfoot id='y7olB'></tfoot>
    1. <small id='y7olB'></small><noframes id='y7olB'>

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

        从另一个 Azure Function 启动 Azure Function 的最佳实践

        Best practice for initiating Azure Function from another Azure Function(从另一个 Azure Function 启动 Azure Function 的最佳实践)

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

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

            • <legend id='cRTxQ'><style id='cRTxQ'><dir id='cRTxQ'><q id='cRTxQ'></q></dir></style></legend>
                <tbody id='cRTxQ'></tbody>

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

                  本文介绍了从另一个 Azure Function 启动 Azure Function 的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个场景,我有 2 个函数,比如说函数 A 和函数 B.

                  I have a scenario where I have 2 functions, let's say Function A and Function B.

                  目前,函数 A 和函数 B 都具有相同的逻辑来记录失败的活动,其中元数据记录到表存储和 JSON 记录到 Blob 存储.

                  Currently, Function A and Function B both have the same logic for logging failed activity where metadata is logged to Table Storage and JSON to Blob Storage.

                  编辑 --> 函数 A 和函数 B 位于两个不同的函数应用程序中(有意).功能 A 属于消费计划,功能 B 属于应用服务计划.

                  第一个问题 - 创建一个函数 C 并从 A 和 B 获取失败的活动日志记录逻辑并将其放入 C 中是否有意义?

                  First question - would it make sense to create a Function C and take the failed activity logging logic from both A and B and put it in C?

                  这消除了代码重复,逻辑集中在一个更易于管理的地方.

                  This removes code duplication and the logic is in one place which is easier to manage.

                  第二个问题 - 从 A 和 B 调用函数 C 的最佳方法是什么?

                  Second question - what would be the best way to call Function C from A and B?

                  我已阅读 这里 最好使用 Storage Queue 或 Service Bus 来实现 Functions 之间的交叉通信.我遇到的问题是 - 在大多数情况下,我需要存储的 JSON 将超过 256KB,因此我无法将其放入队列中以触发函数.

                  I have read here that it is best to use a Storage Queue or Service Bus for cross communication between Functions. The problem I have is - the JSON I need to store will in most cases exceed 256KB so I can't put it on a queue to trigger a Function.

                  那么,函数 C 是否可以作为 HTTP 触发器,并且我发送一个请求,其中包含通过 HTTP 从函数 A 和 B 记录所需的所有相关信息?

                  So, could Function C be a HTTP trigger and I send a request containing all of my relevant information needed to log via HTTP from Function A and B?

                  有什么理由不这样做吗?

                  Is there any reason not to do this?

                  非常感谢.

                  推荐答案

                  为了将来参考(以及那些可能通过网络搜索找到这个问题的人),我们构建了一个新的 Durable Functions 对 Azure Functions 的扩展,允许从另一个函数调用一个函数.您的具体问题可能会编码如下:

                  For future reference (and for those who may find this question via web searching), we've built a new Durable Functions extension to Azure Functions which allows calling one function from another. Your specific problem could potentially be coded up as follows:

                  public static async Task<object> Run(DurableOrchestrationContext ctx)
                  {
                      try
                      {
                          var result = await ctx.CallActivityAsync<object>("FunctionA");
                          var y = await ctx.CallActivityAsync<object>("FunctionB", result);
                          return y;
                      }
                      catch (Exception e)
                      {
                          // error handling/compensation goes here
                          await ctx.CallActivityAsync<object>("FunctionC", e);
                          return null;
                      }
                  }
                  

                  FunctionAFunctionB 是 活动函数 可以存在于同一个函数应用中.上面安排它们的函数是 协调器功能.支持消费和应用服务计划.

                  FunctionA and FunctionB are activity functions that can live in the same function app. The function above which schedules them is an orchestrator function. Both Consumption and App Service plans are supported.

                  在幕后,CallActivityAsync 方法通过 Azure 存储队列发送消息以按名称触发指定的函数.通过自动切换到队列和 Blob 的组合来支持大型消息,以确保它们能够可靠地传递.

                  Under the covers the CallActivityAsync method sends a message via a Azure Storage queue to trigger the specified function by name. Large messages are supported by automatically switching to a combination of queues and blobs to ensure they can be delivered reliably.

                  然而,一个重要的限制是 FunctionA 和 FunctionB 必须在同一个函数应用中定义.因此,这与您的问题不完全匹配.但是,对于那些可以将其功能保留在同一个函数应用中的人来说,这是一个很好的解决方案.

                  One important constraint, however, is that FunctionA and FunctionB must be defined in the same function app. For that reason, it's not an exact match for your question. It's a great solution for those who can keep their functions in the same function app, however.

                  官方文档:https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-overview

                  GitHub:https://github.com/Azure/azure-functions-durable-extension

                  这篇关于从另一个 Azure Function 启动 Azure Function 的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)

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

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

                    <tbody id='UGeew'></tbody>

                • <legend id='UGeew'><style id='UGeew'><dir id='UGeew'><q id='UGeew'></q></dir></style></legend><tfoot id='UGeew'></tfoot>
                      <bdo id='UGeew'></bdo><ul id='UGeew'></ul>