logo
down
shadow

How can I change a setting in appsettings.json after auto-deploy?


How can I change a setting in appsettings.json after auto-deploy?

By : Gtwogtwo Gtwogtwo
Date : November 20 2020, 11:01 PM
I wish this help you As I know we can config token in App Settings on the Azure port. I do a test on this, it works successfully, the following is my detail steps.
Create an Asp.net core Application. Add [AppSettings] section in the appsetting.json file (Token vaule: mysecretkey). Add a public class AppSettings.cs under the created project. Add the code services.Configure(Configuration.GetSection("AppSettings")) in the function ConfigureService function in the Startup.cs file (For .net Core 1.0).
code :


Share : facebook icon twitter icon
appsettings.json in Deploy folder not updated to show production connection strings

appsettings.json in Deploy folder not updated to show production connection strings


By : Helmi Ruza
Date : March 29 2020, 07:55 AM
I wish did fix the issue. appsettings.Production.json should be published as a separate file, it does not replace content of appsettings.json during publishing.
You should add appsettings.Production.json into publishOptions section in project.json file:
code :
"publishOptions": {
  "include": [
    "appsettings.json",
    "appsettings.Production.json",
    ...
  ]
},
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
VSTS deploy: Unable to replace variables in appsettings.json

VSTS deploy: Unable to replace variables in appsettings.json


By : Chris enix
Date : March 29 2020, 07:55 AM
may help you . I have a fairly standard setup for an ASP.NET Core application - source control on GitHub with the live application hosted on Azure, with master branch changes triggering CI builds on VSTS. The DB connection string is in appsettings.json, normally pointing at a localdb instance. For deploying to Azure, I want it to point to an Azure SQL DB (which I had neglected to set up during the first publish). The app service itself was set up on Azure as an app service without a DB - in other words, I shouldn't have done this just after waking up. However, both the app service and DB are linked to the same resource group. , My initial thoughts are that you've misspelt the JSON config name
code :
Service:'BlackscarsSheetsSwtor' 2017-07-09T08:47:07.6978989Z ##[error]Error: NO JSON file matched with specific pattern: appsettings,json.
VSTS Deploy IIS App winrm and change appsettings.json

VSTS Deploy IIS App winrm and change appsettings.json


By : Paul G
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You don’t need to change appsettings.json. The core project can retrieve data from appsettings.[environment].json file per to ASPNETCORE_ENVIRONMENT environment variable.
For example:
code :
  public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();
            Configuration = builder.Build();
        }
add-migration can not read the connection string from the file appsettings.json because of the path to appsettings.json

add-migration can not read the connection string from the file appsettings.json because of the path to appsettings.json


By : Shawn Kong
Date : March 29 2020, 07:55 AM
seems to work fine You might want to override OnConfiguring method in your DbContext. Here is an example I'm using. It will work whenever you are using command line or windows service:
code :
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    if (optionsBuilder.IsConfigured)
    {
        base.OnConfiguring(optionsBuilder);
        return;
    }

    string pathToContentRoot = Directory.GetCurrentDirectory();
    string json = Path.Combine(pathToContentRoot, "appsettings.json");

    if (!File.Exists(json))
    {
        string pathToExe = Process.GetCurrentProcess().MainModule.FileName;
        pathToContentRoot = Path.GetDirectoryName(pathToExe);
    }

    IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
        .SetBasePath(pathToContentRoot)
        .AddJsonFile("appsettings.json");

    IConfiguration configuration = configurationBuilder.Build();

    optionsBuilder.UseSqlServer(configuration.GetConnectionString("RecipeDatabase"));

    base.OnConfiguring(optionsBuilder);
}
ASP.NET Core deploy only applicable appsettings.{EnvironmentName}.json

ASP.NET Core deploy only applicable appsettings.{EnvironmentName}.json


By : user3053344
Date : March 29 2020, 07:55 AM
I wish did fix the issue. No, it's not possible. ASP.NET Core is not like ASP.NET. In ASP.NET, you literally published for the environment; if you wanted to switch to a different environment, you'd need to republish. ASP.NET Core is published for all environments. The same published app can be picked up and moved to any environment, without change. The actual environment is generally externalized, such as via and environment variable, and can be changed on a whim, without requiring new code to be deployed. This is actually a feature of ASP.NET Core.
Now, the way you're handling the environment variable does somewhat make it dependent on the publish, but that's just modifying the web.config, which itself only has meaning when deploying to IIS. ASP.NET Core itself doesn't care about or use web.config, and honestly doesn't even care about or use release configurations.
Related Posts Related Posts :
  • Trying to keep user from using an old password for their new one
  • How do you give components a name in react?
  • Only last radio button control in list being set as checked
  • DateTime.Kind set to unspecified, not UTC, upon loading from database
  • Server Error in '/' Application (Configuration Error)
  • Find an IP change during user's navigation on website
  • HTTPS Redirect not working quite right
  • Setting up ASP.NET in Plesk Web Host Edition
  • Access Web.config settings in Asp.Net Core App?
  • Converting from framework to core
  • asp.net mvc 5 - system doesn't find a view that exists
  • Can I add a THEAD and other columns to a checkboxlist
  • I can't find Global.asax, how to handle Application_Error in webform 4.5 in startup class?
  • Web app with REST api data layer
  • ASP.NET Razor: Send variable as parameter
  • Click event cannot be fired on buttons created dynamically in VB.Net ASP.Net
  • TypeError: Cannot read property of Selector-Matcher
  • I am not able to find master page when i am trying to create one
  • ASP.NET Web API site virtual directory is accessible, but controller actions return HTTP 503
  • Trouble Returning XML to 2D Array not Looping to next Element
  • How can I disable my global.asax Application_Error sub when running on localhost?
  • Run app and launch browser from command line
  • Write output from Gulp task into .Masterpage/.aspx page
  • Object giving null error
  • Not able to create "Asp.Net Core Web application" in Visual Studio 2017
  • Bootstrap Dropdown with MVC - Keep last selected value displayed
  • Bootstrap datetimepicker - set date time server side
  • ASP.NET Session Management DeleteExpiredSessions Looks silly?
  • Asp.Net MVC Authentication Cookie Conflict
  • how to retrieve facebook user info ASP.NET WEB API 2
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com