Deployment Variables for Azure .Net Core Web App

问题内容:

I am having trouble getting the desired result from my CI/CD pipeline when deploying a .Net Core 2.0 web app to Azure.

As it stands everything is working when I deploy to my test environment. I have added a setting – ConnectionString:Main – to link to the correct database in the AppSettings section for the development app in the Azure portal.

I now want to deploy to my production environment. The issue is that there are two production databases, only one of which is “live” any any one time. What I would like to do is create two release definitions, one for each database and then have the ability to deploy using either one.

Is it possible to simply add a release variable that will override the local connection string in AppSettings.json as it was with previous .Net versions or is a more complex solution required?

问题评论:

    
Can you first elaborate on why you have two live production databases? Isn’t this an issue that can be solved with deployment slots?
    
There are two production databases as the system requires a daily update from a legacy system which is a multi hour process and there needs to be availability to users while the update takes place. The application should be pointed at the most recently updated database following the update, the data then slowly becomes out of date until the next update 24 hours later when the connection is switched (not ideal but a necessity until the legacy system is replaced). I think you might be right that deployment slots could be the way to go, I hadn’t realized that auto-swapping was a feature.
– SBFrancies
32 mins ago

答案:

答案1:

When using ASP.NET Core apps on Azure, the recommended way to store secrets is by using Azure Key Vault. This makes sure that no credentials are stored in version control or in VSTS.

If you really want to update a configuration value during deployment, you can tokenize your parameters and replace them during deployment. You can use this marketplace task for that. Managing Config for .NET Core Web App Deployments with Tokenizer and ReplaceTokens Tasks describes how to use these tasks.

答案评论:

原文地址:

https://stackoverflow.com/questions/47749725/deployment-variables-for-azure-net-core-web-app

Add a Comment