Azure Functions - default query parameters value for testing

Oliver Rodrigues 1 Reputation point MVP
2022-06-27T10:31:14.24+00:00

Hi, I have an Azure Function and I want to set default query string parameters for testing via Azure Portal.

Is there a way to setup this?
thanks
Oliver

215383-image.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,908 questions
{count} votes

1 answer

Sort by: Most helpful
  1. sadomovalex 3,636 Reputation points
    2022-06-28T13:39:45.21+00:00

    it is probably possible to provision default query string params via ARM template - try to set parameters manually via portal UI like you did and export function app's ARM template - it may contain these values there. It is also possible to set default params by changing C# code:

    string foo = req.GetQueryNameValuePairs().FirstOrDefault(q => string.Compare(q.Key, "foo", true) == 0).Value;  
    if (string.IsNullOrEmpty(foo))  
    {  
        foo = Environment.GetEnvironmentVariable("foo", EnvironmentVariableTarget.Process);  
    }  
    

    In this example if param is missing in query string it will be read from app settings (can be set from Azure portal: Function app > Configuration > Application Settings).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.