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.
-
You mean programatically? Because you can set the conn strings in the Management Portal– Maria Ines ParnisariJan 14, 2015 at 13:37
-
2I can't finish to understand, why your two applications can't access to same database ¿?, this is a normal escenario.– Juan Ruiz de CastillaJan 14, 2015 at 17:11
1 Answer
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.