<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Zafar Kapadia's blogs</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/zkap/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/zkap/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:10:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Options to migrate Classic ASP and VB6 Applications from Windows 2003  to Windows 2012</title>
      <link>https://docs.microsoft.com/archive/blogs/zkap/options-to-migrate-classic-asp-and-vb6-applications-from-windows-2003-to-windows-2012</link>
      <pubDate>Tue, 04 Apr 2017 13:51:27 GMT</pubDate>
      <dc:creator><![CDATA[zafarx]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/zkap/?p=56</guid>
      <description><![CDATA[Below are some options to migrate Classic ASP and VB6 Applications from Windows 2003  to Windows...]]></description>
      <content:encoded><![CDATA[Below are some options to migrate Classic ASP and VB6 Applications from Windows 2003  to Windows 2012.

<strong>Option 1: Lift and Shift Applications to Windows 2012
</strong>
Classic ASP applications may be moved as is to Windows 2012 by enabling IIS 8.5 for hosting Classic ASP applications. This approach can be used if we do not have the VB6 or COM source code available.
<ol>
 	<li>Please follow the <a href="https://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-not-installed-by-default-on-iis">article</a> from IIS team to setup IIS 7.0 or above for hosting classic ASP sites.</li>
 	<li>Register any COM and VB6 Dll’s using the regserv32.exe command as shown below:

<em>%systemroot%\SysWoW64\regsvr32.exe &lt;path to dll&gt;\&lt;dll name&gt;
</em><em>Or
</em>C:\Windows\System32\regsvr32.exe &lt;path to dll&gt;\&lt;dll name&gt;</li>
 	<li>Once you have the COM and VB6 DLL’s registered move the site to the target Application Pool with 32 Bit Application hosting enabled for the Application Pool hosting the site as shown below.

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/IISB.png"><img width="242" height="300" class="size-medium wp-image-95 aligncenter" alt="iisb" src="https://msdnshared.blob.core.windows.net/media/2017/04/IISB-242x300.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2017/04/IIS.png"></a></li>
 	<li>Make any modifications such as updating connection strings, drivers if required to get the site working.</li>
 	<li>Test the site and see if the lift and shift was successful.</li>
</ol>
<strong>Option 2: Upgrade the Classic ASP site to ASP.NET and VB6 code to VB.NET/C#</strong>

If we have the source code available and are not able to easily lift and shift applications to Windows 2012, then we can migrate the code to ASP.NET and VB.NET/C# using the tools below.
<ol>
 	<li>Use the <a href="https://www.asp.net/downloads/archived-v11/migration-assistants/asp-to-aspnet">ASP Migration Asisstant</a> to upgrade classic ASP code to ASP.NET. You will need to run this tool with Code on a Windows XP machine. You can create a Virtual PC VM on Windows 7 with Windows XP. Please see <a href="https://technet.microsoft.com/en-us/magazine/hh859554.aspx">article</a> to setup Windows XP mode on Windows 7.</li>
 	<li>Convert VB6 to VB.NET/C# using migration utilities. Other teams at American Airlines have used the <a href="https://msdn.microsoft.com/en-us/vstudio/ff793478.aspx">VBUC tool</a>.</li>
 	<li>Though the migration tools will convert the VB6 code to VB.NET/C#, you may have to change the way objects are created and referenced from the ASP.NET pages. Other code changes may be required depending on the application.</li>
 	<li>Make any modifications such as updating connection strings, drivers if required to get the site / application working.</li>
 	<li>We must rebuild the code targeting .NET 4.6.1 after all the migration is complete.</li>
 	<li>Test the site/application and see if everything works successfully.</li>
</ol>
<strong>Option 3: Re-Write the Application</strong>

If all of the above methods fail, we can re-write the application in ASP.NET (Web Forms or MVC) if feasible.]]></content:encoded>
    </item>
    <item>
      <title>Make your HTML5 Application Location Aware using GeoLocation API and Bing Maps API</title>
      <link>https://docs.microsoft.com/archive/blogs/zkap/make-your-html5-application-location-aware-using-geolocation-api-and-bing-maps-api</link>
      <pubDate>Mon, 08 Dec 2014 22:35:00 GMT</pubDate>
      <dc:creator><![CDATA[zafarx]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/zkap/2014/12/08/make-your-html5-application-location-aware-using-geolocation-api-and-bing-maps-api/</guid>
      <description><![CDATA[This blog will show you how to make your HTML5 Application Location Aware using use the GeoLocation...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">This blog will show you how to make your HTML5 Application Location Aware using use the GeoLocation API with the Bing Maps AJAX Control.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Before we start you will need to obtain a Bing Maps Key.Please visit <a href="https://msdn.microsoft.com/en-us/library/ff428642.aspx">https://msdn.microsoft.com/en-us/library/ff428642.aspx</a> to&nbsp;get a Bing Maps Key.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">To begin, create an ASP.NET Empty Web Application as shown below.</span><br /><br /><span style="font-family: arial,helvetica,sans-serif;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1401.Image1.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1401.Image1.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1401.Image1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1401.Image1.PNG" alt="" border="0" /></a></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">Add a HTML Page to the project. You can right click on the ExampleGeoLocationBing project in Solution Explorer, click on Add and then click HTML Page as shown below. </span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3010.Image2.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3010.Image2.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3010.Image2.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3010.Image2.PNG" alt="" border="0" /></a></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">Name the page default when requested to &ldquo;Specify the Name for the Item&rdquo; as shown below. Click on OK.</span></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2543.Image3.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2543.Image3.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2543.Image3.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2543.Image3.PNG" alt="" width="379" height="117" border="0" /></a></span></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">You should now see the default.html file created as shown below.</span></span></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6874.Image4.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6874.Image4.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6874.Image4.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6874.Image4.PNG" alt="" border="0" /></a></span></span></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">In the&nbsp;HTML document, add the onLoad attribute to the body element which will invoke the initializeGeoLocation function when the web page loads in the browser. In the body element, create a div element with an id &ldquo;map&rdquo;. The HTML code can be seen below.</span></span></span></span></p>
<p><span style="line-height: 107%; font-family: arial,helvetica,sans-serif; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="line-height: 107%; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4848.Image5.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4848.Image5.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4848.Image5.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4848.Image5.PNG" alt="" width="409" height="244" border="0" /></a></span></span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now add a script element in the head element of the HTML document for the Bing Maps AJAX Control. </span><br /><br /><span style="font-family: courier new,courier; font-size: small;">&lt;script src="https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"&gt;&lt;/script&gt;</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Add a folder called Scripts to the ExampleGeoLocationBing project.</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1856.Image6.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1856.Image6.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1856.Image6.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1856.Image6.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Right click the Scripts folder and add a JavaScript file as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5224.Image7.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5224.Image7.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5224.Image7.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5224.Image7.PNG" alt="" border="0" /></a></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="line-height: 107%; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">Name the file GeoLocation when requested to Specify the Name for the Item. Click on OK. You should now see the GeoLocation.js file in the Scripts folder as shown below.</span></span></p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4405.Image8.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4405.Image8.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4405.Image8.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4405.Image8.PNG" alt="" width="399" height="327" border="0" /></a></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Open the GeoLocation.js file by double clicking on it. Add the code below for the GeoLocation API and the Bing Map API as shown below.</span></p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6114.Image9.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6114.Image9.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6114.Image9.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6114.Image9.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">In the above code the initializeGeoLocation function creates the geolocation object by utilizing the navigator.geolocation variable. The geolocation object calls the getCurrentPosition method which determines the current position of the user. To this method we pass in the getPosition function. The getPosition function is passed the position object which contains the coords property. The coords property gets the coordinates object which has the latitude and longitude properties. The latitude and longitude properties get the latitude and longitude in decimal degrees.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">The getPosition function also initializes a new instance of the Map class. We pass in the container element (which is the div element with map as its id) and the Bing Map Key as arguments. We initialize a new instance of the Location class, which takes the latitude and longitude as arguments. We then initialize a new instance of the Pushpin class which adds a pushpin on the map. We add the Pushpin to the entities property of the map. This will add a pushpin to the current latitude and longitude coordinates of the user returned by the Location class.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Next, we set the map view using the specified coordinates as the center and the zoom level.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now, return to the default.html page and add a script element for the GeoLocation.js file to the head element. The code for the HTML page should look as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5241.Image10.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5241.Image10.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5241.Image10.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5241.Image10.PNG" alt="" border="0" /></a></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Set the default.html page as the start page. To do so, right click on the default.html file and select &ldquo;Set As Start Page&rdquo;.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now press F5 to launch the application in a browser. You should see results similar to the one shown below.</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5824.Image12.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5824.Image12.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5824.Image12.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5824.Image12.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">If you wish to add some styling to the HTML content, add a new folder called Styles to the project ExampleGeoLocationBing. Right Click on the ExampleGeoLocationBing project in Solution Explorer, click on Add and then click on New Folder as shown below. Name the folder Styles.<br /></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8358.Image13.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8358.Image13.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8358.Image13.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8358.Image13.PNG" alt="" border="0" /></a><br /></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Add a new Style Sheet to the Styles folder called default.css. Right Click on the Styles folder, Click on Add and then select Style Sheet as shown below.<br /></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2677.Image14.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2677.Image14.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2677.Image14.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2677.Image14.PNG" alt="" border="0" /></a><br /></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="line-height: 107%; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">Name the Style Sheet default when requested to &ldquo;Specify the Name for the Item&rdquo;. You should now see the default.css Style Sheet in the Styles folder as shown below.</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4403.Image15.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4403.Image15.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4403.Image15.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4403.Image15.PNG" alt="" width="401" height="382" border="0" /></a></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Open the default.css Style Sheet and add the following code to it to center the body of the HTML and set the position, width and height of the div element with id map.</span></p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3073.Image16.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3073.Image16.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3073.Image16.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3073.Image16.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now press F5 to launch the application in a browser. You should see results similar to the one shown below.</span></p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0143.Image17.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0143.Image17.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0143.Image17.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0143.Image17.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Consume ASP.NET Web API hosted in Windows Azure from  HTML5 and JavaScript Windows Store Application using WinJS.xhr</title>
      <link>https://docs.microsoft.com/archive/blogs/zkap/consume-asp-net-web-api-hosted-in-windows-azure-from-html5-and-javascript-windows-store-application-using-winjs-xhr</link>
      <pubDate>Wed, 02 Oct 2013 18:00:00 GMT</pubDate>
      <dc:creator><![CDATA[zafarx]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/zkap/2013/10/02/consume-asp-net-web-api-hosted-in-windows-azure-from-html5-and-javascript-windows-store-application-using-winjs-xhr/</guid>
      <description><![CDATA[In this blog we will look at consuming an ASP.NET Web API which is hosted in Windows Azure from an...]]></description>
      <content:encoded><![CDATA[<p>In this blog we will look at consuming an ASP.NET Web API which is hosted in Windows Azure from an HTML application using&nbsp;WinJS.xhr.&nbsp;</p>
<p><strong>Task 1: Create a Database in Azure</strong></p>
<p>First we will create a database in Windows Azure which will be exposed using the Web API. <span style="font-family: arial,helvetica,sans-serif; font-size: small;">In this example&nbsp;I am&nbsp;using the SyncDB database and the Products table. You can&nbsp;use this <a title="Walkthrough" href="https://msdn.microsoft.com/en-us/library/ff928549.aspx">Walkthrough</a> to create the&nbsp;SyncDB database.</span></p>
<p>Logon to the <a title="https://manage.windowsazure.com" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Windows Azure Portal">Windows Azure Portal</a>. After you have logged in you will see the portal as shown below. Click on <strong>SQL Databases</strong> link on the left menu and then click on <strong>New</strong> as shown below.</p>
<p style="text-align: center;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3465.1.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3465.1.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3465.1.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x550/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3465.1.JPG" alt="" border="0" /></a></p>
<p style="text-align: left;">&nbsp;</p>
<p style="text-align: left;">You will see the options below. Select <strong>Data Services</strong> -&gt; <strong>SQL Database</strong> -&gt; <strong>Quick Create</strong>. In the <strong>Database Name</strong> text box enter <strong>SyncDB</strong> and then click on <strong>Create SQL Database</strong>. See the figure below for reference.</p>
<p style="text-align: center;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4532.2.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4532.2.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4532.2.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4532.2.JPG" alt="" border="0" /></a></p>
<p style="text-align: left;">&nbsp;</p>
<p style="text-align: left;">Once you have created the new SQL Database you will see SyncDB in the list of databases on the management portal as shown below. Click on the <strong>SyncDB</strong> database.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3857.3.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3857.3.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3857.3.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3857.3.JPG" alt="" border="0" /></a><br /><br />When you click on the SyncDB database you will see the screen below. Click on <strong>Manage</strong> at the bottom of the screen (you might have to click on it multiple times).<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8738.4.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8738.4.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8738.4.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8738.4.JPG" alt="" border="0" /></a></p>
<p><span style="color: #000000;">This will take you to the SQL Database Management portal login screen. Enter the Database server username and password and click on Log on. This is the username and password you chose when you first created the</span> Database Server.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7701.5.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7701.5.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7701.5.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7701.5.JPG" alt="" border="0" /></a></p>
<p>Once you login to the SQL Database Management portal you will see the screen below. Click on <strong>New Query</strong>.</p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6278.6.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6278.6.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6278.6.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6278.6.JPG" alt="" border="0" /></a></p>
<p>Once the New Query window opens enter the SQL code from the <a title="Walkthrough" href="https://msdn.microsoft.com/en-us/library/ff928549.aspx">Walkthrough</a> (only enter code starting from line USE [SyncDB]&nbsp; onward) and click <strong>Run</strong> as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8611.7.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8611.7.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8611.7.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8611.7.JPG" alt="" border="0" /></a></p>
<p>The SQL Code will execute as shown below.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6471.8.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6471.8.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6471.8.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6471.8.JPG" alt="" border="0" /></a></p>
<p>You can now close the query window. Go back to the Windows Azure Management Portal, click on SQL Databases on the left menu and then click on Servers and then select your database server from the list as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2086.10.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2086.10.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2086.10.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2086.10.JPG" alt="" border="0" /></a><br /><br /></p>
<p>You will then see the Dashboard for the database server. Click on the Configure option and make sure the Windows Azure Services under allowed services section has Yes selected as shown below. Hence our Web API will be able to connect to the SQL Server.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0216.11.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0216.11.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0216.11.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0216.11.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><strong>Task 2: Create an ASP.NET Web API</strong></p>
<p>Before we create a Web API in Azure we need to install the <a title="Windows Azure SDK for Visual Studio 2012" href="https://www.windowsazure.com/en-us/develop/net/?slideshow=5">Windows Azure SDK for Visual Studio 2012</a>. <br /><br />After you have installed the SDK open Visual Studio 2012 and create a new project. From the Installed templates select <strong>Windows Azure Cloud Service</strong>. In the Name text box type <strong>ProductWebAPI</strong> and click <strong>OK</strong> as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0434.19.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0434.19.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0434.19.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0434.19.JPG" alt="" border="0" /></a><br />You will then see the <strong>New Windows Azure Cloud Service</strong> dialog box. Select <strong>ASP.NET MVC 4 Web Role</strong> and add it to the <strong>Windows Azure Cloud Service Solution</strong> as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7610.21.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7610.21.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7610.21.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7610.21.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Then from the <strong>New ASP.NET MVC 4 Project</strong> Dialog box select <strong>Web API</strong> template. Click on <strong>OK</strong>. See the figure below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8078.22.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8078.22.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8078.22.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8078.22.JPG" alt="" border="0" /></a></p>
<p>Once you click OK, you will see the <strong>ProductWebAPI </strong>solution with the <strong>MvcWebRole1</strong> project. We will modify the <strong>Get</strong> method in the <strong>ValuesController.cs </strong>class to get a list of products from our <strong>SyncDB</strong> database.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3817.23.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3817.23.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3817.23.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3817.23.JPG" alt="" border="0" /></a></p>
<p>Before we modify the C# code, we need to get the connection string to connect to the <strong>SyncDB</strong> database. To get the connection string go to the Windows Azure Management Portal, click on the <strong>SQL Databases</strong> and click on the <strong>SyncDB</strong> database as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8713.24.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8713.24.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8713.24.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8713.24.JPG" alt="" border="0" /></a></p>
<p>Click on <strong>Dashboard</strong> and click on <strong>Show connection strings</strong> on the bottom right.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7608.25.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7608.25.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7608.25.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7608.25.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>When you see the <strong>Connection Strings</strong> select the ADO.NET connection string as shown below. Replace {your_password_here} with the Server Password.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8372.26.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8372.26.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8372.26.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8372.26.JPG" alt="" border="0" /></a><br /><br />Before we modify the Get method add the following namespaces to the code.<br /><span style="font-family: courier new,courier;"><strong><span style="color: #000080;">using</span></strong> System.Data;</span><br /><span style="font-family: courier new,courier;"><strong><span style="color: #000080;">using</span></strong> System.Data.SqlClient;</span></p>
<p>The modified Get method is shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1727.27.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1727.27.JPG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1727.27.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1727.27.JPG" alt="" border="0" /></a><br /><strong>Task 3: Deploy the Web API to the Cloud</strong></p>
<p>Since we have created the Web API we will now deploy the Web API to the cloud. In order to do so we will first create a new Cloud Service. Go back to the Windows Azure Management Portal and click on Cloud Services from the left menu. Then click on Create a Cloud Service as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0535.28.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0535.28.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0535.28.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0535.28.JPG" alt="" border="0" /></a></p>
<p>You will then see&nbsp;the screen below. I have named my URL <strong>productwebapi </strong>as shown below. Click on <strong>Create Cloud Service</strong>.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4846.29.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4846.29.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4846.29.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4846.29.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>We can see that the Cloud Service has been created.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3240.30.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3240.30.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3240.30.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3240.30.JPG" alt="" border="0" /></a></p>
<p>We will now package our Web API and then upload it to the <strong>productwebapi</strong> cloud service.</p>
<p>Lets go back to Visual Studio 2012, right click on <strong>ProductWebAPI</strong> Project and click on <strong>Package</strong> as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7271.31.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7271.31.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7271.31.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7271.31.JPG" alt="" border="0" /></a></p>
<p>When you see the <strong>Package Windows Azure Application</strong> dialog box, click <strong>Package</strong>.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8510.32.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8510.32.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8510.32.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8510.32.JPG" alt="" border="0" /></a></p>
<p><br />The packaged files are now available on my computer at the location shown below (please note the location). We can see the package and configuration files.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1072.33.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1072.33.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1072.33.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1072.33.JPG" alt="" border="0" /></a></p>
<p>We now go back to the Windows Azure Management Portal, click on Cloud Services and then select the <strong>productswebapi</strong> cloud service. We then click on <strong>Upload a New Production Deployment</strong> as shown below.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1220.34.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1220.34.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1220.34.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1220.34.JPG" alt="" border="0" /></a></p>
<p>Enter the Deployment Label, the Package and the Configuration&nbsp;files (these were created and stored locally on the computer and we noted the location). Click on the check to complete the upload as shown.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0385.35.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0385.35.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0385.35.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0385.35.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>It will take a few minutes to complete the deployment. Till then you will see screen below.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6505.36.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6505.36.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6505.36.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6505.36.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Once the deployment is complete you will see the screen below. Our site URL is <a href="https://productwebapi.cloudapp.net/">https://productwebapi.cloudapp.net/</a>.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7750.38.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7750.38.JPG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/7750.38.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/7750.38.JPG" alt="" border="0" /></a></p>
<p>We can access the Get method from a browser by&nbsp;appending&nbsp;<a title="api/values  " href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/api/values">api/values</a> to the end of the&nbsp;link. When we go to the link <a href="https://productwebapi.cloudapp.net/api/values">https://productwebapi.cloudapp.net/api/values</a>&nbsp;we will be prompted to save or open the&nbsp;file containing JSON data.</p>
<p><strong>Task 4: Create a Windows Store App using HTML and JavaScript to consume the Web API</strong></p>
<p>Open Visual Studio 2012 and click on the New Project link as shown below.<br /><br /></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2538.1.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2538.1.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2538.1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2538.1.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>From the <strong>New Project Dialog Box</strong> select <strong>Templates</strong> -&gt; <strong>Other Languages</strong> -&gt; <strong>JavaScipt</strong>. In the center pane select <strong>Blank App</strong>. In the Name text box type<strong> productApp</strong> and click <strong>OK</strong> as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0451.2.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0451.2.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0451.2.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0451.2.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Once you click on <strong>OK </strong>the new project is created as shown below. Double Click on the <strong>default.html</strong> file to open it.<br /><br /></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5353.3.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5353.3.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5353.3.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5353.3.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>In the <strong>default.html</strong> file replace the code in the <strong><span style="color: #0000ff;">&lt;</span><span style="color: #993300;">body</span><span style="color: #0000ff;">&gt;</span></strong> section with the code below. <br /><br /></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1108.4.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1108.4.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1108.4.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1108.4.PNG" alt="" border="0" /></a><br /><br />In the <strong>productApp</strong> project expand the <strong>css</strong> folder and open the <strong>default.css</strong> file.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3247.5.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3247.5.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3247.5.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3247.5.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>In the <strong>default.css</strong> file add the CSS rule for the body element as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4861.6.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4861.6.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/4861.6.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/4861.6.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Now we need to add the <strong>JQuery</strong> library to our Solution. Click on the <strong>Project</strong> menu and select <strong>Manage Nuget Packages </strong>as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1323.7.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1323.7.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/1323.7.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/1323.7.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>In the Manage NuGet Packages dialog box search for jQuery in the top right hand side. Then from the middle pane once you see the jQuery library, click on the Install button as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3617.8.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3617.8.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/3617.8.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/3617.8.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Once the jQuery library is installed a green check is placed next to the jQuery library in the middle pane as shown below. Close the dialog box.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6082.9.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6082.9.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6082.9.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6082.9.PNG" alt="" border="0" /></a></p>
<p>Now you should see the jQuery files in the Scripts folder in the Solution explorer as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6254.10.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6254.10.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/6254.10.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/6254.10.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Go back to the default.html file and drag the jquery-2.0.3.min.js file&nbsp;under&nbsp;the productApp references section as shown below. We will need to use the jQuery library to populate the table body with id <strong>productList</strong>.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2477.11.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2477.11.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/2477.11.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/2477.11.PNG" alt="" border="0" /></a>&nbsp;</p>
<p>Now we go back to the <strong>default.js</strong> file and add an event handler for the Get Products button. In the <strong>default.js</strong>file after the <strong>app.oncheckpoint</strong> function, add the <strong>buttonGetProductsClickHandler</strong> function as shown below.This function uses the <strong>WinJS.xhr</strong> to consume the Web API and populates the JSON data received from the Web API into the table body with id <strong>productList</strong>. The url used to call the Web API and&nbsp;get the JSON data is <span style="color: #a31515; font-family: Consolas; font-size: x-small;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><a href="https://productwebapi.cloudapp.net/api/values">https://productwebapi.cloudapp.net/api/values</a>&nbsp;</span></span></span></p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8611.12.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8611.12.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/8611.12.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/8611.12.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Finally we need to register the <strong>buttonGetProductsClickHandler </strong>event handler. We register the&nbsp;event handler&nbsp;in the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/br212679.aspx"><strong>onactivated</strong></a>&nbsp;event handler in default.js, we retrieve getProducts and use <a href="https://msdn.microsoft.com/en-us/library/windows/apps/hh441145.aspx"><strong>addEventListener</strong></a> to register our event handler for the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/hh441312.aspx"><strong>click</strong></a> event. Add this code after the call to <a href="https://msdn.microsoft.com/en-us/library/windows/apps/hh440975.aspx"><strong>WinJS.UI.processAll</strong></a>&nbsp;as shown below.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0602.13.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0602.13.PNG"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0602.13.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0602.13.PNG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Now test the application in the Windows 8 Simulator as shown below.<br /><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0820.14.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0820.14.PNG"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/0820.14.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/0820.14.PNG" alt="" border="0" /></a></p>
<p>When you click on<strong> Get Products</strong> button in the simulator you will see the products displayed as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5807.15.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5807.15.png"><img style="margin-right: auto; margin-left: auto; display: block;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/52/02/5807.15.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-52-02/5807.15.png" alt="" border="0" /></a><br /><br />That's it! We have successfully created a HTML and JavaScript Windows Store Application which consumes a Web API hosted in WIndows Azure using WinJS.xhr.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Synchronize SQL Server and SQL Azure using Sync Framework</title>
      <link>https://docs.microsoft.com/archive/blogs/zkap/synchronize-sql-server-and-sql-azure-using-sync-framework</link>
      <pubDate>Thu, 12 Apr 2012 15:18:00 GMT</pubDate>
      <dc:creator><![CDATA[zafarx]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/zkap/2012/04/12/synchronize-sql-server-and-sql-azure-using-sync-framework/</guid>
      <description><![CDATA[In this Blog, I will discuss Synchronizing data between an On-Premise SQL Server database and a SQL...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">In this Blog, I will discuss Synchronizing data between an On-Premise SQL Server database and a SQL Azure database in the Cloud using Microsoft Sync Framework. There are others&nbsp;ways of synchronizing data between On-Premise SQL Server databases and SQL Azure databases, but this blog is focused&nbsp;on using&nbsp;Microsoft Sync Framework and C# code to synchronize data.<br /> <br />Before we begin you will need to download and install Microsoft Sync Framework from the <a href="https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=23217">Microsoft Download Center</a>.&nbsp;You will also need to add references to the following DLL files after you have installed the Microsoft Sync Framework.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Microsoft.Synchronization.dll </span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Microsoft.Synchronization.Data.dll </span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Microsoft.Synchronization.Data.SqlServer.dll</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">In this example&nbsp;I am&nbsp;using the SyncDB database and the Products table. You can&nbsp;use this <a href="https://msdn.microsoft.com/en-us/library/ff928549.aspx">Walkthrough</a> to create the&nbsp;SyncDB database.&nbsp;<br /><br /></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;">I am also using a DBConnection class which stores and returns my database connection strings.</span> <br /><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now lets discuss the Synchronization. There are two ways to structure your application to synchronize data between SQL Server Database and SQL Azure Database. You could either use 2-tier architecture or N-tier architecture. The difference between the two is as follows:</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">2 - Tier Architecture - With this option the Sync Framework runs on the local computer and uses a <a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncprovider.aspx">SqlSyncProvider</a>&nbsp;object to connect the SQL Azure database with a SQL Server database.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">N &ndash; Tier Architecture &ndash; With this option the Sync Framework database provider runs in a Windows Azure hosted service and communicates with a proxy provider that runs on the local computer.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">In this blog will implement a 2 &ndash; Tier Architecture.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">To synchronize On-Premise SQL Server database with a SQL Azure database in the cloud we will complete the tasks below.</span></p>
<ol>
<li><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Define the scope based on the tables from the SQL Server database, then provision the SQL Server and SQL Azure databases. </span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">This will prepare the SQL Server and SQL Azure databases for Synchronization.</span></li>
<li><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Synchronize the SQL Server and SQL Azure databases after they have been configured for synchronization as per step 1.</span></li>
<li><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Optionally if you wish you can use the SqlSyncDeprovisioning class to&nbsp;deprovision the specified scope and remove all associated synchronization elements from the database.</span></li>
</ol>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b>Task 1: Scope the SQL Server database and then provision SQL Server and SQL Azure databases.</b></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Below are the Sync Framework Classes we will use to scope the SQL Server Database and then provision the SQL Server and SQL Azure databases,</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.dbsyncscopedescription.aspx">DbSyncScopeDescription</a></b>&nbsp;- Represents a synchronization scope, which is a logical grouping of tables (optionally filtered) that are synchronized as a unit.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.dbsynctabledescription.aspx">DbSyncTableDescription</a></b>&nbsp;- Represents the schema of a table that is included in the Tables list of a DbSyncScopeDescription object. This is used during database provisioning.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncdescriptionbuilder.aspx">SqlSyncDescriptionBuilder</a></b>&nbsp;- Represents scope and table information for a SQL Server database that is involved in synchronization.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncscopeprovisioning.aspx">SqlSyncScopeProvisioning</a></b>&nbsp;- Represents the provisioning of a SQL Server database for a particular scope that is represented by a <a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.dbsyncscopedescription.aspx">DbSyncScopeDescription</a> object.</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We will now write the method to scope and provision the databases.The first thing we will do is to create two SqlConnection objects to connect to the SQL Server and SQL Azure databases as shown below. </span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to on premise SQL Server database<br />&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> onPremiseConn =&nbsp;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLServer);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to SQL Azure database<br />&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> azureConn =&nbsp;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLAzure);</span></span></span></p>
<p><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We will then use the Sync Framework classes to create scope, choose the tables and choose the columns within the tables and add them to the scope. Below is the code which accomplishes the task.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We create the scope named <b>&ldquo;product&rdquo;</b> using the <b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.dbsyncscopedescription.aspx">DbSyncScopeDescription</a></b>&nbsp;class shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncScopeDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> productScope =&nbsp;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncScopeDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Then we select the columns from the dbo.Products table to be included by adding them to a Collections object. We select the ID, Name and ListPrice columns as shown below. </span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><br />Collection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&lt;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">string</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&gt; includeColumns = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">Collection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&lt;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">string</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&gt;();<br /></span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ID"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br /></span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"Name"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br /></span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ListPrice"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;" face="Consolas" size="2"><span face="Consolas" size="2"></span></span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We then define the schema for the <strong>dbo.Products</strong> table using the <b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.dbsynctabledescription.aspx">DbSyncTableDescription</a></b>&nbsp;and<b> <a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncdescriptionbuilder.aspx">SqlSyncDescriptionBuilder</a></b>&nbsp;classes shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncTableDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> productDescription =&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncDescriptionBuilder</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.GetDescriptionForTable(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">,&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">includeColumns, onPremiseConn);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">After the schema for the dbo.Products table has been defined we add it to the Tables collection of productScope as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">productScope.Tables.Add(productDescription);</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now we create a SQL Sync Provisioning object using the <b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncscopeprovisioning.aspx">SqlSyncScopeProvisioning</a></b>&nbsp;class for the on premise SQL Server as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;SqlSyncScopeProvisioning <span face="Consolas" size="2"><span face="Consolas" size="2">onPremiseProvision =&nbsp;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(onPremiseConn, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; productScope);</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We filter rows for the specific ListPrice column and then filter the rows based on the criteria defined below. [side] is an alias for the tracking table.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">onPremiseProvision.Tables[<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">].AddFilterColumn(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ListPrice"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br /></span></span>onPremiseProvision.Tables[<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">].FilterClause = </span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"[side].[ListPrice]&lt;'600'"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">;</span></span></span></p>
<p><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">if</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> (!onPremiseProvision.ScopeExists(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">))<br />&nbsp;&nbsp;&nbsp;&nbsp; </span></span>onPremiseProvision.Apply();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We create a SQL Sync Provisioning object for the SQL Azure database using the <b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncscopeprovisioning.aspx">SqlSyncScopeProvisioning</a></b>&nbsp;class as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> azureProvision =&nbsp;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(azureConn, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">productScope);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">Apply the provisioning to the <strong>&ldquo;product&rdquo;</strong> scope if the scope does not exist.</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;<span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">if</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> (!azureProvision.ScopeExists(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>azureProvision.Apply();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Finally close the SQL Server and SQL Azure database connections as shown below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;onPremiseConn.Close();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;onPremiseConn.Dispose();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;azureConn.Close();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;azureConn.Dispose();</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">The complete <strong>Setup</strong> method for scoping and provisioning is shown below.</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">public</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">static</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">void</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> Setup()</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">{</span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to on premise SQL Server database<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> onPremiseConn = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLServer);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to SQL Azure database<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> azureConn = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLAzure);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Create a scope named "product" and add tables to it.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncScopeDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> productScope = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncScopeDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Select the colums to be included in the Collection Object<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">Collection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&lt;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">string</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&gt; includeColumns = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">Collection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&lt;</span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">string</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">&gt;();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ID"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"Name"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span></span>includeColumns.Add(<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ListPrice"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Define the Products table.<br /></span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DbSyncTableDescription</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> productDescription = <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncDescriptionBuilder</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.GetDescriptionForTable(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">includeColumns, onPremiseConn);</span></span></span></span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"></span></span></span><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">&nbsp;// Add the Table to the scope object.</span></span></span>&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;productScope.Tables.Add(productDescription);</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #000000;" face="Arial" color="#000000">&nbsp;</span>// Create a provisioning object for "product" and apply it to the on-premise database if one does <br />&nbsp;&nbsp;&nbsp; not exist.<br />&nbsp;&nbsp;&nbsp; </span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> onPremiseProvision = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(onPremiseConn, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">productScope);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Filter Rows for the ListPrice column<br />&nbsp;&nbsp;&nbsp;</span></span></span>onPremiseProvision.Tables[<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">].AddFilterColumn(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"ListPrice"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">);<br />&nbsp;&nbsp;&nbsp;</span></span>onPremiseProvision.Tables[<span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"dbo.Products"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">].FilterClause = </span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"[side].[ListPrice] &lt; '600'"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">;</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">if</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> (!onPremiseProvision.ScopeExists(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>onPremiseProvision.Apply();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Provision the SQL Azure database from the on-premise SQL Server database if one does not exist.<br />&nbsp;&nbsp;&nbsp;</span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> azureProvision = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncScopeProvisioning</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(azureConn, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; productScope);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">if</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> (!azureProvision.ScopeExists(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span>azureProvision.Apply();</span></p>
<p><span style="color: #008000; font-family: arial,helvetica,sans-serif; font-size: small;" face="Consolas" size="2" color="#008000">&nbsp;<span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Shut down database connections.</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp; onPremiseConn.Close();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;onPremiseConn.Dispose();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;azureConn.Close();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;azureConn.Dispose();</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">&nbsp;}</span></p>
<p></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b>Task 2: Synchronize the SQL Server and SQL Azure databases </b></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Now that we have the scope and provisioning complete we will write the method to Synchronize the databases. </span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">We will use the Sync Framework SyncOrchestrator class below.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.syncorchestrator.aspx">SyncOrchestrator</a></b> - Initiates and controls synchronization sessions.<br /><br /><b><a href="https://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.sqlserver.sqlsyncprovider.aspx">SqlSyncProvider</a></b> - Represents a synchronization provider that communicates with a SQL Server database and shields other Sync Framework components from the specific implementation of the database.<br /></span></p>
<p>The first thing we will do is to create &nbsp;create two SqlConnection objects to connect to the SQL Server and SQL Azure databases as shown below.</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to on premise SQL Server database<br />&nbsp;&nbsp; </span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> onPremiseConn = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLServer);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000"><span style="color: #008000;" face="Consolas" size="2" color="#008000">// Connection to SQL Azure database<br />&nbsp;&nbsp; </span></span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> azureConn = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">DBConnection</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">.ConnStringSQLAzure);</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span face="Consolas" size="2"><span face="Consolas" size="2">We then create the SyncOrchestrator object as shown below.</span></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SyncOrchestrator</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> syncOrchestrator = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SyncOrchestrator</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">();</span></span></span></p>
<p><br />We then create SqlSyncProviders for SQL Server and SQL Azure as shown below.<br /><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncProvider</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> onPremiseProvider = </span></span><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2"> </span></span><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af;" face="Consolas" size="2" color="#2b91af">SqlSyncProvider</span></span></span><span face="Consolas" size="2"><span face="Consolas" size="2">(</span></span><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515;" face="Consolas" size="2" color="#a31515">"product"</span></span></span><span face="Consolas" siz