Accessing Storage account programmatically

Viewed 172

In my c# solution I am accessing my storage account through a connection string.

Issue -

  1. right now the cloud solution is in dev
  2. when the solution will be promoted to qa\prod - that string will change. Is there an alternative better way to manage this i.e to avoid code change throughout this promotion\env changes.

one way i was thinking was use of vault .. any other idea ? Please guide. Thanks.

3 Answers

I assume you are talking about a Web App where you are using Storage Account Connection string.

Usually, it's a good practice to have your connection string in a config file (web.config for .Net Framework and appsettings.json for .net core).

However, though these work in Azure App Service, they are kind of deprecated. So, you need to create App Settings / Connection Strings (go to Configuration blade in App Service) for your Storage Connection.

You didn't mention what kind of application you have in your solution. Based on the type you can use the below appropriate technique to access the App Settings/ connection strings.

  1. .Net Framework - ConfigurationManager namespace
  2. .Net Core - IConfiguration

Thanks, Praveen

I see you are using Azure DevOps.

The old "config transforms" of yesteryear are arguably deprecated now with continuous deployment (CD). Essentially your connection string represents a "secret" or at least something that is stage-dependent and generally stage dependant items should not be part of the source code's repository. Sure you can put them in but its much easier to manage in CD.

Instead, whoever is defining the CD pipeline defines it in other means such as DevOps CD variables and injects it into your config after the code has been compiled but just prior to deployment

More

Related