Creating an On Premise Database and MVC Web Application and Migrating to Windows Azure and SQL Azure-Step 6 of 10

Previous Posts that you should review

bullet

Step 1
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/12/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-1-of-10.aspx

bullet

Step 2
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/11/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure.aspx

bullet

Step 3
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/27/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-3-of-10.aspx

bullet

Step 4
hyperlink3

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/28/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-4-of-10.aspx

bullet

Step 5
hyperlink

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/28/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-5-of-10.aspx

 

Introduction

Pointing to the cloud We want our MVC application to get the data from the cloud (SQL Azure). To retrieve data from SQL Azure, it is incredibly easy:

bullet_thumb1

A simple change in the MVC’s connection string will make the change

This is a relevant use case

High availability and fault tolerance is built-in and no physical administration is required for SQL Azure. This is potentially an architecture that will work for many businesses – to have the data hosted in the cloud but have the web applications (Web Forms or MVC) hosted on premise.

 

The Connection String – Found in app.config

Currently configured for “On Premise” Notice that the connection string is found in App.config. Also notice that we are pointing to a Data Source=(local) .

snap0134

The New Connection String 

Points to SQL AzureOur data source is now
     <add name="ModelStocksContainer" connectionString="metadata=res://*/ModelStocks.csdl|         res://*/ModelStocks.ssdl|res://*/ModelStocks.msl;provider=System.Data.SqlClient;         provider connection string=         &quot;Data Source=tcp:bjzkzsxp9c.database.windows.net;Database=stocksdb;         User ID=brunoterkaly@bjzkzsxp9c;Password =[your password goes here] ;Trusted_Connection=False;         Encrypt=False&quot;" providerName="System.Data.EntityClient"         />

snap0135

Connection String is in both projects 

We need to adjust the connection string in 2 placesAs you recall from a previous post, the connection string is in both projects:

bullet

DataLayer

bullet

MvcOnPremise

snap0136snap0137snap0138snap0139

On Premise Web App – Cloud hosted database

Hybrid ApplicationAt this point you may decide you are done. That is, your application will be hosted ‘on-premise’ but the but he data is hosted in the cloud in SQL Azure.

snap0142

 

Future Posts for this blog

Move MVC Web App to Windows AzureWe will conclude this series of posts by migrating our web application to the cloud. At this point, the data is in the cloud, but not the application.