Set Environment Variables from code for a Azure Function.

Lalith 161 Reputation points
2022-05-12T05:53:18.537+00:00

Hello, we have azure function with same code deployed into multiple environments or multiple instances. we set the variables locally in local.settings.json and later edit them from the azure portal in the configuration tab. Now, I want to set these variables from the code just like how we do it for a web api or a web app using appsettings.development.json, appsettings.staging.json etc. Is this possible with azure functions?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,190 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.
11,104 questions
0 comments No comments
{count} votes

Accepted answer
  1. Magnus Oxenwaldt 166 Reputation points
    2022-05-12T06:38:31.107+00:00

    Hi
    I would recommend using Azure Devops for build and release. Through the release pipeline you can set those variables and use the transform action which would adjust the variables depending on which stage environment you are targeting.

    Mox


0 additional answers

Sort by: Most helpful

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.