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

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

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

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

        获取 Azure Function App v2 的根目录

        Get root directory of Azure Function App v2(获取 Azure Function App v2 的根目录)
      1. <small id='RDzU1'></small><noframes id='RDzU1'>

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

                  本文介绍了获取 Azure Function App v2 的根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我构建了一个 Azure Function App (v2).所有功能所需的配置任务都在一个结构如下的 Setup 类中完成:

                  I build an Azure Function App (v2). Configuration tasks necessary for all functions are done in a Setup class that is structured like the following:

                  [assembly: WebJobsStartup(typeof(Startup))]
                  
                  internal class Startup : IWebJobsStartup
                  {
                    public void Configure(IWebJobsBuilder builder)
                    {
                      Configuration = new ConfigurationBuilder()
                                        .SetBasePath(<functionAppDirectory>)
                                        .AddJsonFile("local.settings.json")
                                        .Build();
                      builder.AddDependencyInjection(ConfigureServices);  
                    }
                  
                    public IConfiguration Configuration { get; set; }
                  
                    private void ConfigureServices(IServiceCollection services)
                    {
                      var connection = Configuration.GetConnectionString("<myconnection-string>");
                      ...
                    }
                  }
                  

                  ConfigureServices 我想从配置文件中读取一个连接字符串.为此,函数应用基本文件夹已使用 SetBasePath 指定.但我发现没有办法访问这条路径.根据 https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function 可以将 ExecutionContext 注入到包含路径的函数中需要.但是如何在我的 Startup 类中访问 ExecutionContext?

                  In ConfigureServices I want to read a connection string from a configuration file. For that the function app base folder has be specified with SetBasePath. But I found no way to get access to this path. According to https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function an ExecutionContext can be injected in a function, which contains the path need. But how do I access ExecutionContext in my Startup class?

                  推荐答案

                  你可以在你的启动文件中使用这段代码.我今天刚刚为我的项目测试了它,它适用于云和本地.

                  You can use this piece of code in your startup file. I have just tested it today for my project and it works on both cloud and local.

                  var executioncontextoptions = builder.Services.BuildServiceProvider()
                      .GetService<IOptions<ExecutionContextOptions>>().Value;
                  var currentDirectory = executioncontextoptions.AppDirectory;
                  

                  这篇关于获取 Azure Function App v2 的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

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

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

                            <tbody id='lEyt3'></tbody>

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