How to update a value of Key in appsettings.json file in azure devops pipeline

Sathish Kumar Karikalan 81 Reputation points
2023-07-07T10:38:00.25+00:00

I have below default configuration Appsettings.json file, I need to update the value of InstrumentationKey during CD process, is there any powershell script to replace the InstrumentationKey default value with the new value.

"ApplicationInsights": {

    "InstrumentationKey": "xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbb",

    "RoleName": "API_Localhost"
}
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ben Gimblett 4,560 Reputation points Microsoft Employee
    2023-07-10T09:27:47.6566667+00:00

    Hi
    Use App Service App Settings - the underscore replaces ":" for the hierarchy. The following snip (below) shows both the legacy instrumentation key and the newer connection string config .

    App Settings override the config file values and are also exposed as Env Vars at runtime.

    Azure Dev Ops (ADO) supports tasks for App service - and more generically there's a PS1 and CLI commands for setting app settings which can be used in a pipeline. CLI example here.

    App settings also help a lot if you want to use App Service slots.
    User's image


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.