{"id":6481,"date":"2016-01-04T17:32:03","date_gmt":"2016-01-04T16:32:03","guid":{"rendered":"https:\/\/blog.redbaronofazure.com\/?p=6481"},"modified":"2016-01-04T18:32:01","modified_gmt":"2016-01-04T17:32:01","slug":"dr-part-3-sql-azure-geo-replication","status":"publish","type":"post","link":"https:\/\/blog.redbaronofazure.com\/?p=6481","title":{"rendered":"DR part 3 &#8211; SQL Azure Geo-Replication"},"content":{"rendered":"<p>This is the third post on how to make sure your application can survive a datacenter outage. The first post just set the basics on how to get your company&#8217;s website on to Azure. The second post focused on how to use Traffic Manager infront of a dual datacenter website deployment. This third post in the series will be on the topic on how the SQL Azure database can be geo-replicated across two datacenters.<\/p>\n<p>If you haven&#8217;t read the DR2 post, I suggest you do this before reading this post.<\/p>\n<p><strong>Geo-replication is built in functionality in SQL Azure Database<\/strong><\/p>\n<p>First of all, there is an excellent article by Tony Petrossian in the SQL Azure product group (see references) that discusses the geo-replication features in SQL Azure and the difference between Active and Standard. I encourage you to read that if you haven&#8217;t.<\/p>\n<p>In short, how geo-replication works in SQL Azure is that you have a primary database that continously sends commited transactions asynchronously to its secondary databases so that they are up to date. You can have multiple secondary databases but they can only be SQL Azure databases, so you can not user a SQL Server VM as the secondary.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-1.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-6521\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-1.png\" alt=\"DR3-enable-geo-repl-portal-1\" width=\"808\" height=\"359\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-1.png 808w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-1-300x133.png 300w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/a><\/p>\n<p>Configuring the Geo-Replication is very easy in the portal. You just go to the primary database and select Geo-Replication in the Settings list. If you can&#8217;t find the menu item, you have the wrong Pricing Tier for the database. It needs to be Standard, so S0 is the lowest you can have to set this up.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-2.png\"><img loading=\"lazy\" class=\"size-full wp-image-6531 alignright\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-2.png\" alt=\"DR3-enable-geo-repl-portal-2\" width=\"271\" height=\"485\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-2.png 271w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-enable-geo-repl-portal-2-168x300.png 168w\" sizes=\"(max-width: 271px) 100vw, 271px\" \/><\/a>If the Pricing Tier for the database is Standard,\u00a0you can only do what is called Standard Geo-Replication, and the portal tells\u00a0you that twice. In order to have a readable secondary database, the Pricing Tier must be Premium.<\/p>\n<p>What is the Non-readable secondary type, then? It is basically an offline database that receives and applies the asynchronous transactions and keeps the database up to date, but it can not be used by applications in any way until you terminate the continous copy relationship.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-non-readble.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-6611\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-non-readble-300x87.png\" alt=\"DR3-non-readble\" width=\"300\" height=\"87\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-non-readble-300x87.png 300w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-non-readble.png 607w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Terminating the relationship is a manual procedure in the portal or something you do with Powershell. Either way you do it, it is not something Azure does automatically.<\/p>\n<p>So the question is &#8211; should you switch to Premium or stay with Standard? Well, that depends on what you need the secondary site for and also how you plan to use Traffic Managers routing option.<\/p>\n<p><strong>The combinations of Traffic Manager&#8217;s Routing options and SQL Azure&#8217;s Geo-Repliction options<\/strong><\/p>\n<p>Traffic Manager has three options for Routing Method between the endpoints (websites) it has in its profile. The Routing Methods are Performance, Weighted(Round Robin)\u00a0and Priority(Failover). The first two options will mean that all endpoints (websites) will be actively in use and serve web content to clients. This means\u00a0that an offline, non-readable database is\u00a0of little use with Performance or Weighted Traffic Manager routing and we must\u00a0have Active Geo-Replication to get a readable database.\u00a0But if the Traffic Manager routing is Priority(Failover), this means that we can\u00a0get by with\u00a0either the offline or the read-only as the secondary database. It becomes a question on how the failover should happen.<\/p>\n<p><strong>Time and decision to failover the database<\/strong><\/p>\n<p>If we assume we are using Routing Method Priority (Failover) for the Traffic Manager Profile, the switch from the primary to the secondary endpoints will happen automatically when TM&#8217;s monitoring\u00a0probing fails on http(s). At that point monitoring status will become &#8220;Degraded&#8221; as I explained in my DR2 post and it will start to direct traffic to the secondary endpoint (ie the website in alternate Azure datacenter).<\/p>\n<p>Since the continous copy relationship needs to be terminated regardless if we use an offline or read-only secondary database, this means that the actual database failover involves a decision point to execute the failover\u00a0action. The choice of using offline or read-only as a secondary database is\u00a0a choice of what should happen between the time of the TM failover and until the decision is made to terminate the continous copy relationship (which\u00a0puts the secondary database in read-write mode).<\/p>\n<ul>\n<li>Using <strong>offline<\/strong> as the secondary database means that the now active website will not be able to function correctly until the decision has been made to do database failover. The website responds, but you probably would call this a service disruption.<\/li>\n<li>Using <strong>read-only<\/strong>\u00a0as the secondary database means that the now active website may have a chance to function in read-only mode until the decision for failover has been made. How well the website behaves is really a question on what use read-only data is to your application. If this is a e-Commerce website, read-only is certainly not enough.<\/li>\n<\/ul>\n<p><strong>Manual decision when to failover<\/strong><\/p>\n<p>The decision to fail over is manual and should probably be done by a human so that\u00a0a person can verify the state of the failed website. If you configure Traffic Manager with Priority (Failover) Routing Method, you may have the database connection string of the secondary website pointing to the primary database, since it may just be the website that failed in the primary datacenter and not a complete datacenter outage. In that case, you will have the odd configuration of cross datacenter database queries, but the web application will still be up and running.\u00a0In this scenario, you may not even know that you had a problem since Traffic Manager will switch back when probing of the primary endpoint succeeds.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-2.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-6681\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-2.png\" alt=\"DR3-geo-repl-failover-2\" width=\"393\" height=\"464\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-2.png 393w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-2-254x300.png 254w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Failover action<\/strong><\/p>\n<p>In the portal, failover is a simple step and you do it via right-clicking on the secondary database and select Failover.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-portal.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-6641\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-portal.png\" alt=\"DR3-geo-repl-failover-portal\" width=\"749\" height=\"228\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-portal.png 749w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-portal-300x91.png 300w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/a><\/p>\n<p>Failing over using Poweshell is even simpler since it&#8217;s one command &#8211; Set-AzureRmSqlDatabaseSecondary. The command is fast and it just takes seconds for the Geo-Replication role to change from Secondary to Primary.<\/p>\n<p><a href=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-ps.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-6661\" src=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-ps.png\" alt=\"DR3-geo-repl-failover-ps\" width=\"875\" height=\"358\" srcset=\"https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-ps.png 875w, https:\/\/blog.redbaronofazure.com\/wp-content\/uploads\/2016\/01\/DR3-geo-repl-failover-ps-300x123.png 300w\" sizes=\"(max-width: 875px) 100vw, 875px\" \/><\/a><\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>This post have tried to show you how you can take advantage of SQL Azure&#8217;s built in Geo-Replication feature in order to avoid having a Disaster Recovery situation. Using Traffic Managers Priority (Failover) Routing Method and SQL Azure&#8217;s Geo-Replication feature, you can have a secondary website and database. Traffic Manager will switch website based on failed probing on port 80\/443, but failing over the database is something you must plan and do as a manual step.<\/p>\n<p><strong>References<\/strong><\/p>\n<p>Azure SQL Database Standard Geo-Replication &#8211; Tony Petrossian<br \/>\n<a href=\"https:\/\/azure.microsoft.com\/sv-se\/blog\/azure-sql-database-standard-geo-replication\/\" target=\"_blank\">https:\/\/azure.microsoft.com\/sv-se\/blog\/azure-sql-database-standard-geo-replication\/<\/a><\/p>\n<p>Azure SQL Database Geo-Replication Overview<br \/>\n<a href=\"https:\/\/azure.microsoft.com\/sv-se\/documentation\/articles\/sql-database-geo-replication-overview\/\" target=\"_blank\">https:\/\/azure.microsoft.com\/sv-se\/documentation\/articles\/sql-database-geo-replication-overview\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the third post on how to make sure your application can survive a datacenter outage. The first post just set the basics on how to get your company&#8217;s website on to Azure. The second post focused on how to use Traffic Manager infront of a dual datacenter website deployment. This third post in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[231,101,141,201],"tags":[361],"_links":{"self":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts\/6481"}],"collection":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6481"}],"version-history":[{"count":0,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=\/wp\/v2\/posts\/6481\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.redbaronofazure.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}