0
votes

I am new to Azure functions. I am developing an azure function using Visual Studio. I have referred a dll in my project that will handle the database related stuff. I am using database first approach. While developing, I added the connection string in my local.settings.json and it worked fine. Now, I am deploying it on azure portal and I had set the connection string in host.json assuming that it will serve as config file for deployment. The deployment succeeded and connection string is there but for some reason its not picking up from host.json. I tried setting the connection string in app settings, but then I received 'keyword not supported metadata' error.

Here is how I am setting in host.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true"
  },
  "ConnectionStrings": {
    "HMISEntities" : {
      "ConnectionString": "metadata=res://*/EFModel.MyModel.csdl|res://*/EFModel.MyModel.ssdl|res://*/EFModel.MyModel.msl;provider=System.Data.SqlClient;provider connection string='data source=server.data.source;initial catalog=test_db;persist security info=True;user id=user;password=value;MultipleActiveResultSets=True;App=EntityFramework'",
      "ProviderName": "System.Data.EntityClient"
    }
  }
}

Any Help is appriciated.

1

1 Answers

1
votes

host.json file is not intended to store the application settings, it's for the configuration of Azure Functions host. Leave it empty ({}) for now.

The connection strings should be defined in Function App application settings, see this answer for a walkthrough related to Entity Framework.