-5

I have written connection string in appsettings.json for .Net core project. My connection string is :

 "ConnectionStrings": {
"OT_DB_Connection": "Data Source=108.***.**.**;Initial Catalog=O*******s;User ID=O*******s;Password=O*********$"

},

I am accessing this connection string in startup.cs file as shown below.

options.UseSqlServer(Configuration.GetConnectionString("OT_DB_Connection"));

Now i deployed this website on azure and i have separate database on azure and i want that my website will to connect to azure database at runtime by overriding the local connection string.

Please suggest how i can achieve this.

Thanks

2
  • Have you tried adding the connection string to the AppSettings on your Azure App Service? A simple Google found this web page Commented Aug 28, 2018 at 5:16
  • I already go through this link. But it does'nt help. Commented Aug 28, 2018 at 5:24

1 Answer 1

0

You may create application setting entry (in Azure) with name ConnectionStrings:OT_DB_Connection and read it as

Configuration["ConnectionStrings:OT_DB_Connection"]

This code will read both and you appsettings value for local development, and overrided value in Azure App Service.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.