Azure应用程序设置未覆盖我的appsettings.json文件值 [英] Azure Application Settings not overriding my appsettings.json file values

查看:181
本文介绍了Azure应用程序设置未覆盖我的appsettings.json文件值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将来自我的appsettings.json文件的DefaultConnection添加到Azure的应用程序设置"中,但是Azure不会覆盖连接字符串.

I have tried adding DefaultConnection from my appsettings.json file to Azure's Application Settings but Azure will not override the connection string.

在任何文章或博客中,我都可以找到状态,我需要做的就是添加连接字符串名称(如在appsettings.json文件中所声明的那样),而Azure应该完成其余的工作(例如

Any article or blog I can find states that all I should need to do is add the connection string name as it states in the appsettings.json file and Azure should do the rest (e.g. https://tehremo.wordpress.com/2016/10/07/override-connection-strings-app-settings-in-asp-net-core-and-azure-app-service/) however when the application is published it is using my local connection string.

我的Startup.cs文件如下所示:

My Startup.cs file looks like the following:

注意:我正在使用VSTS连续交付进行发布,并带有部署Azure App Service"发布任务.

NOTE: I am publishing using VSTS continuous delivery with "Deploy Azure App Service" release task.

推荐答案

我只是遇到了类似的问题(问题是PostgreSQL连接字符串类型,我不得不将其更改为自定义),现在它对我有用,因此这些是碎片:

I just had a similar problem (the problem was with PostgreSQL connection string type, I had to change it to custom) and now it works for me, so these are the pieces:

  1. 这是我的appsettings.json文件.我在appsettings.Development.json中设置了"Psql"的值,但在appsettings.json中将其保留为空.
  2. 这些是在Azure门户中设置的设置.请注意,有两种方法可以覆盖连接字符串.
  3. 这是我的Startup.cs文件的一部分.请注意在Startup构造函数中如何应用设置的顺序以及在ConfigureServices方法中获取连接字符串的方式(GetConnectionString是标准扩展方法).
  1. This is my appsettings.json file. I have a value for 'Psql' set in my appsettings.Development.json, but in the appsettings.json it is left empty.
  2. These are the settings which are set in the Azure portal. Please note, that there are two ways to override the connection string.
  3. This is the part of my Startup.cs file. Pay attention to the order of how the settings are applied in the Startup constructor and the way I get the connection string in the ConfigureServices method (GetConnectionString is a standard extension method).


我在下面的评论中提供的其他信息:

Azure GUI(连接字符串,应用程序设置)在内部使用环境变量,因此appsettings.json将保持不变.

Azure GUI (Connection strings, Application settings) uses environment variables internally, so the appsettings.json will stay the same.

如果需要在VSTS发布活动期间覆盖 appsettings.json的值(在将其发布到Azure之前),请使用Colin的ALM Corner Build&可以使用释放工具.以下是指向 Colin的ALM Corner Build&的链接.发布工具教程.

If there is a need for an appsettings.json's value to be overwritten during VSTS release activity (before it will be published to Azure), Colin's ALM Corner Build & Release Tools can be used. Here are the links to Colin's ALM Corner Build & Release Tools and tutorial.

这篇关于Azure应用程序设置未覆盖我的appsettings.json文件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