Entity Framework on Azure function (Connectionstring problem)

Akarapol Prompiriyapong 6 Reputation points

I want to insert or update on Azure function by Entity Framework.

I already created Azure function and ADO .NET from my SQL database. I inserted ConnectionString and ProviderName from ADO .NET to local.setting.json in Azure function.

When I use model entities from ADO .NET Azure function the system will show the message below.

Please suggest to me.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,184 questions
Microsoft Technologies based on the .NET software framework.
3,323 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
553 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,411 Reputation points

    @Akarapol Prompiriyapong ,

    Thanks for reaching out to Q&A.

    The connection string should be configured under the "Connection Strings" section (underlined in below image) in the Configuration blade. After publishing, you need to make sure to set the appropriate application setting for "SqlConnectionString" with the production entity connection string. I would also suggest you to look into this article for using entity framework in Azure functions.


    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

  2. wsiang 1 Reputation point


    Please try to put your connection string in local.settings.json as below:


    And then you can get the conn string to add it into the db context in your function's startup.cs

    public class Startup : FunctionsStartup  
            public override void Configure(IFunctionsHostBuilder builder)  
                FunctionsHostBuilderContext context = builder.GetContext();    
                string connString = context.Configuration.GetConnectionString("DataEntities");  

    Hope this could help you.