23 C
Dubai
Monday, December 23, 2024

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
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a 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?