<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Herve Roggero</title>
        <link>http://geekswithblogs.net/hroggero/Default.aspx</link>
        <description> </description>
        <language>en-US</language>
        <copyright>Herve Roggero</copyright>
        <managingEditor>hroggero@pynlogic.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>Herve Roggero</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/hroggero/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Quick Review of Backup tools for SQL Azure</title>
            <link>http://geekswithblogs.net/hroggero/archive/2012/02/02/quick-review-of-backup-tools-for-sql-azure.aspx</link>
            <description>&lt;p&gt;The landscape of SQL Azure backups is changing rapidly.  A few tools are becoming available at no charge and Microsoft is adding capabilities over time. Here a quick update.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;Microsoft Tools&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Microsoft offers two primary backup mechanisms so far:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Export/Import feature available on the Azure Management portal&lt;/li&gt;&lt;li&gt;The COPY operation as part of its T-SQL CREATE DATABASE statement&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These mechanisms do not offer a scheduling component and do not work together. To obtain a transactionally consistent backup, you first need to perform the COPY operation manually, then run the Export function.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;Free Tools&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You have other tools on the market that are a bit more comprehensive at no charge. Here are a few:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Enzo Backup for SQL Azure (Standard Edition)&lt;/li&gt;&lt;li&gt;Red Gate's SQL Azure Backup (backup only; no restore; no cloud backup)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These are the only two third-party products available at no charge I am aware of right now. Note that Red Gate's product provides a simple copy operation to a local SQL Server database, not really a backup/restore solution. However it does the job well if you want to get a local copy of your data. Enzo Backup is more comprehensive and offers many more functions, such as a built-in scheduler, cloud backup devices (in Blobs) and a restore capability.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;Paid-For Tools&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Enzo Backup for SQL Azure (Advanced Edition)&lt;/li&gt;&lt;li&gt;SQLAzureBackup (basic command-line BCP wrapper, no cloud backup)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Regarding the tools you can purchase, SQLAzureBackup is a product you can purchase, although it seems somewhat limited in its capabilities. You can nonetheless use it to export your data locally and restore the database back into SQL Azure. Enzo Backup Advanced Edition is a more powerful flavor of the free version that leverages multithreading for faster operations.&lt;/p&gt;&lt;p&gt;Here is a link to an MSDN article that offers additional information on how to backup SQL Azure: &lt;a href="http://blogs.msdn.com/b/davidmcg/archive/2011/09/29/data-backup-strategies-for-windows-and-sql-azure.aspx"&gt;http://blogs.msdn.com/b/davidmcg/archive/2011/09/29/data-backup-strategies-for-windows-and-sql-azure.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;For the time being Enzo Backup appears to have significantly more capabilities than the other products, and it can be used at no charge by visiting Blue Syntax's website (&lt;a href="http://www.bluesyntax.net"&gt;http://www.bluesyntax.net&lt;/a&gt;). &lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;[Disclaimer: I am the author of Enzo Backup for SQL Azure;  this blog intends to provide a quick overview of the current tools available on the market; please investigate the tools referenced here and visit the MSDN link provided to make an educated decision]&lt;/font&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/148565.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2012/02/02/quick-review-of-backup-tools-for-sql-azure.aspx</guid>
            <pubDate>Thu, 02 Feb 2012 14:40:19 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hroggero/comments/148565.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hroggero/archive/2012/02/02/quick-review-of-backup-tools-for-sql-azure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/148565.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Azure Florida Association:  New user group announcement</title>
            <category>South Florida</category>
            <link>http://geekswithblogs.net/hroggero/archive/2011/11/18/azure-florida-association--new-user-group-announcement.aspx</link>
            <description>&lt;p&gt;I am proud to announce the creation of a new virtual user group: the Azure Florida Association.&lt;/p&gt;
