Friday Fact: Settings present on local.settings.json file inside Azure Functions project are not deployed with Visual Studio

When creating an Azure Function, it’s crucial for security reasons to avoid directly embedding connection strings and other sensitive information in the code.

In our development environment, a common best practice is to store such important information in the local.settings.json file:

This image has an empty alt attribute; its file name is Screenshot_1563.png

Of course, we can improve even more by also binding Key Vault. If your local tests go as expected and the code is correct, the next step you will have is to deploy it into your Azure Subscription. This brings us to today’s Friday Fact!

However, once you upload the Azure Function to the Function App in the Azure Portal and attempt to use it, for example, in a Logic App, you may notice a discrepancy between the local test and the Logic App environment. The challenge doesn’t lie in integrating the Azure Function into a Logic App but rather in the loss of configurations.

Here’s the catch: the local.settings.json file doesn’t get deployed directly with Visual Studio (manual deployment) in a way that carries along your connection strings and other critical information. As a result, you’ll need to configure these details after deployment in the Function App, ensuring they match the key-value pairs from your local.settings.json file. – Of course, if you implement CI/CD, this can easily be accomplished inside DevOps pipelines!

Once this configuration step is complete, your Azure Function and the flow within the Logic App should run smoothly. It’s essential to be mindful of this potential loss of configuration, as overlooking it can lead to issues like attempting to troubleshoot the Azure Function locally and deploying without success.

Within the Function App, you can smoothly configure sensitive information by navigating to the Environment Variables section under Settings in the left menu.

This is the key spot where you can input the necessary details, ensuring a seamless operation for your Azure Function. By managing these environment variables effectively, you’ll have your Azure Function up and running.

Hope you have enjoyed this Friday Fact, and we will see you in the next one!

To lazy to read? We’ve got you covered! Check out our video version of this content!

Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can help us buy a Star Wars Lego for Sandro’s son! 

Author: Luis Rigueira

Luis Rigueira is a Enterprise Integration Consultant at DevScope

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to Top