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

    1. <tfoot id='FnRuF'></tfoot>

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

        <bdo id='FnRuF'></bdo><ul id='FnRuF'></ul>
      1. 存储 Azure Function 环境变量的最佳位置

        时间:2023-10-05
      2. <small id='d0qY9'></small><noframes id='d0qY9'>

            <tbody id='d0qY9'></tbody>

            <bdo id='d0qY9'></bdo><ul id='d0qY9'></ul>
            <legend id='d0qY9'><style id='d0qY9'><dir id='d0qY9'><q id='d0qY9'></q></dir></style></legend>
            <tfoot id='d0qY9'></tfoot>
            <i id='d0qY9'><tr id='d0qY9'><dt id='d0qY9'><q id='d0qY9'><span id='d0qY9'><b id='d0qY9'><form id='d0qY9'><ins id='d0qY9'></ins><ul id='d0qY9'></ul><sub id='d0qY9'></sub></form><legend id='d0qY9'></legend><bdo id='d0qY9'><pre id='d0qY9'><center id='d0qY9'></center></pre></bdo></b><th id='d0qY9'></th></span></q></dt></tr></i><div id='d0qY9'><tfoot id='d0qY9'></tfoot><dl id='d0qY9'><fieldset id='d0qY9'></fieldset></dl></div>
                1. 本文介绍了存储 Azure Function 环境变量的最佳位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用几个 api 键在本地测试一个 azure 函数.存储环境变量的最佳位置是什么以及如何访问它们?我试过了

                  I'm testing an azure function locally with several api keys. Whats the best place to store environment variables and how do I access them? I tried

                  System.Environment.GetEnvironmentVariable("name")}
                  

                  但我不确定环境变量的存储位置.

                  but I'm not sure where the environment variable is stored.

                  谢谢!

                  推荐答案

                  你应该有一个名为 local.settings.json 的文件.这是 Functions-Run-Local

                  You should have a file called local.settings.json. Here is the azure website for Functions-Run-Local

                  说明

                  这些设置也可以在您的代码中作为环境变量读取.在 C# 中,使用 System.Environment.GetEnvironmentVariable 或 ConfigurationManager.AppSettings.在 JavaScript 中,使用 process.env.指定为系统环境变量的设置优先于 local.settings.json 文件中的值.

                  These settings can also be read in your code as environment variables. In C#, use System.Environment.GetEnvironmentVariable or ConfigurationManager.AppSettings. In JavaScript, use process.env. Settings specified as a system environment variable take precedence over values in the local.settings.json file.

                  local.settings.json 示例

                  example local.settings.json

                  {
                    "IsEncrypted": false,   
                    "Values": {
                      "AzureWebJobsStorage": "<connection string>", 
                      "AzureWebJobsDashboard": "<connection string>" 
                    },
                    "Host": {
                      "LocalHttpPort": 7071, 
                      "CORS": "*" 
                    },
                    "ConnectionStrings": {
                      "SQLConnectionString": "Value"
                    }
                  }
                  

                  它说您需要将应用程序设置放在 local.settings.json 中的 Values 属性下.

                  It says that you need to put the application settings under the Values property within the local.settings.json.

                  为了检索,我使用了 ConfigurationManager.AppSettings["CustomSetting"],因为它可以让您检索连接字符串.

                  To retrieve I used ConfigurationManager.AppSettings["CustomSetting"] as it lets you retrieve connection strings.

                  我一直在玩这个,发现你必须有一个字符串键和一个字符串值.当我尝试创建一个小节时出现错误(就像您在 appsettings.json 中所做的那样).我必须让 local.settings.json 看起来像这样:

                  I have just been playing around with this and discovered that you have to have a a string key and a string value. I got an error when I tried having a subsection (like you would in an appsettings.json). I had to have the local.settings.json look like this:

                  {
                    "IsEncrypted": false,   
                    "Values": {
                      "AzureWebJobsStorage": "<connection string>", 
                      "AzureWebJobsDashboard": "<connection string>" 
                      "CustomSetting":"20"
                    }
                  }
                  

                  这篇关于存储 Azure Function 环境变量的最佳位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何通过 POST 将参数传递给 Azure 函数? 下一篇:Azure Functions 中的 DI

                  相关文章

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

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

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

                  1. <legend id='u3bpC'><style id='u3bpC'><dir id='u3bpC'><q id='u3bpC'></q></dir></style></legend>

                    1. <tfoot id='u3bpC'></tfoot>