Questions on Azure functions and Visual Studio / C#

Dave Gray 471 Reputation points
2022-01-05T12:03:37.08+00:00

Hi,

First set of Azure function apps so please bear with. :-)

Is it correct to add my SQL database connection string in the Azure function app configuration for production and in local.settings.json for my development/debugging?
If so then is this the correct format in that file?

How do I read this value and also my other values (Limit, offset etc) which used to be <appSettings> in the original Console app?
How do I read these in my C# code? I have read that I need to use Environment.GetEnvironmentVariable, however this returns null

 string pagerduty = Environment.GetEnvironmentVariable("PagerDuty");  
 log.LogInformation(pagerduty);  

Is there a way to keep the function app configuration (in portal) and the local settings in sync?

At present I only have two Azure functions in my project which is defined as the startup project. I have set a breakpoint in each
but only the first function (alphabetically) is hit, how can I test the second function (GetTeams)?

Here are some screenshots that will help explain better.
162478-qa1.png

162515-qa2.png

162542-qa3.png

162450-qa4.png

162497-qa5.png

Thanks

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
2,584 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,952 questions
1 vote

2 additional answers

Sort by: Most helpful
  1. Dave Gray 471 Reputation points
    2022-01-05T17:51:41.357+00:00

    Does anyone know the answer to this

    At present I only have two Azure functions in my project which is defined as the startup project. I have set a breakpoint in each
    but only the first function (alphabetically) is hit, how can I test the second function (GetTeams)?

    Thanks


  2. Lohith GN 501 Reputation points
    2022-01-11T09:27:44.413+00:00

    Hi. I created a video which explains how to read application settings in your function app. Do have a look at the video here: https://dotnetrumbles.wordpress.com/2022/01/11/reading-application-settings-in-azure-function-application/

    No comments