locked
Deploy simple EF Model First Website to Azure RRS feed

  • Question

  • Hi,

    I'm a beginner at web programming, so as a project I've created a very simple website that I've been running locally on my machine.  I'm using a local SQL database that I created using an EF data model.

    For the next step I wanted to try to publish the project to a server so I could look at it from other machines (like my phone), so I published the website and database to Azure.  However, when I load the website there it fails to see the Azure database, and it looks like it's still trying to connect to my local db.  I would assume I have to change the webconfig connection string to point to it, but none of the offered connection strings on the Azure version of SQL look right.  I'm basically lost as to how to get the cloud hosted version of the website to look at the cloud db (I'd like to keep the local version looking at the local db if possible).  Most of the help I can find has a person starting by creating an Azure db and using that to begin with instead of porting an existing one.  Can anyone point me in a direction?

    Thank you,

    Nathan

    Tuesday, July 17, 2012 9:58 PM

Answers

  • Hello B,

    Thanks for the suggestion.  I just now figured out that the problem with my connection string was that the Integrated Security setting was set to true instead of false.  Now I can continue exploring Rajesh's suggestion above of using the cscfg files.  


    Nathan

    • Marked as answer by Arwind - MSFT Monday, July 23, 2012 6:40 AM
    Sunday, July 22, 2012 8:37 PM

All replies

  • If you are using Azure web role and Azure SQL Database on cloud, Here is one of the ways you can implement this.

    You can find two versions of cscfg files, local and cloud. You can put your local and cloud connection strings into these files and update your code to build db connection programmatically by reading connection string information from Azure configuration rather than web.config (refer here).

    HTH.


    Please mark it as answer by clicking on "Propose As Answer", if it helps. My Blog : http://dotnetizen.blogspot.com

    Tuesday, July 17, 2012 10:15 PM
  • Hi Rajesh,

    That seems like a useful answer for connecting to different dbs in different environments.  However, as I mentioned above, I'm still unable to simply use a remote db at all, as the connection strings provided by Azure don't seem to cut it.  I have finally figured out how to add the remote db so that server explorer sees it, and I seem to have just gotten it to accept the Azure sql db as the entity provider.  But currently actual data pull is failing on open.  I will keep messing with it, and when/if I get it to the point of having two working connection strings, I will then try your idea and come back and report on it.

    Thanks again for the suggestion,

    Nathan

    Wednesday, July 18, 2012 6:50 AM
  • Nathan,

    If the connection strings are failing, the first place to check is the SQL Azure Firewall Rules.

    Ensure that it allows both Azure connections & connections to your local IP range. http://msdn.microsoft.com/en-us/library/windowsazure/ee621783.aspx

    To test if the firewall is the issue, you could also try connecting via creating a data connection in VS or connecting through SQL Management Studio.

    • Proposed as answer by B Blanchard Wednesday, July 18, 2012 9:41 PM
    Wednesday, July 18, 2012 9:22 PM
  • Hello B,

    Thanks for the suggestion.  I just now figured out that the problem with my connection string was that the Integrated Security setting was set to true instead of false.  Now I can continue exploring Rajesh's suggestion above of using the cscfg files.  


    Nathan

    • Marked as answer by Arwind - MSFT Monday, July 23, 2012 6:40 AM
    Sunday, July 22, 2012 8:37 PM