Database connection in windows azure

+1 vote
asked Aug 6, 2014 by donaldcb

I have an N-Tier MVC4 project connected to an SQL server database. The MVC4 project was created using the MVC internet application template in VS. I'm trying to deploy this project to windows azure. The website was added to azure with no problems the database was added with no problem as well.

When i browse to my website it's there but when i try to do actions related to the DB such as register/login/view a certain list i get the error:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections."

my development connection string is:

<add name="CarRentalDataBaseEntities" connectionString="metadata=res://*/CarRentalDataBase.csdl|res://*/CarRentalDataBase.ssdl|res://*/CarRentalDataBase.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=CONSTANTINE-PC\SQLEXPRESS;initial catalog=CarRentalDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

my production connection string is:

<add name="CarRentalDataBaseEntities" connectionString="metadata=res://*/CarRentalDataBase.csdl|res://*/CarRentalDataBase.ssdl|res://*/CarRentalDataBase.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=tcp:ptuwjgqh7p.database.windows.net,1433;Database=CarRentalDataBase;User ID=XXXX;Password=XXXX;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

when i run the project in VS it works fine with no problems, which means that remote connections allowed to the database.

Seems that there something wrong with the connection between the website and the database in azure but i dont know what.

please advise what can i check in order to find the problem.

Thank you.

EDIT:

I just created draft MVC website that has a connection to a database and it worked - There is a connection to the DB in azure. The difference was that this website wasnt N-Tier designed meaning it didnt have a business logic project.

In my original website (the one that i still didnt manage to connect to a DB) there is a business logic project and the database edmx file is on that project. The publish to azure that i did was to the MVC website project that has a reference to the business logic(which has the edmx DB file).

Any suggestions on the latest findings?

Thank you.

2 Answers

0 votes
answered Aug 6, 2014 by steve-newton

On the firewall section of the portal for that server have you turned on access to Azure Services?

+2 votes
answered Mar 2, 2015 by donaldcb

Eventually I found that in the publish menu, in Settings under databases, from some reason, the connection string did not match the connection string in AppConfig and Azure management portal all though I performed a Clean-Rebuild on the entire solution before publishing.. Anyway mystery solved after almost a year!

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...