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

    1. <small id='OEhFL'></small><noframes id='OEhFL'>

        <tfoot id='OEhFL'></tfoot>
        <legend id='OEhFL'><style id='OEhFL'><dir id='OEhFL'><q id='OEhFL'></q></dir></style></legend>

          <bdo id='OEhFL'></bdo><ul id='OEhFL'></ul>

        单例 Azure 函数作为单独的实例运行

        Singleton Azure function running as separate instances(单例 Azure 函数作为单独的实例运行)

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

                <bdo id='ud9c2'></bdo><ul id='ud9c2'></ul>
                  本文介绍了单例 Azure 函数作为单独的实例运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我们有一个 Azure 函数,它应该同时处理多个服务总线触发器,我假设正在发生的事情是它被拆分到多个实例中,这导致了我们端的一些并发问题.

                  We have an Azure function that is supposed to be handling several service bus triggers at the same time and what I assume is happening is that it is being split across several instances which is causing some concurrency problems on our end.

                  我们需要我们的函数充当单例,这样我们就可以一次处理一个请求而不会发生任何冲突.根据我们在本文中的研究 (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) 我们应该能够做到这一点.

                  We need our function to act as a singleton so we can process requests one at a time without any collisions. From what we looked into in this article (https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute) we should be able to accomplish this.

                  我们的函数如下所示:

                  [Microsoft.Azure.WebJobs.Singleton(Mode = SingletonMode.Listener)]
                  [FunctionName("AccountCreatedSubscriber")]
                  public static void Run([ServiceBusTrigger("accountscontacts-account-created", "license-keys", Connection = "FBISEventBus")]BrokeredMessage message, ILogger log)
                  {
                      log.LogInformation($"{{ Message received from accountscontacts-account-created topic }}");
                  
                      // Do Work
                      log.LogInformation($"{{ Message sent to account creation handler }}");
                  }
                  

                  为了备份,我们的 host.json 文件中也有这个,

                  And for backup we also have this in our host.json file,

                  {
                    "serviceBus": { "maxConcurrentCalls": 1 }
                  }
                  

                  但无论出于何种原因,我们的函数仍在并行运行.有什么想法吗?

                  But for whatever reason our functions are still running parallel. Any ideas?

                  推荐答案

                  1. 如果您的函数在消耗计划中,请在 WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT 设置为 1us/azure/azure-functions/functions-app-settings#websitemaxdynamicapplicationscaleout" rel="noreferrer">应用程序设置.

                  1. If your function is on Consumption plan, set WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT to 1 in Application settings.

                  在门户中检查您的 Azure Function 运行时版本(平台功能> 函数应用设置).如果是~2,我们需要在 host.json 如下.

                  Check your Azure Function runtime version in portal(Platform features> Function app settings). If it's ~2, we need to modify service bus setting in host.json as below.

                  {
                      "version": "2.0",
                      "extensions": {
                          "serviceBus": {
                              "messageHandlerOptions": {
                                 "maxConcurrentCalls": 1
                              }
                          }
                      }
                  }
                  

                  这篇关于单例 Azure 函数作为单独的实例运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 列表框上的取消选择)
                    <tfoot id='ZqbT0'></tfoot>

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

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

                            <tbody id='ZqbT0'></tbody>
                          <legend id='ZqbT0'><style id='ZqbT0'><dir id='ZqbT0'><q id='ZqbT0'></q></dir></style></legend>