&lt;p&gt;The missiong of this group is to bring national and internaional speakers to the forefront of the Florida Azure community. Speakers include Microsoft employees, MVPs and senior developers that use the Azure platform extensively.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;How to learn about meetings and the group&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Go to &lt;a href="http://www.linkedin.com/groups?gid=4177626"&gt;http://www.linkedin.com/groups?gid=4177626&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;First Meeting Announcement&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Date&lt;/strong&gt;: January 25 2012 @4PM ET&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Topic&lt;/strong&gt;: Demystifying SQL Azure&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;: What is SQL Azure, Value Proposition, Usage scenarios, Concepts and Architecture, What is there and what is not, Tips and Tricks&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bio&lt;/strong&gt;: Vikas is a versatile technical consultant whose knowledge and experience ranges from products to projects, from .net to IBM Mainframe Assembler.  He has lead and mentored people on different technical platforms, and has focused on new technologies from Microsoft for the past few years.  He is also takes keen interest in Methodologies, Quality and Processes.&lt;br /&gt;
 &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/147754.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/11/18/azure-florida-association--new-user-group-announcement.aspx</guid>
            <pubDate>Sat, 19 Nov 2011 04:03:28 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/11/18/azure-florida-association--new-user-group-announcement.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/147754.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to Detect If You Are Connected To A Federation Root</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/10/27/how-to-detect-if-you-are-connected-to-a-federation.aspx</link>
            <description>&lt;div style="margin: 24pt 0in 0pt"&gt;If you develop applications in SQL Azure, you may end up in a situation where your code needs to know if it is operating in the root database or in a Federation Member, or if it is connected to a regular user database. Two ways can be used to make this determination: using system tables, or using the USE FEDERATION command.&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Using System Tables&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;This approach is the easiest to implement since it relies a SQL call only, without much logic in your application code. Assuming your code is currently connected to a SQL Azure database, you could use the &lt;b&gt;sys.databases&lt;/b&gt; table to read the &lt;b&gt;is_federation_member&lt;/b&gt; column.  &lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Here is the statement you would use:&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;b&gt;SELECT is_federation_member FROM sys.databases WHERE name = db_name()&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;If you are currently connected to a federation member, is_federation_member will be 1; otherwise it will be 0.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;b&gt;&lt;i&gt;Note that as of this writing, running the above statement in SQL Azure will throw an error because the is_federation_member column is not yet available in regular SQL Azure user databases. However, if you connect to a federation, the SQL code above will run.&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Using the USE FEDERATION Command&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Alternatively you can also use code in .NET to make that determination. Connect to the database as usual, using the SqlConnection class for example, then perform the following tasks:&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;Execute the &lt;b&gt;USE FEDERATION ROOT WITH RESET&lt;/b&gt; command, which forces the connection back to the root database (in case you are not current in the root database)&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;Execute &lt;b&gt;SELECT db_name() &lt;/b&gt;which fetches the name of the database of the root database&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 10pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;Compare the original database name you connected to with the one returned by the previous call; if the names are the same, you originally connected to the root database&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Here is the sample code:&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 9.5pt"&gt;string&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt; sql = &lt;span style="color: #a31515"&gt;"USE FEDERATION ROOT WITH RESET"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 9.5pt"&gt;string&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt; sql2 = &lt;span style="color: #a31515"&gt;"SELECT db_name()"&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 9.5pt"&gt;bool&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt; isFederationRoot = &lt;span style="color: blue"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 9.5pt"&gt;try&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: #2b91af; font-size: 9.5pt"&gt; SqlConnection&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt; sqlConn = new...; &lt;span style="color: green"&gt;// Your connection string goes here&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: #2b91af; font-size: 9.5pt"&gt; &lt;font color="#000000"&gt;sqlConn.Open();&lt;/font&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt; (&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt;(sql, sqlConn)).&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt;ExecuteNonQuery(); &lt;span style="color: green"&gt;// connect to the root db&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt; &lt;span style="color: #2b91af"&gt;SqlDataReader&lt;/span&gt; dr = (&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt;(sql2, sqlConn)).ExecuteReader(); &lt;span style="color: green"&gt;// Get the db_name()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (dr.Read())&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt;   isFederationRoot = (dr[0].ToString().ToLower() == dbName.ToLower());&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt; dr.Close();&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="font-size: 9.5pt"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 9.5pt"&gt;catch&lt;/span&gt;&lt;span style="font-size: 9.5pt"&gt; { }&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt; &lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt; &lt;/div&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/147475.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/10/27/how-to-detect-if-you-are-connected-to-a-federation.aspx</guid>
            <pubDate>Fri, 28 Oct 2011 03:44:22 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/10/27/how-to-detect-if-you-are-connected-to-a-federation.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/147475.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Solving Schema Separation Challenges</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/10/05/solving-schema-separation-challenges.aspx</link>
            <description>&lt;div style="margin: 24pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Introduction&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;To save on hosting costs and simplify maintenance, Software as a Service (SaaS) providers typically rely on schema separation to host multiple customers' records. This implementation relies on a specific SQL Server and SQL Azure feature called a schema object. A schema object behaves like a container, or a namespace in programmatic terms, allowing multiple tables (and other objects) to be stored with the same name in a single database.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;However schema separation comes with its own set of challenges. The challenge in using schema separation is that few tools support it. For example, until recently, it was not possible to easily backup or restore a single schema.  Other challenges include security and account management. Let's explore further.&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Basics of Schema Separation&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Let's assume you have two customers, and you need to track historical information. So you need to create a table called &lt;b&gt;tbl_history&lt;/b&gt; for each customer.  You could either create a database for each customer with the &lt;b&gt;tbl_history&lt;/b&gt; table in each database (the linear shard pattern), or create a schema container for each customer in a single database, and create the &lt;b&gt;tbl_history&lt;/b&gt; table in each schema container (the compressed shard pattern). For a description of sharding patterns review this white paper:  &lt;a href="http://www.bluesyntax.net/files/EnzoFramework.pdf"&gt;&lt;font color="#0000ff"&gt;http://www.bluesyntax.net/files/EnzoFramework.pdf&lt;/font&gt;&lt;/a&gt;.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Here is an example of a schema-based storage for different customers. A database is created with 2 schema containers (&lt;b&gt;cust1&lt;/b&gt; and &lt;b&gt;cust2&lt;/b&gt;). The &lt;b&gt;tbl_history&lt;/b&gt; table is then added to each schema container. The following script assumes that the database has already been created.&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;SCHEMA&lt;/span&gt; cust1&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;SCHEMA&lt;/span&gt; cust2&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; cust1&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;span style="color: gray"&gt;(&lt;/span&gt;id &lt;span style="color: blue"&gt;int&lt;/span&gt; &lt;span style="color: blue"&gt;identity&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;1&lt;span style="color: gray"&gt;,&lt;/span&gt;1&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;primary&lt;/span&gt; &lt;span style="color: blue"&gt;key&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; dateadded &lt;span style="color: blue"&gt;datetime&lt;/span&gt; &lt;span style="color: blue"&gt;default &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia"&gt;getdate&lt;/span&gt;&lt;span style="color: gray"&gt;()),&lt;/span&gt; productid &lt;span style="color: blue"&gt;int&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; quantity &lt;span style="color: blue"&gt;int&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; cust2&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;span style="color: gray"&gt;(&lt;/span&gt;id &lt;span style="color: blue"&gt;int&lt;/span&gt; &lt;span style="color: blue"&gt;identity&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;1&lt;span style="color: gray"&gt;,&lt;/span&gt;1&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;primary&lt;/span&gt; &lt;span style="color: blue"&gt;key&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; dateadded &lt;span style="color: blue"&gt;datetime&lt;/span&gt; &lt;span style="color: blue"&gt;default &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia"&gt;getdate&lt;/span&gt;&lt;span style="color: gray"&gt;()),&lt;/span&gt; productid &lt;span style="color: blue"&gt;int&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; quantity &lt;span style="color: blue"&gt;int&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; cust1&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;span style="color: gray"&gt;(&lt;/span&gt;productid&lt;span style="color: gray"&gt;,&lt;/span&gt; quantity&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;values &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;1&lt;span style="color: gray"&gt;,&lt;/span&gt; 5&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; cust1&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;span style="color: gray"&gt;(&lt;/span&gt;productid&lt;span style="color: gray"&gt;,&lt;/span&gt; quantity&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;values &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;2&lt;span style="color: gray"&gt;,&lt;/span&gt; 7&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; cust2&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;span style="color: gray"&gt;(&lt;/span&gt;productid&lt;span style="color: gray"&gt;,&lt;/span&gt; quantity&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;values &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;107&lt;span style="color: gray"&gt;,&lt;/span&gt; 22&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: gray"&gt;*&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; cust1&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;span style="line-height: 115%; color: blue; font-size: 10pt"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-size: 10pt"&gt; &lt;span style="color: gray"&gt;*&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; cust2&lt;span style="color: gray"&gt;.&lt;/span&gt;tbl_history&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;At this point we have two tables with the same name, each in a different schema container, but within a single database. Here is more information about schema containers: &lt;a href="http://msdn.microsoft.com/en-us/library/ms189462.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms189462.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Securing Access&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;An important feature of schema containers is their support for security. You could easily create a user (mapped to a login account) and grant that user SELECT rights to &lt;b&gt;cust1&lt;/b&gt;.  The following statements should be executed against the &lt;b&gt;master database&lt;/b&gt; in SQL Azure.&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;LOGIN&lt;/span&gt; logincust1 &lt;span style="color: blue"&gt;WITH&lt;/span&gt; &lt;span style="color: blue"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; &lt;span style="color: red"&gt;'p@ssw0rd001'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;span style="line-height: 115%; color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-size: 10pt"&gt; &lt;span style="color: blue"&gt;LOGIN&lt;/span&gt; logincust2 &lt;span style="color: blue"&gt;WITH&lt;/span&gt; &lt;span style="color: blue"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; &lt;span style="color: red"&gt;'p@ssw0rd002'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Then back in the user database, create two users.&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: fuchsia"&gt;USER&lt;/span&gt; user1 &lt;span style="color: blue"&gt;FOR&lt;/span&gt; &lt;span style="color: blue"&gt;LOGIN&lt;/span&gt; logincust1&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: fuchsia"&gt;USER&lt;/span&gt; user2 &lt;span style="color: blue"&gt;FOR&lt;/span&gt; &lt;span style="color: blue"&gt;LOGIN&lt;/span&gt; logincust2&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Finally, you need to authorize each user to execute statements against the history table. We will authorize &lt;b&gt;user1&lt;/b&gt; to use all the objects in schema &lt;b&gt;cust1&lt;/b&gt;, and &lt;b&gt;user2&lt;/b&gt; in &lt;b&gt;cust2&lt;/b&gt;.&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;GRANT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;SELECT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; &lt;span style="color: blue"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: blue"&gt;ON&lt;/span&gt; &lt;span style="color: blue"&gt;SCHEMA&lt;/span&gt;&lt;span style="color: gray"&gt;::&lt;/span&gt;cust1 &lt;span style="color: blue"&gt;TO&lt;/span&gt; user1&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;GRANT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;SELECT&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; &lt;span style="color: blue"&gt;EXECUTE&lt;/span&gt; &lt;span style="color: blue"&gt;ON&lt;/span&gt; &lt;span style="color: blue"&gt;SCHEMA&lt;/span&gt;&lt;span style="color: gray"&gt;::&lt;/span&gt;cust2 &lt;span style="color: blue"&gt;TO&lt;/span&gt; user2&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;At this point, &lt;b&gt;user1&lt;/b&gt; can only select and execute stored procedures in the cust1 schema. &lt;b&gt;user1&lt;/b&gt; cannot access schema cust2.  Here is more information about the Create Login statement: &lt;a href="http://msdn.microsoft.com/en-us/library/ee336268.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee336268.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Customer Accounts vs. Service Accounts&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;The previous section discusses the creation of logins and users that provide security to each schema container. It should be noted that each login/user account created in the user database should be treated as a service account, not an actual customer account. Indeed, if you create customer accounts in SQL Azure directly you could negatively impact connection pooling, and hence performance. You should authorize users first, using a specific application authentication component (such as ASP.NET Membership), then map the customer account to the service account to use.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;You typically implement the mapping (from customer account to service account) using a separate customer account database. A column in your customer account table would store the database connection string, which would contain the service account to use. Here is an example:&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;span style="line-height: 115%; color: blue; font-size: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-size: 10pt"&gt; &lt;span style="color: blue"&gt;TABLE&lt;/span&gt; custmapping&lt;span style="color: gray"&gt;(&lt;/span&gt;customerid &lt;span style="color: blue"&gt;int&lt;/span&gt; &lt;span style="color: blue"&gt;primary&lt;/span&gt; &lt;span style="color: blue"&gt;key&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; custconnection &lt;span style="color: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;255&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: gray"&gt;NOT&lt;/span&gt; &lt;span style="color: gray"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;b&gt;&lt;i&gt;Note that in a production environment, you would likely encrypt the connection string. The above table does not implement encryption to illustrate a simple scenario.&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;You would then add a record for each customer:&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; custmapping &lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;1&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; &lt;span style="color: red"&gt;'server=....;UID=logincust1;PWD=p@ssw0rd001'&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt;&lt;span style="color: blue; font-size: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: blue"&gt;INTO&lt;/span&gt; custmapping &lt;span style="color: blue"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;2&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt; &lt;span style="color: red"&gt;'server=....;UID=logincust2;PWD=p@ssw0rd002'&lt;/span&gt;&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal"&gt; &lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;When a customer logins with their account, your code would read the &lt;b&gt;custmapping&lt;/b&gt; table to retrieve the connection string to use for the duration of the session.&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Moving A Schema&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;If a customer grows significantly, or is abusing your SaaS application, you may be facing the need to move that customer's data to a different database so that the other customers (called tenants in SaaS terms) are not affected negatively by the increase in resources needed by that customer.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;There are very few options available today to move a single schema container, and its associated objects, from one database to another. You could manually create the schema container and its objects first, then use BCP or SSIS to move the data. However this can be error prone and lengthy.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;A tool recently released by Blue Syntax, called Enzo Backup for SQL Azure, provides the ability to backup a single schema. This tool will backup the associated users in addition to the related objects (tables, stored procedures and so forth). The restore process will recreate the schema in the chosen database server and all the objects (and data) in that schema. Here is more information about this tool: &lt;a href="http://www.bluesyntax.net/backup.aspx"&gt;http://www.bluesyntax.net/backup.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Multitenant Frameworks&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Due to the level of complexity in building multitenant environments, certain companies are turning to specialized frameworks. Although these frameworks can require some learning curve, they provide certain capabilities that would be difficult to build, such as fan-out, caching, and other capabilities. Here are a few .NET frameworks:&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;·&lt;span style="font: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;The Enzo Sharding Library (open-source); &lt;u&gt;also supports Data Federation&lt;/u&gt;: &lt;a href="http://enzosqlshard.codeplex.com/releases/view/72791"&gt;http://enzosqlshard.codeplex.com/releases/view/72791&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;·&lt;span style="font: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;The CloudNinja project (open-source): &lt;a href="http://cloudninja.codeplex.com/"&gt;http://cloudninja.codeplex.com/&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 10pt 0.5in"&gt;&lt;span&gt;·&lt;span style="font: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;The Enzo Multitenant Framework: &lt;a href="http://www.bluesyntax.net/scale.aspx"&gt;http://www.bluesyntax.net/scale.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Schema Separation and Data Federation&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Data Federation is an upcoming feature of SQL Azure that will provide a new mechanism to distribute data. In a way, Data Federation allows SaaS vendors to design a monolithic database, in which all customers are located, and distribute records of one or more tables across databases when the time comes. Data Federation is essentially a compressed shard, similarly to schema separation, with the added benefit of tooling support and easier repartitioning based on performance and storage needs. In addition, Data Federation can help you distribute data on almost any dimension; not just customer id.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Data Federation and Schema Separation are not competing solutions for SaaS vendors. Each have specific benefits and challenges. SaaS vendors will need to determine which one serves their needs best, or even use both.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Using both Schema Separation and Data Federation delivers even greater flexibility.  For example, if the history table of customer 2 becomes too large, you could leverage Data Federation to split that table, without affecting customer 1. A specific use of this technique could be to use Data Federation to split tables across databases every year for all customers (or only those that have a lot of records). This dual layering technique (using schema separation for customer records, and data federation for archiving) can deliver remarkable performance results and scalability.&lt;/div&gt;
&lt;div style="margin: 10pt 0in 0pt"&gt;&lt;b&gt;&lt;font size="5"&gt;&lt;font color="#4f81bd" size="4"&gt;Conclusion&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Many vendors have successfully built a SaaS solution using schema separation. While tooling has been lacking, some vendors are adding schema separation support in their products. Understanding the options available at your finger tips, including the frameworks already developed, and how to combine sharding models can give you a significant advantage when building your SaaS solutions.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;  &lt;/div&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/147196.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/10/05/solving-schema-separation-challenges.aspx</guid>
            <pubDate>Thu, 06 Oct 2011 03:03:26 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/10/05/solving-schema-separation-challenges.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/147196.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Sharding Library for SQL Azure Data Federation</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/09/07/sharding-library-for-sql-azure-data-federation.aspx</link>
            <description>&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;The ability to write scale out applications for SQL Azure will soon become much easier, thanks to the upcoming SQL Azure Data Federation capabilities. In an &lt;/font&gt;&lt;a href="http://geekswithblogs.net/hroggero/archive/2011/07/23/preparing-for-data-federation-in-sql-azure.aspx"&gt;&lt;font size="3" face="Calibri"&gt;earlier post&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt;, I outlined specific steps developers can take to prepare for this key enhancement.&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;Some of the key capabilities of SQL Azure Data Federation is to distribute large data sets across multiple databases, hence providing a mechanism to avoid the current database size limitations of SQL Azure. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;While it may be tempting to look at this new feature as a workaround to an existing size limitation, the real benefit of federating data is to give each data set its own set of independent processing power; indeed each federation member is assigned its own CPU, storage, memory, TempDB and network bandwidth. In other words, Data Federation provides the basic foundation for a scale out database model, typically needed by SaaS applications and historical data sets.&lt;/font&gt;&lt;/p&gt;
