Reading settings from a Azure Function
I'm new to Azure's function... I've created a new timer function (will be fired every 30 minutes) and it has to perform a query on a url, then push data on the buffer..
I've done
public static void Run(TimerInfo myTimer, TraceWriter log)
var s = CloudConfigurationManager.GetSetting("url");
log.Info(s);
And in my function settings I've
What am I doing wrong?
Thanks
azure
add a comment |
I'm new to Azure's function... I've created a new timer function (will be fired every 30 minutes) and it has to perform a query on a url, then push data on the buffer..
I've done
public static void Run(TimerInfo myTimer, TraceWriter log)
var s = CloudConfigurationManager.GetSetting("url");
log.Info(s);
And in my function settings I've
What am I doing wrong?
Thanks
azure
add a comment |
I'm new to Azure's function... I've created a new timer function (will be fired every 30 minutes) and it has to perform a query on a url, then push data on the buffer..
I've done
public static void Run(TimerInfo myTimer, TraceWriter log)
var s = CloudConfigurationManager.GetSetting("url");
log.Info(s);
And in my function settings I've
What am I doing wrong?
Thanks
azure
I'm new to Azure's function... I've created a new timer function (will be fired every 30 minutes) and it has to perform a query on a url, then push data on the buffer..
I've done
public static void Run(TimerInfo myTimer, TraceWriter log)
var s = CloudConfigurationManager.GetSetting("url");
log.Info(s);
And in my function settings I've
What am I doing wrong?
Thanks
azure
azure
asked Apr 22 '17 at 7:02
advapiadvapi
1,06911134
1,06911134
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You need to go to Platform Features -> Application settings and add it there.
Add the setting under App settings.
Reading the setting can be done by first adding this at the top:
using System.Configuration;
And then reading a setting with:
string setting = ConfigurationManager.AppSettings["url"];
Where url
is your setting key. The setting
variable will contain your setting value.
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
Note that during development you will need to set these configuration values inlocal.settings.json
.
– Jaime Hablutzel
Dec 15 '17 at 6:05
add a comment |
Note that for Azure Functions v2 this is no longer true.
The following is from Jon Gallant's blog:
For Azure Functions v2, the ConfigurationManager is not supported and you must use the ASP.NET Core Configuration system:
Include the following using statement:
using Microsoft.Extensions.Configuration;
Include the ExecutionContext as a parameter
public static void Run(InboundMessage inboundMessage,
TraceWriter log,
out string outboundMessage,
ExecutionContext context)Get the
IConfiguration
Rootvar config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();And use it to reference AppSettings keys
var password = config["password"]
When debugging locally, it gets the settings from local.settings.json
under the "Values" keyword. When running in Azure, it gets the settings from the Application settings tab.
add a comment |
You can use System.Environment.GetEnvironmentVariable
like this:
var value = Environment.GetEnvironmentVariable("your_key_here")
This gets settings whenever you're working locally or on Azure.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43556311%2freading-settings-from-a-azure-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to go to Platform Features -> Application settings and add it there.
Add the setting under App settings.
Reading the setting can be done by first adding this at the top:
using System.Configuration;
And then reading a setting with:
string setting = ConfigurationManager.AppSettings["url"];
Where url
is your setting key. The setting
variable will contain your setting value.
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
Note that during development you will need to set these configuration values inlocal.settings.json
.
– Jaime Hablutzel
Dec 15 '17 at 6:05
add a comment |
You need to go to Platform Features -> Application settings and add it there.
Add the setting under App settings.
Reading the setting can be done by first adding this at the top:
using System.Configuration;
And then reading a setting with:
string setting = ConfigurationManager.AppSettings["url"];
Where url
is your setting key. The setting
variable will contain your setting value.
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
Note that during development you will need to set these configuration values inlocal.settings.json
.
– Jaime Hablutzel
Dec 15 '17 at 6:05
add a comment |
You need to go to Platform Features -> Application settings and add it there.
Add the setting under App settings.
Reading the setting can be done by first adding this at the top:
using System.Configuration;
And then reading a setting with:
string setting = ConfigurationManager.AppSettings["url"];
Where url
is your setting key. The setting
variable will contain your setting value.
You need to go to Platform Features -> Application settings and add it there.
Add the setting under App settings.
Reading the setting can be done by first adding this at the top:
using System.Configuration;
And then reading a setting with:
string setting = ConfigurationManager.AppSettings["url"];
Where url
is your setting key. The setting
variable will contain your setting value.
edited Apr 22 '17 at 12:17
answered Apr 22 '17 at 11:03
juunasjuunas
23.5k35182
23.5k35182
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
Note that during development you will need to set these configuration values inlocal.settings.json
.
– Jaime Hablutzel
Dec 15 '17 at 6:05
add a comment |
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
Note that during development you will need to set these configuration values inlocal.settings.json
.
– Jaime Hablutzel
Dec 15 '17 at 6:05
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
Thanks for your reply... but how do i read them from script?
– advapi
Apr 22 '17 at 12:16
1
1
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
Check my update, System.Configuration.ConfigurationManager is the class I use typically.
– juunas
Apr 22 '17 at 12:18
2
2
Note that during development you will need to set these configuration values in
local.settings.json
.– Jaime Hablutzel
Dec 15 '17 at 6:05
Note that during development you will need to set these configuration values in
local.settings.json
.– Jaime Hablutzel
Dec 15 '17 at 6:05
add a comment |
Note that for Azure Functions v2 this is no longer true.
The following is from Jon Gallant's blog:
For Azure Functions v2, the ConfigurationManager is not supported and you must use the ASP.NET Core Configuration system:
Include the following using statement:
using Microsoft.Extensions.Configuration;
Include the ExecutionContext as a parameter
public static void Run(InboundMessage inboundMessage,
TraceWriter log,
out string outboundMessage,
ExecutionContext context)Get the
IConfiguration
Rootvar config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();And use it to reference AppSettings keys
var password = config["password"]
When debugging locally, it gets the settings from local.settings.json
under the "Values" keyword. When running in Azure, it gets the settings from the Application settings tab.
add a comment |
Note that for Azure Functions v2 this is no longer true.
The following is from Jon Gallant's blog:
For Azure Functions v2, the ConfigurationManager is not supported and you must use the ASP.NET Core Configuration system:
Include the following using statement:
using Microsoft.Extensions.Configuration;
Include the ExecutionContext as a parameter
public static void Run(InboundMessage inboundMessage,
TraceWriter log,
out string outboundMessage,
ExecutionContext context)Get the
IConfiguration
Rootvar config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();And use it to reference AppSettings keys
var password = config["password"]
When debugging locally, it gets the settings from local.settings.json
under the "Values" keyword. When running in Azure, it gets the settings from the Application settings tab.
add a comment |
Note that for Azure Functions v2 this is no longer true.
The following is from Jon Gallant's blog:
For Azure Functions v2, the ConfigurationManager is not supported and you must use the ASP.NET Core Configuration system:
Include the following using statement:
using Microsoft.Extensions.Configuration;
Include the ExecutionContext as a parameter
public static void Run(InboundMessage inboundMessage,
TraceWriter log,
out string outboundMessage,
ExecutionContext context)Get the
IConfiguration
Rootvar config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();And use it to reference AppSettings keys
var password = config["password"]
When debugging locally, it gets the settings from local.settings.json
under the "Values" keyword. When running in Azure, it gets the settings from the Application settings tab.
Note that for Azure Functions v2 this is no longer true.
The following is from Jon Gallant's blog:
For Azure Functions v2, the ConfigurationManager is not supported and you must use the ASP.NET Core Configuration system:
Include the following using statement:
using Microsoft.Extensions.Configuration;
Include the ExecutionContext as a parameter
public static void Run(InboundMessage inboundMessage,
TraceWriter log,
out string outboundMessage,
ExecutionContext context)Get the
IConfiguration
Rootvar config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();And use it to reference AppSettings keys
var password = config["password"]
When debugging locally, it gets the settings from local.settings.json
under the "Values" keyword. When running in Azure, it gets the settings from the Application settings tab.
edited Nov 15 '18 at 3:20
KyleMit
59.2k37248412
59.2k37248412
answered Sep 18 '18 at 22:41
PitchmattPitchmatt
583158
583158
add a comment |
add a comment |
You can use System.Environment.GetEnvironmentVariable
like this:
var value = Environment.GetEnvironmentVariable("your_key_here")
This gets settings whenever you're working locally or on Azure.
add a comment |
You can use System.Environment.GetEnvironmentVariable
like this:
var value = Environment.GetEnvironmentVariable("your_key_here")
This gets settings whenever you're working locally or on Azure.
add a comment |
You can use System.Environment.GetEnvironmentVariable
like this:
var value = Environment.GetEnvironmentVariable("your_key_here")
This gets settings whenever you're working locally or on Azure.
You can use System.Environment.GetEnvironmentVariable
like this:
var value = Environment.GetEnvironmentVariable("your_key_here")
This gets settings whenever you're working locally or on Azure.
edited Nov 15 '18 at 3:28
KyleMit
59.2k37248412
59.2k37248412
answered Nov 6 '18 at 11:50
DSpiritDSpirit
12614
12614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43556311%2freading-settings-from-a-azure-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown