how to override local connection string with azure connection string

前端 未结 1 475
梦毁少年i
梦毁少年i 2021-01-15 01:20

I am using appsettings.json in .Net core project for connection string. My connection string is :

  \"ConnectionStrings\": {
    \"OT_DB_Connection\": \"Data         


        
相关标签:
1条回答
  • 2021-01-15 01:54

    You should read the following article:

    Multiple Environment Configuration Files in ASP.NET Core

    You can have multiple appSettings e.g. 1 for you local environment and 1 for Azure etc. When you publish your app to Azure, you can add an application setting called ASPNETCORE_ENVIRONMENT and add a value that maps to your environment for your app to pick up the correct configuration. If you have an appSettings.Azure.json file you can set ASPNETCORE_ENVIRONMENT to Azure and it will use that configuration file.

    If you do not want to take this approach, you can also override the connection string directly in Azure as show in the picture below. This is accessible under your app service -> Application Settings -> Connection Strings. You will want to override OT_DB_Connection.

    0 讨论(0)
提交回复
热议问题