Just as all Azure Web Apps need configuration values, most applications also need to have database Connection String values configured. With Azure Web Apps the Connection Strings are stored/retrieved in a very similar fashion as Azure Web App Application Settings. Connection Strings are also Key / Value pairs of String values, but are separated out into their own section.

Connection Strings are typically used to store the connection information for one or more databases the Web App needs to connect to for storing and retrieving data. The Connection String types supported are SQL Database, SQL Server, MySQL and Custom. Most often the Connection Strings used will be for some kind of SQL RDMS, but the Custom type allows for an additional Connection String to be configured any other type of database connection necessary.

As with Application Settings, the Connection Strings are accessed as normal from .NET code and the values will come from what is set within the Azure Management Portal. In other development environments (Node.js, Java, PHP, Python) the Connection Strings are exposed to code as Environment Variables. Additionally, the Connection Strings are editable within the Azure Management Portal, but are read-only when access through code.

Connection String within Azure Management Portal

Managing the Connection Strings for an Azure Web App is performed through the Azure Management Portal.

Here are the necessary steps for locating and accessing the Connection Strings for an Azure Web App within the portal:

  1. Open the Azure Management Portal via https://portal.azure.com
  2. Navigate to the Web App within the portal.
  3. Under “All settings” open up the “Application settings” pane
  4. Scroll down to the “Connection strings” section


Connection Strings from .NET

Retrieving the Connection Strings for the Azure Web App is performed from .NET using the ConfigurationManager class in a very similar fashion as how Application Settings are retrieved.

Here’s an example of retrieving a Connection String from C# code:

using System.Configuration;

var key = "MyDBConnString";
string value = ConfigurationManager.ConnectionStrings[key]

Connection Strings from Node.js

In Node.js the Azure Web App Connection Strings are exposed as Environment Variables. Accessing the Connection Strings through the Environment Variables is exactly like accessing Application Settings, but with a different string prefixing the Connection String key name.

Here are the Connection String Environment Variable key name prefixes:

  • SQL Database prefix is “SQLAZURECONNSTR_”
  • SQL Server prefix is “SQLCONNSTR_”
  • MySQL prefix is “MYSQLCONNSTR_”
  • Custom prefix is “CUSTOMCONNSTR_”

Here’s an example of retrieving a Connection String from Javascript running on Node.js:

var value = process.env.SQLCONNSTR_MyDBConnString;

Connection Strings from Java

Azure Web App Connection Strings are exposed to Java code as Environment Variables. These are accessed in the same method as Application Settings except with different string prefixes on the Connection String key names.

Here are the Connection String Environment Variable key name prefixes:

  • SQL Database prefix is “SQLAZURECONNSTR_”
  • SQL Server prefix is “SQLCONNSTR_”
  • MySQL prefix is “MYSQLCONNSTR_”
  • Custom prefix is “CUSTOMCONNSTR_”

Here’s an example of retrieving a Connection String from Java code:

String value = System.getenv("SQLCONNSTR_MyDBConnString");

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has nearly 20 years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.


  1. […] feature of Azure Web Apps that helps with this is the ability to override application settings and connection strings from within the Azure Portal. This way you could allow your developers or infrastructure admins to […]


  2. There is a typo. Custom prefix is not “CUSTOM_CONNSTR_” but “CUSTOMCONNSTR_”


    1. Chris Pietschmann January 28, 2018 at 6:04 pm

      Oops, thanks! 🙂


  3. Hi Chris!

    Do you know if the Connection Strings are encrypted at rest inside the Azure Management Portal?


    1. Chris Pietschmann March 11, 2018 at 10:00 pm

      That I do not know. I haven’t seen any mention of it in documentation. What’s your use case where you need to have that done?


  4. Hi Chris, I am trying to connect to azure table and using my local.settings.json file to define the connection string as follows

    “IsEncrypted”: false,
    “Values”: {
    “AzureWebJobsStorage”: “UseDevelopmentStorage=true”,
    “AzureWebJobsDashboard”: “”,

    and reading the connection string in my java code which is spring boot application

    storageAccount = CloudStorageAccount.parse(System.getenv(“storageConnectionString”));

    all the time I am getting storageAccount is null. Please help me how can I fix this issue


    1. Chris Pietschmann December 17, 2018 at 10:18 pm

      You’ll want to name your connection string “storageConnectionString” within the local.settings.json file. Then you’ll be able to access the “SQLCONNSTR_storageConnectionString” environment variable from code. You just have them swapped in the snippets you’ve shared.


  5. Hi Chris,
    Hey we have Postgres SQL DB created and we want to access the connection string within the Jave webapp we are going to deploy within the Azure environment. Do you think we will have to define a Connection String (wtithin the Application Settings of the Web-App in Azure Portal) variable (“CUSTOMCONNSTR_outVariableName”) and then use it within the Java code to connect to the DB? sorry if this sounds basic but I am new to Java side of things for connecting the Azure Postgres SQL DB. Thank you.


    1. Chris Pietschmann April 16, 2019 at 2:49 pm

      Yes you could add it to application settings in the Azure Web App and then get it from Java via the environment variable.


      1. Thank you Chris, just wanted to confirm that I should be defining the variable as this:–> “CUSTOMCONNSTR_outVariableName” is that correct? My database is PostgresSQL on Azure.

      2. Chris Pietschmann April 24, 2019 at 9:17 am

        Just name it “outVariableName” and it will be made available as an environment variable named “CUSTOMCONNSTR_outVariableName”.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.