18.5 C
Dubai
Monday, February 6, 2023

Application Settings in Azure App Service and Static Web Apps

Utilizing Connection Strings in PHP/Nodejs/Next Js for App Service – The source code is Deployed in UAT and Production; both have different connection strings, for example. So that pipeline is deployed smoothly without any manual changes utilizing DevOps variables. Let’s take an example of using the same codebase and applying it on UAT and Prod. My UAT will apply UAT DB Connection String, and Production will apply the Production Connection string for the same Codebase.

As you can see, I am adding this MYSQLCONNSTR_ suffix for my connection string as its MYSQL; you can update the suffix accordingly. Application settings don’t need any suffixes. Also, you can retrieve secrets from the key vault to run them in the App service without exposing them.

At runtime, connection strings are available as environment variables, prefixed with the following connection types:

  • SQLServer: SQLCONNSTR_
  • MySQL: MYSQLCONNSTR_
  • SQLAzure: SQLAZURECONNSTR_
  • Custom: CUSTOMCONNSTR_
  • PostgreSQL: POSTGRESQLCONNSTR_

For Retrieving from Key Vault, you need to specific the URI, and it will retrieve the latest version if the below format is used.

@Microsoft.KeyVault(SecretUri=https://az-az-pr-ause-kv.vault.azure.net/secrets/accesstoken/)



Utilizing Application Settings inside JSON in Azure Static Web Apps

To Retrieve from Azure Key Vault –

@Microsoft.KeyVault(SecretUri=https://az-az-pr-ause-kv.vault.azure.net/secrets/accesstoken/)

You can see Key vault Reference has been added.

System Assigned Identity is Turned On. To talk with key vault

Key Vault Reference

So that secret is not exposed even to the App Service Administrator for example.

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Specialized in Microsoft Azure - Office 365 / Microsoft Exchange; conducted numerous projects worldwide in designing, supporting, and implementing messaging and virtualization infrastructure for medium-sized and large enterprises. Further, I am a Cloud Architect and Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?