How to change a parameter in appsettings.json after automatic deployment?

I have an ASP.NET Core application on which Github with automatic deployment is installed. But since this is an open repo, I obviously do not want to download my correct configuration file.

I would like to replace some lines in appsettings.json after github auto-deployment.

"AppSettings": {
    "Token": "my super duper secret token"
}

How can I change my super duper secret tokento a real token after deploying github in Azure?

+6
source share
3 answers

As I know, we can configure the token in the application settings on the Azure port. I am doing a test on this, it works successfully, my next steps.

  • Create the main Asp.net application.
  • [AppSettings] appsetting.json(Token vaule: mysecretkey). enter image description here
  • AppSettings.cs . enter image description here
  • services.Configure<AppSettings>(Configuration.GetSection("AppSettings")) ConfigureService Startup.cs( .net Core 1.0).

. RC1 RC2. services.Configure<AppSettings>(Configuration.GetSection("AppSettings")) . , ConfigureServices Startup.cs:     services.Configure<AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));

enter image description here 5. HomeController.cs. enter image description here

  1. WebApp Azure Portal.
  2. [AppSettings: Token] Azure Portal. enter image description here
  3. WebApp about, , , . enter image description here
+15

, - Azure, / . appsettings.json . . / azure, . asp.net " " . /.

, , .AddEnvironmentVariables() .

+3

( → → (Preview)). , . , , - ( web.config - ). Kudu (Advanced Tools), , Visual Studio .

- . asp.net .

Typically, this is a way to download secrets from a secure data warehouse and override them using environment variables in production (can be installed in an azure web application).

0
source

Source: https://habr.com/ru/post/1658624/


All Articles