&lt;h2&gt;&lt;font size="3" face="Calibri"&gt;Distributed Needs&lt;/font&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;Since data stored in federation members are actually stored across multiple databases, certain capabilities taken for granted in typical development environments are not available just yet.&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;And with this type of new features, new needs are surfacing.&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;In a nutshell, some of the capabilities currently missing include:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size="3" face="Calibri"&gt;-&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;The ability to fan out queries when running a query across federation members &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size="3" face="Calibri"&gt;-&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;The ability to perform basic joins across federation members to exclude data sets&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size="3" face="Calibri"&gt;-&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;The ability to execute simple aggregated functions such as MIN, MAX... across federated members&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;Since these capabilities are not yet supported by the Data Federation feature, it is necessary to leverage parallel processing on the client (or middle-tier) application in order to efficiently query across federation members (i.e. databases).&lt;/font&gt;&lt;/p&gt;
&lt;h2&gt;&lt;font size="3" face="Calibri"&gt;Open-Source Enzo Library&lt;/font&gt;&lt;/h2&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;In order to provide support the above capabilities across federation members, I updated the &lt;b style="mso-bidi-font-weight: normal"&gt;Enzo Shard Library open-source project&lt;/b&gt; (&lt;/font&gt;&lt;a href="http://enzosqlshard.codeplex.com/releases/view/72791"&gt;&lt;font size="3" face="Calibri"&gt;http://enzosqlshard.codeplex.com/releases/view/72791&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt;), which is currently in Version 2.0 Beta. This updated library offers new important features, including support for Data Federation. A new class (called the Distributed Query) allows developers to execute a simple SELECT query across federation members. For example, a Distributed Query that fetches customer data across federation members (hence databases) to return the Maximum CustomerID would look like this:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;span style="font-family: Verdana"&gt;&lt;em&gt;&lt;span style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi"&gt;&lt;font size="3"&gt;SELECT MAX(CustomerId) USING (&lt;b style="mso-bidi-font-weight: normal"&gt;select customerid from customers&lt;/b&gt;) FEDERATED ON (customerfederation) &lt;/font&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;em&gt;&lt;span style="font-family: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi"&gt;&lt;font size="3"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;The above statement is interpreted by the Enzo library; the inner statement (&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri"&gt;&lt;span style="font-family: Verdana"&gt;select customerid from customers&lt;/span&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;) is the T-SQL part that is actually executed across each federation member in parallel against SQL Azure. Then the library aggregates the results and returns the maximum customer id from all the databases involved in the federation &lt;span style="mso-spacerun: yes"&gt;(see the details on CodePlex for a complete specification of the Distributed Query).&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;font size="3" face="Calibri"&gt;There are many new features available in this library, which will be the subject of my talk at the PASS Conference 2011 in October (&lt;/font&gt;&lt;a href="http://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SpeakerDetail.aspx?spid=276"&gt;&lt;font size="3" face="Calibri"&gt;more information&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt;). &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;font size="3" face="Calibri"&gt; &lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/146793.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/09/07/sharding-library-for-sql-azure-data-federation.aspx</guid>
            <pubDate>Thu, 08 Sep 2011 01:16:28 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/09/07/sharding-library-for-sql-azure-data-federation.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/146793.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Spotlight (R) on Azure: Cool Tool</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/09/06/spotlight-r-on-azure-cool-tool.aspx</link>
            <description>&lt;div style="margin: 0in 0in 10pt"&gt;While testing the performance characteristics of the SQL Azure backup tool I am building (called &lt;a href="http://www.bluesyntax.net/backup.aspx"&gt;Enzo Backup for SQL Azure&lt;/a&gt;), I decided to try Spotlight (R) on Azure in order to obtain specific performance metrics from a virtual machine (VM) running on Microsoft's data center.  Indeed, my backup solution comes with a cloud agent (running as a worker role in Azure) that performs backup and restore operations entirely in the cloud. Due to the nature of this application, I needed to have an understanding of possible memory and CPU pressures.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;As of today, very few techniques are available to capture VM's performance metrics in Microsoft Azure. One thing you can do is to configure your application to send Diagnostics data to Azure Tables and Blobs; however this requires a lot of work when comes time to parse the information. I had previously tried the Azure Management Pack of System Center. While the Management Pack was indeed powerful, it was difficult to install and came with a very limited number of metrics by default, making it more difficult for a small organization like mine to customize and fully leverage. System Center's capabilities with Azure will grow over time and will most likely appeal to larger organizations.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;When it comes to small companies with few operational capabilities, Spotlight (R) on Azure delivers (from Quest). The installation is extremely simple and the tool comes with many metrics out of box. In my tests, I was able to obtain a quick read on my virtual machine and review performance graphs showing CPU Utilization, CPU Queue Length, Memory Utilization and Network Traffic.  The tool shows by default the last 15 minutes or data, which is very handy. If you have a large farm of virtual machines, you can also view metrics rolled up across your virtual machines. Finally the tool allows you to declare Alerts if you cross performance thresholds (the thresholds values can be changed to your needs).   &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size: x-small"&gt;&lt;span style="line-height: 115%"&gt;All in all, this is a simple, yet powerful performance monitoring tool for your Azure virtual machines. Here is a link that shows the tool in action: &lt;a href="http://www.youtube.com/watch?v=FDJjytW-VFI"&gt;http://www.youtube.com/watch?v=FDJjytW-VFI&lt;/a&gt; and here is a link where you can download the tool for a test drive: &lt;a href="http://communities.quest.com/docs/DOC-9906"&gt;http://communities.quest.com/docs/DOC-9906&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/146779.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/09/06/spotlight-r-on-azure-cool-tool.aspx</guid>
            <pubDate>Wed, 07 Sep 2011 04:05:14 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/09/06/spotlight-r-on-azure-cool-tool.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/146779.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Preparing for Data Federation in SQL Azure</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/07/23/preparing-for-data-federation-in-sql-azure.aspx</link>
            <description>&lt;div style="margin: 0in 0in 10pt"&gt;This blog will help you prepare for an upcoming release of SQL Azure that will offer support for Data Federation.  While no date has been provided for this feature, I was able to test an early preview and compiled a few lessons learned that can be shared publicly. Note however that certain items could not be shared in this blog because they are considered NDA material; as a result, you should expect additional guidance in future posts when the public Beta will be made available.&lt;/div&gt;
&lt;h3&gt;&lt;b&gt;What is Data Federation?&lt;/b&gt;&lt;/h3&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;First and foremost, allow me to explain what Data Federation is in SQL Azure. Many terms have been used, like partitioning, sharding and scale out. Other sharding pattern exist too, which could be described in similar terms; so it is difficult to paint a clear picture of what Data Federation really is without comparing with other partitioning models. (To view a complete description of sharding models, take a look at a white paper I wrote on the topic where with a link on this page: &lt;a href="http://bluesyntax.net/scale.aspx"&gt;http://bluesyntax.net/scale.aspx&lt;/a&gt;)&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;The simplest model to explain is the &lt;b&gt;linear shard&lt;/b&gt;: each database contains all the necessary tables for a given customer (in which case the customer ID would be the dimension). So in a linear shard, you will need 100 databases if you have 100 customers.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Another model is the &lt;b&gt;compressed shard&lt;/b&gt;: a container (typically a schema) inside a database contains all the necessary tables for a given customer. So in a compressed shard, each database could contain one or more customers, all logically usually separated by a schema (providing a strong security data enforcement model). As you will see, Data Federation offers an alternative to schema separation.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;The &lt;b&gt;scale up&lt;/b&gt; model (which is not a shard technically) uses a single database in which customer records are identified by an identifier. Most applications fall in this category today. However the need to design flexible and scalable components in a cloud paradigm makes this design difficult to embrace.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;&lt;b&gt;Data Federation&lt;/b&gt;, as it turns out, is a mix of a compressed shard and a scale up model as described above, but instead of using a schema to separate records logically, it uses a federation (a new type of container) which is a set of physical databases (each database is called a federation member).  So within each database (a federation member) you can have multiple customers. You are in control of the number of customers you place inside each federation, member and you can either split customers (i.e. create new database containers) or merge them back at a later time (i.e. reducing the number of databases making up your shard).&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;For a more complete description of Data Federation, see Cihan’s blog here: &lt;a href="http://blogs.msdn.com/b/cbiyikoglu/archive/2010/10/30/building-scalable-database-solution-in-sql-azure-introducing-federation-in-sql-azure.aspx"&gt;http://blogs.msdn.com/b/cbiyikoglu/archive/2010/10/30/building-scalable-database-solution-in-sql-azure-introducing-federation-in-sql-azure.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;As a result, Data Federation allows you to start with a single database (similar to a scale up model), and create federations over time (moving into the compressed shard territory). When you create a federation, you specify a range over the customer IDs you would like to split, and SQL Azure will automatically move the records in the appropriate database (federation member). You could then, in theory, design “as usual” using a scale up model and use Data Federation at a later time when performance requirements dictate.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;I did say in theory.&lt;/div&gt;
&lt;h3&gt;&lt;b&gt;Design Considerations&lt;/b&gt;&lt;/h3&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;So at this point you are probably wondering… what’s the catch? It’s pretty simple, really. It has to do with the location of the data and performance implications of storing data across physical databases: referential integrity. [Read Cihan’s blog about the limitations on referential integrity here: &lt;a href="http://blogs.msdn.com/b/cbiyikoglu/archive/2011/07/19/data-consistency-models-referential-integrity-with-federations-in-sql-azure.aspx"&gt;http://blogs.msdn.com/b/cbiyikoglu/archive/2011/07/19/data-consistency-models-referential-integrity-with-federations-in-sql-azure.aspx&lt;/a&gt;]&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;Data Federation is indeed very powerful. It provides a new way to spread data access across databases, hence offering a shared-nothing architecture across federation members hosting your records. In other words: the more members your federation has (i.e. databases) the more performance is at your fingertips.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;But in order to harvest this new power, you will need to make certain tradeoffs, one of which being referential integrity.  While foreign key relationships are allowed within a federated member, they are not allowed between members. So if you are not careful, you could duplicate unique IDs in related tables. Also, since you have distributed records, you may need to replicate certain tables on all your federated members, hence creating a case of data proliferation which will not be synchronized across federation members for you.&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;If you are considering to use Data Federation in the future and would like to take an early start in your design, I will make the following recommendations:&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;The smaller the number of tables, the easier it will be for you to reconcile records and enforce referential integrity in your application&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;Do not assume all existing Referential Integrity (RI) constructs will still exist in a federated database; plan to move certain RI rules in your application&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;It is possible that the more you create federations members, the more expensive your implementation will be (no formal pricing information is available at the time of this writing)&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;Data Federation still uses the scale up model as its core, since each federated table needs to contain the customer ID in question; so record security and access control is similar to a scale up model&lt;/div&gt;
&lt;div style="text-indent: -0.25in; margin: 0in 0in 10pt 0.5in"&gt;&lt;span&gt;-&lt;span style="font: 7pt 'Times New Roman'"&gt;          &lt;/span&gt;&lt;/span&gt;You will need to leverage parallel processing extensively to query federated members in parallel if you are searching for records across your members, so if you are not familiar with the Task Parallel Library (TPL), take a look. You will need it&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt;In summary, Data Federation is for you if you need to scale your database to dozens of databases or more due to performance and scalability reasons. It goes without saying that the simpler the database, the easier the adoption of Data Federation will be.  Performance and scalability improvements often come with specific tradeoffs;  Data Federation is no exception and as expected the tradeoff is referential integrity (similar to no-sql database systems).&lt;/div&gt;
&lt;div style="margin: 0in 0in 10pt"&gt; &lt;/div&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/146306.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/07/23/preparing-for-data-federation-in-sql-azure.aspx</guid>
            <pubDate>Sat, 23 Jul 2011 22:23:11 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/07/23/preparing-for-data-federation-in-sql-azure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/146306.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Backing up SQL Azure</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/06/21/backing-up-sql-azure.aspx</link>
            <description>&lt;p&gt;That's it!!! After many days and nights... and an amazing set of challenges, I just released the Enzo Backup for SQL Azure BETA product (&lt;a href="http://www.bluesyntax.net"&gt;http://www.bluesyntax.net&lt;/a&gt;). Clearly, that was one of the most challenging projects I have done so far.&lt;/p&gt;
&lt;p&gt;Why???&lt;/p&gt;
&lt;p&gt;Because to create a highly redundant system, expecting failures at all times for an operation that could take anywhere from a couple of minutes to a couple of hours, and still making sure that the operation completes at some point was remarkably challenging. Some routines have more error trapping that actual code... &lt;img alt="" src="http://geekswithblogs.net/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/regular_smile.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Here are a few things I had to take into account:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Exponential Backoff (&lt;a href="http://geekswithblogs.net/hroggero/archive/2011/05/26/cloud-lesson-learned-exponential-backoff.aspx"&gt;explained in another post&lt;/a&gt;)&lt;/li&gt;
    &lt;li&gt;Dual dynamic determination of number of rows to backup &lt;/li&gt;
    &lt;li&gt;Dynamic reduction of batch rows used to restore the data&lt;/li&gt;
    &lt;li&gt;Implementation of a flexible BULK Insert API that the tool could use&lt;/li&gt;
    &lt;li&gt;Implementation of a custom Storage REST API to handle automatic retries&lt;/li&gt;
    &lt;li&gt;Automatic data chunking based on blob sizes&lt;/li&gt;
    &lt;li&gt;Compression of data&lt;/li&gt;
    &lt;li&gt;Implementation of the Task Parallel Library at multiple levels including deserialization of Azure Table rows and backup/restore operations&lt;/li&gt;
    &lt;li&gt;Full or Partial Restore operations&lt;/li&gt;
    &lt;li&gt;Implementation of a Ghost class to serialize/deserialize data tables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And that's just a partial list... I will explain what some of those mean in future blob posts. A lot of the complexities had to do with implementing a form of retry logic, depending on the resource and the operation.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/145940.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/06/21/backing-up-sql-azure.aspx</guid>
            <pubDate>Tue, 21 Jun 2011 19:27:55 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/06/21/backing-up-sql-azure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/145940.aspx</wfw:commentRss>
        </item>
        <item>
            <title>PASS Conference 2011 Topic: Multitenant Design and Sharding with SQL Azure</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/06/21/pass-conference-2011-topic-multitenant-design-and-sharding-with-sql.aspx</link>
            <description>&lt;p&gt;I am really happy to announce that I have been accepted as a speaker at the 2011 PASS Conference in Seattle. The topic? It will be about SQL Azure scalability using shards, and the Data Federation feature of SQL Azure. I will also talk extensively about the community open-source sharding library &lt;strong&gt;Enzo SQL Shard&lt;/strong&gt; (&lt;a target="_blank" href="http://enzosqlshard.codeplex.com"&gt;enzosqlshard.codeplex.com&lt;/a&gt;) and show how to make the most out of it.&lt;/p&gt;
&lt;p&gt;In general, the presentation will provide details about how to properly design an application for sharding, how to make it work for SQL Server, SQL Azure, and how to leverage the upcoming Data Federation technology that Microsoft is planning. The primary objective is to turn sharding an implementation concern, not a development concern. Using a library like &lt;strong&gt;Enzo SQL Shard&lt;/strong&gt; will help you achieve this objective.&lt;/p&gt;
&lt;p&gt;If you come to PASS Summit this year, come see me and mention you saw this blog!&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/145939.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/06/21/pass-conference-2011-topic-multitenant-design-and-sharding-with-sql.aspx</guid>
            <pubDate>Tue, 21 Jun 2011 19:13:16 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/06/21/pass-conference-2011-topic-multitenant-design-and-sharding-with-sql.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/145939.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Cloud Lesson Learned: Exponential Backoff</title>
            <link>http://geekswithblogs.net/hroggero/archive/2011/05/26/cloud-lesson-learned-exponential-backoff.aspx</link>
            <description>&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;This blog is the first one of a series of blogs addressing programming practices and lessons learned related to cloud computing. While most developers will be familiar at least conceptually with the techniques exposed, I will provide background information and code samples in an attempt to explain why they are so critical in cloud software development.  While most of the information provided will be using Windows Azure and/or SQL Azure, these concepts apply to cloud computing in general.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 3"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;Exponential Backoff&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;In this blog I will discuss expotential backoff (EB). EB is a retry technique that assumes failure by nature and attempts to retry the operation, with an exponentially increasing wait time, until a maximum retry count has been reached. This technique accounts for the fact that cloud resources may be unavailable more than a few seconds, for any reason out of your control. In the case of SQL Azure for example, a database may be moved to another server at any time, causing the database from being unavailable for a few seconds, or a few minutes depending on the scenario.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;In addition to resource availability, EB also takes into account the fact that the cloud provider may decide to throttle, or limit, availability of resources due to usage overload. For example, requesting too many connection requests quickly may be viewed as a Denial of Service attack by the cloud provider. As result, backing off exponentially connection requests to SQL Azure provides a mechanism to scale back connection requests when a capacity threshold has been encountered.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 3"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 13.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;Example&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;The following C# example shows an extension method called &lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt"&gt;TryOpen &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;that provides an EB when a connection timeout is encountered. In your code you may want to provide additional exception management, such as providing a mechanism to cancel the EB if a user presses a Cancel button for example. In this code snippet, the &lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt"&gt;TryOpen &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;method tries to open a database connection up to 5 times in a row, backing off 3 seconds exponentially every time (3 seconds, 9 seconds, 27 seconds...).&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;em&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;[the code below was edited on 6/4/11 to fix a bug in the sleep timeout calculation]&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt;static&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt; TryOpen(&lt;span style="color: blue"&gt;this&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt; connection)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style="color: blue"&gt;  int&lt;/span&gt; attempts = 0; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;&lt;span style="color: blue"&gt;while&lt;/span&gt; (attempts &amp;lt; 5)&lt;br /&gt;
  {&lt;br /&gt;
    &lt;span style="color: blue"&gt;try&lt;br /&gt;
    &lt;/span&gt;{&lt;br /&gt;
      &lt;span style="color: blue"&gt;if&lt;/span&gt; (attempts &amp;gt; 0)&lt;br /&gt;
       &lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt"&gt;System.Threading.&lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;.Sleep(((&lt;span style="color: blue"&gt;int&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;Math&lt;/span&gt;.Pow(3, attempts)) * 1000);&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt;&lt;br /&gt;
      connection.Open();&lt;br /&gt;
      &lt;span style="color: blue"&gt;return&lt;/span&gt; connection;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;span style="color: blue"&gt;catch&lt;/span&gt; { }&lt;br /&gt;
    attempts++;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"Unable to obtain a connection to SQL Server or SQL Azure."&lt;/span&gt;);&lt;br /&gt;
}&lt;/span&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt; &lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'"&gt;Finally, assuming the above code was placed in a static class, your primary code could simply use the TryOpen method this way:&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;span style="font-family: Consolas; color: #2b91af; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt;SqlConnection &lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial"&gt;connection = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt;("your_connection_string");&lt;br /&gt;
connection.TryOpen();&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;As you can see, hiding connection retries is simple when you leverage extension methods in .NET. This allows you to centralize rather complex routines that should be centralized for maintenance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hroggero/aggbug/145589.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Herve Roggero</dc:creator>
            <guid>http://geekswithblogs.net/hroggero/archive/2011/05/26/cloud-lesson-learned-exponential-backoff.aspx</guid>
            <pubDate>Fri, 27 May 2011 01:07:58 GMT</pubDate>
            <comments>http://geekswithblogs.net/hroggero/archive/2011/05/26/cloud-lesson-learned-exponential-backoff.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hroggero/comments/commentRss/145589.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
