2

I have two web site that uses one database in azure. i want to be able to use one connection string( a database) to connection to both site. Any help will be appericiated.

2
  • You mean programatically? Because you can set the conn strings in the Management Portal Jan 14, 2015 at 13:37
  • 2
    I can't finish to understand, why your two applications can't access to same database ¿?, this is a normal escenario. Jan 14, 2015 at 17:11

1 Answer 1

3

Go to the Dashboard of the website in Azure Portal for which you want to use your database. Click on Configure. Scroll Down until you see "Connection Strings" and add the same connection string that you added for your 1st website and give it a unique name. Now simply you can access that connection string using the name provided there through the following code:

connString = 
Environment.GetEnvironmentVariable("PREFIX_myConnStringName");

The PREFIX can have one of the following values depending on what you specified on the Portal:

  • SQL Server: SQLCONNSTR
  • MySQL: MYSQLCONNSTR
  • SQL Database: SQLAZURECONNSTR
  • Custom: CUSTOMCONNSTR
  • SQL Azure: SQLAZURECONNSTR

and the myConnStringName would be the name you wrote in the Portal as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.