Search code examples
azureconnection-stringazure-functions

Azure Function - The ConnectionString property has not been initialized


I developed a Azure Function in Visual Studio and it works when published in Azure (since a year ago).

Now I made a template from that Azure Function, in Visual Studio, and I changed some details, but it's mainly the same. When I test it locally, it works fine.

But when I publish it in Azure and try to test it, I get this error:

The ConnectionString property has not been initialized

I usually write the Connection String in the Application Settings (and it works well for the older Azure functions).

Here is how the function gets the value of the Connection String:

var repo = new GranularRepository(ConfigurationManager.AppSettings["BoConnectionString"]);

I also tried:

var repo = new AvgDeliveryTime_GranularRepository(Environment.GetEnvironmentVariable("BodbConnectionString"));

Solution

  • I fixed it by creating a new Azure Function project.

    So my conclusion is that making a template from another Azure Function and using that as the new project, in Visual Studio, is creating issues.