mardi 4 août 2015

Connect to SQL database when the application and database are on the same Azure VM

I have an ASP.NET MVC 5 application published on a Virtual Machine on Azure. I also have a database on the same Virtual Machine.

Application works fine, however it cannot connect to the database.

I have these information from Azure:

  • Domain Name = "something.cloudapp.net"
  • Host Name = "sampleName"
  • Virtual IP Address = "137.135.123.149"
  • Private IP Address = "10.0.0.4"

This is my connection string:

<add name="RepositoryDbConnectionString"
 connectionString="Data Source=137.135.123.149,1433; Database=Codex-Repo-Cloud; User Id=myUser; Password=mypass; MultipleActiveResultSets=True;"
 providerName="System.Data.SqlClient" />

I also have tried these connection strings, none worked so far:

connectionString="Data Source=something.cloudapp.net; Database=Codex-Repo-Cloud; User Id=myUser; Password=mypass; MultipleActiveResultSets=True;"

connectionString="Data Source=10.0.0.4; Database=Codex-Repo-Cloud; User Id=myUser; Password=mypass; MultipleActiveResultSets=True;"

NOTE With the first connection string, I can remotely connect to the database in Visual Studio Server Explorer and I can actually modify the data.

Question When the SQL Database and the Web application are both on the same Azure Virtual Machine, how can I connect to the database within my application. Is there any settings, or is it just my connection string?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire