• <bdo id='Xi8ag'></bdo><ul id='Xi8ag'></ul>

  • <small id='Xi8ag'></small><noframes id='Xi8ag'>

    <tfoot id='Xi8ag'></tfoot>

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

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

        Azure 函数 local.settings.json 在 appsettings.json 中表示 ServiceB

        Azure functions local.settings.json represented in appsettings.json for a ServiceBusTrigger(Azure 函数 local.settings.json 在 appsettings.json 中表示 ServiceBusTrigger)

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

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

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

                  本文介绍了Azure 函数 local.settings.json 在 appsettings.json 中表示 ServiceBusTrigger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前有一个使用 ServiceBusTrigger 绑定的天蓝色函数

                   [ServiceBusTrigger("%TopicName%", "%SubscripionName%", Connection = "MyConnection")]字符串 catclogueEventMsgs、ILogger 日志、ExecutionContext 上下文)

                  使用这个 local.settings.json 文件

                   "值": {…我的连接":端点=sb://testxxxxxxxxxxxxxxxxxx订阅名称":测试订阅名称""主题名称": "测试主题名称",}

                  如何在 appsettings.json 文件中表示这一点.会像下面这样吗?

                   "值": {我的连接":端点=sb://testxxxxxxxxxxxxxxxxxx订阅名称":测试订阅名称""主题名称": "测试主题名称",}

                  我可以使用例如MySubs"对象来代替使用Values"对象吗?

                   "MySubs": {我的连接":端点=sb://testxxxxxxxxxxxxxxxxxx订阅名称":测试订阅名称""主题名称": "测试主题名称",}

                  如果可以使用上述设置,我如何在 ServiceBusTrigger 绑定中表示?我会改成这个吗?

                   [ServiceBusTrigger("%MySubs.TopicName%", "%MySubs.SubscripionName%", Connection = "MySubs.MyConnection")]字符串 catclogueEventMsgs、ILogger 日志、ExecutionContext 上下文)

                  解决方案

                  您确实可以读取 Values 数组之外的设置,如下所示:

                  WeatherApiConfig.cs

                  公共类 WeatherApiConfig{公共字符串 WeatherApiUrl { 获取;放;}公共字符串 WeatherApiKey { 获取;放;}}

                  <块引用>

                  Azure Functions V2 的新功能,

                  I currently have an azure function using the ServiceBusTrigger binding

                   [ServiceBusTrigger("%TopicName%", "%SubscripionName%", Connection = "MyConnection")]
                           string  catclogueEventMsgs, ILogger log, ExecutionContext context)
                  

                  which uses this local.settings.json file

                     "Values": {
                               …
                      "MyConnection": "Endpoint=sb://testxxxxxxxxxxxxxxxxxx
                      "SubscriptionName": "testsubscriptionName"
                      "TopicName": "testtopicName",
                    }
                  

                  How do I represent this in the appsettings.json file. Will it be like the below?

                     "Values": {
                      "MyConnection": "Endpoint=sb://testxxxxxxxxxxxxxxxxxx
                      "SubscriptionName": "testsubscriptionName"
                      "TopicName": "testtopicName",
                    }
                  

                  Instead of using a "Values" object can I use eg "MySubs" object like the below?

                     "MySubs": {
                      "MyConnection": "Endpoint=sb://testxxxxxxxxxxxxxxxxxx
                      "SubscriptionName": "testsubscriptionName"
                      "TopicName": "testtopicName",
                    }
                  

                  If its possible to use the above settings, how do I represent this in the ServiceBusTrigger binding? would i change it to this?

                   [ServiceBusTrigger("%MySubs.TopicName%", "%MySubs.SubscripionName%", Connection = "MySubs.MyConnection")]
                           string  catclogueEventMsgs, ILogger log, ExecutionContext context)
                  

                  解决方案

                  You CAN indeed read settings outside the Values array as follows:

                  WeatherApiConfig.cs

                  public class WeatherApiConfig
                  {
                      public string WeatherApiUrl { get; set; }
                      public string WeatherApiKey { get; set; }
                  }
                  

                  New for Azure Functions V2, we have an appropriate way to handle DI as shown below:

                  Startup.cs

                  [assembly: FunctionsStartup(typeof(BlazingDemo.Api.Startup))]
                  
                  namespace BlazingDemo.Api
                  {
                      public class Startup : FunctionsStartup
                      {
                          public override void Configure(IFunctionsHostBuilder builder)
                          {
                              var config = new ConfigurationBuilder()
                                  .SetBasePath(Directory.GetCurrentDirectory())
                                  .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                                  .AddEnvironmentVariables()
                                  .Build();
                  
                              var apiConfig = new WeatherApiConfig();
                              config.Bind(nameof(WeatherApiConfig), apiConfig);
                  
                              builder.Services.AddSingleton(apiConfig);
                              builder.Services.AddHttpClient();
                          }
                      }
                  }
                  

                  Local.settings.json

                  {  
                    "IsEncrypted": false,
                    "Values": {
                      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
                      "FUNCTIONS_WORKER_RUNTIME": "dotnet"
                    },
                    "WeatherApiConfig": {
                      "WeatherApiUrl": "http://api.openweathermap.org/data/2.5/weather",
                      "WeatherApiKey": "**removed**"
                    }
                  }
                  

                  Note: The key for me was to add .SetBasePath(Directory.GetCurrentDirectory()) in Startup.cs since it couldn't find the file without it.

                  In production I use the function app's Application Settings section to configure these two properties as follows:

                  这篇关于Azure 函数 local.settings.json 在 appsettings.json 中表示 ServiceBusTrigger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 是否相等(按值,而不是按引用)?)

                      <tfoot id='YljGX'></tfoot>

                          <bdo id='YljGX'></bdo><ul id='YljGX'></ul>
                          <legend id='YljGX'><style id='YljGX'><dir id='YljGX'><q id='YljGX'></q></dir></style></legend>
                          • <small id='YljGX'></small><noframes id='YljGX'>

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