Azure allows you to connect to the cloud database only using the TDS
protocol with limited support, as described in the previous section.
But because the TDS protocol is supported by most of the SQL Server
client APIs, all the features supported by SQL Azure work with existing
client APIs. You can use two common patterns to connect to SQL Azure
databases: code near and code far.
1. Code-Near Connectivity
connectivity, your application is deployed in Windows Azure, which uses
SQL Azure. You geo-locate both of them in the same data center by
configuring the geo-location features of Windows Azure and SQL Azure. Figure 1 illustrates applications with code-near connectivity to a SQL Azure database.
Figure 1. Code-near connectivity to SQL Azure
In a typical code-near
architecture, the data access application is located in the same data
center as the SQL Azure database. The end users or on-premises
applications access the web interface are exposed via a Windows Azure
web role. This web role may be hosting an ASP.NET application for end
users or a web service for on-premises applications.
The advantages of the code-near approach are as follows:
Business logic is located closer to the database.
You can expose open standards–based interfaces like HTTP, REST, SOAP, and so on to your application data.
Client applications don't have to depend on the SQL Server client API.
The disadvantage of this
approach is the performance impact your application experiences if
you're using Windows Azure as a middle tier to access the database.
2. Code-Far Connectivity
connectivity, your application is typically deployed on-premises or in
a different data center than SQL Azure. In this pattern, the client
application makes a SQL query using the TDS protocol over the Internet
to the SQL Azure database. Figure 2 illustrates applications with code-far connectivity to a SQL Azure database.
Figure 2. Code-far connectivity to SQL Azure
The biggest advantage of the
code-far approach is the performance benefit your application can
experience because of direct connectivity to the database in the cloud.
The biggest disadvantage is that all the client applications must use
the TDS protocol to access the database. Therefore, the data access
clients must use SQL Server–supported client APIs like ADO.NET, ODBC,
and so on, reducing data-access possibilities from APIs or platforms
that don't support the TDS protocol.