<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edwin M SarmientoHow To Enable Transparent Data Encryption In An Existing SQL Server Always On Availability Group &#8211; Edwin M Sarmiento</title>
	<atom:link href="https://www.edwinmsarmiento.com/how-to-enable-transparent-data-encryption-in-an-existing-sql-server-availability-group/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.edwinmsarmiento.com</link>
	<description>Intentional Excellence</description>
	<lastBuildDate>Mon, 13 Apr 2026 21:00:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">84283043</site>		<item>
		<title>How To Enable Transparent Data Encryption In An Existing SQL Server Always On Availability Group</title>
		<link>https://www.edwinmsarmiento.com/how-to-enable-transparent-data-encryption-in-an-existing-sql-server-availability-group/</link>
		<comments>https://www.edwinmsarmiento.com/how-to-enable-transparent-data-encryption-in-an-existing-sql-server-availability-group/#respond</comments>
		<pubDate>Thu, 29 Oct 2015 16:59:34 +0000</pubDate>
		<dc:creator>Edwin M Sarmiento</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Availability Groups]]></category>
		<category><![CDATA[TDE]]></category>
		<category><![CDATA[transparent data encryption]]></category>
		<guid isPermaLink="false">http://www.edwinmsarmiento.com/?p=2201</guid>

				<description><![CDATA[I&#8217;ve deployed several SQL Server Always On Availability Groups in the past with high availability being the primary requirement. In some environments, there is a requirement to protect sensitive data for security and compliance reasons. Back in 2013, I had a customer who wanted to implement Always On Availability Groups for their databases. They were moving their [&#8230;]]]></description>
					<content:encoded><![CDATA[<img width="512" height="512" src="https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512.png" class="featured-image wp-post-image" alt="" srcset="https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512.png 512w, https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512-150x150.png 150w, https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512-300x300.png 300w, https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512-35x35.png 35w, https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512-400x400.png 400w, https://www.edwinmsarmiento.com/wp-content/uploads/2015/10/889a7f-data-encryption-512-82x82.png 82w" sizes="(max-width: 512px) 100vw, 512px" /><p>I&#8217;ve deployed several SQL Server Always On Availability Groups in the past with high availability being the primary requirement. In some environments, there is a requirement to protect sensitive data for security and compliance reasons. Back in 2013, I had a customer who wanted to implement Always On Availability Groups for their databases. They were moving their on-premise databases to a new hosting provider and wanted to make sure that the databases are protected at-rest. Their existing solution uses the <a href="http://windows.microsoft.com/en-us/windows/what-is-encrypting-file-system#1TC=windows-7" target="_blank" rel="noopener">Windows Encrypting File System feature</a> for encrypting the disk volumes that contain the database files and <a href="http://truecrypt.sourceforge.net/" target="_blank" rel="noopener">TrueCrypt</a> for the backups. But with the plan to move to a hosting provider, they need something that can do both because they don&#8217;t have the flexibility of keeping their existing solution. Besides, they already have the license for SQL Server 2012 Enterprise Edition, we might as well make the most out of it.</p>
<p>I also wrote an <a href="https://www.mssqltips.com/sqlservertip/3146/configuring-transparent-data-encryption-with-sql-server-2012-alwayson-availability-groups/" target="_blank" rel="noopener">article</a> that outlines what needs to be done to prepare their databases for the upgrade (since they were still on SQL Server 2008) and migration. And while the article has been very helpful for new deployments, not so much for existing Always On Availability Group implementations. Business requirements change frequently and you might need to implement Transparent Data Encryption (TDE) on your databases that are already in an Always On Availability Group configuration. If you follow the steps outlined in the article, you might end up causing issues on your Always On Availability Group databases depending on the amount of transactions generated. I&#8217;ve outlined the steps that you need to take if you would like to enable TDE on an existing database participating in an Always On Availability Group. I&#8217;m &#8220;<em>stealing</em>&#8221; the code examples in the article for reference.</p>
<ol>
<li><strong>Create a database master key on the primary replica</strong>. The <strong>Database Master Key</strong> creates a certificate in the <strong>master</strong> database. To create a database master key, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">USE MASTER<br />
</span><span style="color: black;">GO<br />
</span><span style="color: blue;">CREATE MASTER KEY ENCRYPTION BY </span><span style="color: black;">PASSWORD </span><span style="color: blue;">= </span><span style="color: red;">'mYC0mpl3XP@$$w0rd'<br />
</span><span style="color: black;">GO<br />
</span></code> </div></li>
<li><strong>Create a certificate protected by the database master key</strong>. Once we&#8217;ve created a database master key, we need to create a certificate protected by the database master key. This certificate is what we&#8217;ll use to protect the database encryption key (DEK) used to enable TDE. To create a certificate protected by the service master key, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">CREATE </span><span style="color: black;">CERTIFICATE TDECert<br />
</span><span style="color: blue;">WITH </span><span style="color: black;">SUBJECT </span><span style="color: blue;">= </span><span style="color: red;">'My TDE Certificate for all user database in the Availability Group'</span></code></div></li>
<li><strong>Create a database encryption key and use the certificate to protect it</strong>. After the certificate has been created, we can now create a database encryption key that we can use to enable TDE. You will need to do this on all of the databases that are already on the Always On Availability Group. To create  a database encryption key and protect it using the certificate, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">USE </span><span style="color: black;">[DemoSalesDB]<br />
GO<br />
</span><span style="color: blue;">CREATE DATABASE ENCRYPTION KEY<br />
WITH </span><span style="color: black;">ALGORITHM </span><span style="color: blue;">= </span><span style="color: black;">AES_128<br />
</span><span style="color: blue;">ENCRYPTION BY </span><span style="color: black;">SERVER CERTIFICATE TDECert<br />
GO </span></code> </div></li>
<li><strong>Backup the certificate to a file</strong>. This is where the process is a bit different from the <a href="https://www.mssqltips.com/sqlservertip/3146/configuring-transparent-data-encryption-with-sql-server-2012-alwayson-availability-groups/" target="_blank" rel="noopener">article</a>. If you enable TDE prior to restoring the certificate on the secondary replicas, the transaction log records won&#8217;t get applied to the secondary databases because they &#8220;<span style="color: #800000;"><em><strong>don&#8217;t</strong> </em><strong><em>speak the same language yet.</em></strong></span>&#8221; You want to make sure that the databases in an Always On Availability Group configuration &#8220;<em>speak the same language</em>&#8221; in order for the secondary replicas to properly receive the transaction log records from the primary replica and apply them to the log file. To backup the certificate to a file, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">USE MASTER<br />
</span><span style="color: black;">GO<br />
</span><span style="color: blue;">BACKUP </span><span style="color: black;">CERTIFICATE TDECert<br />
</span><span style="color: blue;">TO FILE = </span><span style="color: red;">'C:\TDECert_File.cer'<br />
</span><span style="color: blue;">WITH </span><span style="color: black;">PRIVATE </span><span style="color: blue;">KEY </span><span style="color: gray;">(</span><span style="color: blue;">FILE = </span><span style="color: red;">'C:\TDECert_Key.pvk' </span><span style="color: gray;">,<br />
</span><span style="color: blue;">ENCRYPTION BY </span><span style="color: black;">PASSWORD </span><span style="color: blue;">= </span><span style="color: red;">'mYC0mpl3XP@$$w0rd' </span><span style="color: gray;">)<br />
</span><span style="color: black;">GO</span></code> </div></li>
<li><strong>Copy the certificate to the secondary replicas</strong>. Once the certificate has been generated to a file, copy it to all of the secondary replicas. We will use this certificate to protect</li>
<li><strong>Create a database master key on the secondary replicas</strong>. Similar to what we did on the primary replica, we need to create a database master key on all of the secondary replicas. Repeat this step and all the steps below on all of your secondary replicas.To create a database master key, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">USE MASTER<br />
</span><span style="color: black;">GO<br />
</span><span style="color: blue;">CREATE MASTER KEY ENCRYPTION BY </span><span style="color: black;">PASSWORD </span><span style="color: blue;">= </span><span style="color: red;">'mYC0mpl3XP@$$w0rd'<br />
</span><span style="color: black;">GO<br />
</span></code></div></li>
<li><strong>Create a certificate on all of the secondary replicas using the certificate file from the primary replica</strong>. Once we&#8217;ve created a database master key on the secondary replicas, we need to create a certificate based on the one that we generated and copied from the primary replica. To create the certificate on all of the secondary replicas, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">USE MASTER<br />
</span><span style="color: black;">GO<br />
</span><span style="color: blue;">CREATE </span><span style="color: black;">CERTIFICATE TDECert<br />
</span><span style="color: blue;">FROM FILE = </span><span style="color: red;">'C:\TDECert_File.cer'<br />
</span><span style="color: blue;">WITH </span><span style="color: black;">PRIVATE </span><span style="color: blue;">KEY </span><span style="color: gray;">(</span><span style="color: blue;">FILE = </span><span style="color: red;">'C:\TDECert_Key.pvk'</span><span style="color: gray;">,<br />
</span></code><code><span style="color: blue;">DECRYPTION BY </span><span style="color: black;">PASSWORD </span><span style="color: blue;">= </span><span style="color: red;">'mYC0mpl3XP@$$w0rd' </span><span style="color: gray;">)</span>;</code> </div></li>
<li><strong>Enable TDE on all of the databases in the Always On Availability Group</strong>. Now that we have given all of the Always On Availability Group replicas a &#8220;<em>common language to use to talk to each other,</em>&#8221; we can go ahead and enable TDE on all of the databases in the Always On Availability Group. And since enabling this feature generates transaction log records, all of the databases in the secondary replicas will also have TDE turned on. Note that you still have to do this on a per-database level. To enable TDE on the database in an Always On Availability Group, <div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><code style="font-size: 14px;"><span style="color: blue;">ALTER DATABASE </span><span style="color: black;">[DemoSalesDB]<br />
</span><span style="color: blue;">SET ENCRYPTION ON</span></code> </div></li>
</ol>
<p>Note that the steps are a bit different from the one described in the article because we don&#8217;t want to cause any disruption on the existing Always On Availability Group configuration. Our goal is still maintaining high availability while meeting security and compliance requirements.</p>
<h3>Additional Resources</h3>
<ul>
<li><a href="https://www.mssqltips.com/sqlservertip/3146/configuring-transparent-data-encryption-with-sql-server-2012-alwayson-availability-groups/" target="_blank" rel="noopener">Configuring Transparent Data Encryption with SQL Server 2012 Always On Availability Groups</a></li>
<li><a href="https://www.mssqltips.com/sqlservertip/1507/implementing-transparent-data-encryption-in-sql-server-2008/" target="_blank" rel="noopener">Implementing Transparent Data Encryption in SQL Server 2008</a> (still applicable in SQL Server 2012 and 2014)</li>
<li><a href="https://msdn.microsoft.com/en-us/library/bb934049.aspx" target="_blank" rel="noopener">SQL Server Transparent Data Encryption (TDE)</a></li>
</ul>
<hr />
<h2>Feeling helpless and confused when dealing with Windows Server Failover Clustering  (WSFC) for your SQL Server databases?</h2>
<p>You&#8217;re not alone. I&#8217;ve heard the same thing from thousands of SQL Server administrators throughout my entire career. These are just a few of them.</p>
<p><span style="color: #0000ff;"><em>&#8220;How do I properly size the server, storage, network and all the AD settings which we do not have any control over?&#8221;</em></span></p>
<p><span style="color: #0000ff;"><em>&#8220;I don&#8217;t quite understand how the Windows portion of the cluster operates and interacts with what SQL controls.&#8221;</em></span></p>
<p><span style="color: #0000ff;"><em>&#8220;I&#8217;m unfamiliar with multi-site clustering.&#8221;</em></span></p>
<p><span style="color: #0000ff;">&#8220;<em>Our servers are setup and configured by our parent company, so we don&#8217;t really get much experience with setting up Failover Clusters.</em>&#8220;</span></p>
<p>If you feel the same way, then, this course is for you. It&#8217;s a simple and easy-to-understand way for you to learn and master how Windows Server Failover Clusters can keep your SQL Server databases highly available. Be confident in designing, building and managing SQL Server databases running on Windows Server Failover Clusters.</p>
<p>But don&#8217;t take my word for it. Here&#8217;s what my students have to say about the course.</p>
<p><span style="color: #0000ff;"><em>&#8220;The techniques presented were very valuable, and used them the following week when I was paged on an issue.&#8221;</em></span></p>
<p><span style="color: #0000ff;"><em>&#8220;Thanks again for giving me confidence and teaching all this stuff about failover clusters.&#8221;</em></span></p>
<p><span style="color: #0000ff;"><em>&#8220;I’m so gladdddddd that I took this course!!&#8221;</em></span></p>
<p><span style="color: #0000ff;"><em>&#8220;Now I got better knowledge to setup the Windows FC ENVIRONMENT (DC) for SQL Server FCI and AlwaysON.&#8221;</em></span></p>
<div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"><span style="color: #800000;"><strong>NOTE:</strong></span> Registration for my online course <a href="https://learnsqlserverhadr.com/" target="_blank" rel="noopener"><span style="color: #800000;"><strong>Windows Server Failover Clustering (WSFC) for the Smart SQL Server DBA</strong></span></a> will re-open in <span style="color: #0000ff;"><strong>January 2018</strong></span>. But be sure you do not miss out. This will be the last time that the course will be offered. After this, you will no longer be able to register for the course.</div>
<hr />
<div style="background-color:#eeeeee;border:1px solid #D6D6D6;font-family:arial,helvetica,sans-serif;font-size:15px;line-height:20px;margin:8px 0 20px;padding:15px 20px;"></p>
<p><!-- Begin MailChimp Signup Form --></p>
<style type="text/css">
	#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }<br />	/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.<br />	   We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */<br /></style>
<p>&nbsp;</p>
<div id="mc_embed_signup">
<form id="mc-embedded-subscribe-form" class="validate" action="//EdwinMSarmiento.us4.list-manage.com/subscribe/post?u=08cdb91518ee67ce09d618509&amp;id=46cff8469f" method="post" name="mc-embedded-subscribe-form" novalidate="" target="_blank">
<div id="mc_embed_signup_scroll">
<h2>Get notified about the next batch of enrollment so you don&#8217;t miss out.</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group"><label for="mce-EMAIL">Email Address <span class="asterisk">*</span><br />
</label><br />
<input id="mce-EMAIL" class="required email" name="EMAIL" type="email" value="" /></div>
<div class="mc-field-group"><label for="mce-FNAME">First Name </label><br />
<input id="mce-FNAME" class="" name="FNAME" type="text" value="" /></div>
<div id="mce-responses" class="clear"></div>
<p><!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--></p>
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input tabindex="-1" name="b_08cdb91518ee67ce09d618509_46cff8469f" type="text" value="" /></div>
<div class="clear"><input id="mc-embedded-subscribe" class="button" name="subscribe" type="submit" value="Keep me updated!" /></div>
</div>
</form>
</div>
<p><script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script><br />
<!--End mc_embed_signup--><br />
</div>
]]></content:encoded>
			

		<wfw:commentRss>https://www.edwinmsarmiento.com/how-to-enable-transparent-data-encryption-in-an-existing-sql-server-availability-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
				<post-id xmlns="com-wordpress:feed-additions:1">2201</post-id>	</item>
	</channel>
</rss>