How to deploy sync framework to windows azure/Deploy sync framework project to windows azure
Deployment of sync framework workerrole / webrole project into azure environment
The article is going to explain that how we can deploy sync framework worker role or webrole projects created in Visual Studio into azure environment. We have created a worker role application that sync azure databases frequently. We are using Sync Framework 2.1 for sync database in the azure. Once it is completed the application, the challenge was to deploy this sync framework to azure platform. We have to include some dlls and also need to do some configuration settings to deploy project into Windows Azure platform
Steps to do for deploying Sync Framework Project into Azure
1.Open your Windows Azure Cloud Service project in Visual Studio >> In the Solution Explorer, right-click the
Web Role project, point to Add, and then click Add Reference.
2.Add references to Microsoft.Synchronization.dll, Microsoft.Synchronization.Data.dll, and Microsoft.Synchronization.Data.SqlServer.dll from Sync Framework 2.1
installation folder most of the time it is C:\Program Files (x86)\Microsoft Sync Framework\2.1.
3.Select all files and take the Properties window, then set the value of Aliases property to global and
Copy Local property to True.
4.Create a class file named activationcontext.cs file with the following content and add the file to
Workerrole/Webrole project.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Runtime.InteropServices; using System.IO; namespace Microsoft.Samples.Synchronization { public class ActivationContext { // Activation Context API Functions [DllImport("Kernel32.dll", SetLastError = true)] private extern static IntPtr CreateActCtx(ref ACTCTX actctx); // Activation context structure private struct ACTCTX { public int cbSize; public uint dwFlags; public string lpSource; public ushort wProcessorArchitecture; public ushort wLangId; public string lpAssemblyDirectory; public string lpResourceName; public string lpApplicationName; } private const int ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID = 0x004; private const int ACTCTX_FLAG_SET_PROCESS_DEFAULT = 0x00000010; private IntPtr m_hActCtx = (IntPtr)0; public const UInt32 ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET = 14011; /// <summary> /// Explicitly load a manifest and create the process-default activation /// context. It takes effect immediately and stays there until the process exits. /// </summary> static public void CreateActivationContext() { string rootFolder = AppDomain.CurrentDomain.BaseDirectory; string manifestPath = Path.Combine(rootFolder, "webapp.manifest"); UInt32 dwError = 0; // Build the activation context information structure ACTCTX info = new ACTCTX(); info.cbSize = Marshal.SizeOf(typeof(ACTCTX)); info.dwFlags = ACTCTX_FLAG_SET_PROCESS_DEFAULT; info.lpSource = manifestPath; if (null != rootFolder && "" != rootFolder) { info.lpAssemblyDirectory = rootFolder; info.dwFlags |= ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; } dwError = 0; // Create the activation context IntPtr result = CreateActCtx(ref info); if (-1 == result.ToInt32()) { dwError = (UInt32)Marshal.GetLastWin32Error(); } if (-1 == result.ToInt32() && ActivationContext.ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET != dwError) { string err = string.Format("Cannot create process-default win32 sxs context, error={0} manifest={1}", dwError, manifestPath); ApplicationException ex = new ApplicationException(err); throw ex; } } } }
5.Add a folder named synchronization.assemblies to the Web Role/ Worker Role project and add the following five files to the folder.
Microsoft.Synchronization.dll Microsoft.Synchronization.Data.dll Microsoft.Synchronization.Data.SqlServer.dll Synchronization21.dll
Create a file named synchronization.assemblies.manifest, add the following content, and add the file to this folder.
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> <assemblyIdentity type="x64" name="synchronization.assemblies" version="2.1.0.0"/> <file name = "synchronization21.dll"> <comClass clsid="{EC413D66-6221-4ebb-AC55-4900FB321011}" threadingModel="Both"/> </file> </assembly>
6.Multiple-select all files under synchronization.assemblies folder, right-click, and then click Properties.
Set the value of Build Action property to Content and Copy To Output Directory to Copy Always.
7.Create a file named webapp.manifest, add the following content, and add the file to the Web Role project.
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity name="webapp" version="8.0.0.0" type="x64"/> <dependency> <dependentAssembly> <assemblyIdentity name="synchronization.assemblies" version="2.1.0.0" type="x64"/> </dependentAssembly> </dependency> </assembly>
8.Set the value of Build Action property to Content and Copy To Output Directory to Copy Always for the webapp.manifest file using Properties window.
9.Add the following statement to the OnStart method before base.OnStart method call in the WebRole.cs file.
Microsoft.Samples.Synchronization.ActivationContext.CreateActivationContext();
Search other topic from here
Blog Stats
- 294,430 hits
Recent Posts
- How to access all types of server controls in ASP.Net using Javscript/JQuery OR Clear all server controls values using javascript or Jquery
- How to implement Cache mechanism in ASP.Net/C# using simple example OR What is Output Caching and Fragment Caching in ASP.Net/C#
- How to implement CAPTCHA image validation in ASP.Net/C# OR CAPTCHA image validator Sample in ASP.Net/C#
- How to implement SQL Bulk Copy in SQL Server OR Bulk insert into SQL Server using SQL BulkCopy
- How to merge two data tables in ASP.Net/C# OR Merge 2 DataTables and store in a new one in ASP.Net/C#
- How to implement Password validation in ASP.Net/C# OR Implement Password strength using Jquery in ASP.Net
- How to create breadcrumbs in ASP.Net/C# OR Show Navigations for each pages in ASP.Net/C# OR How to implement Sitemap in ASP.Net
- How to create a drag able and resizable div in ASP.Net/C# OR How to make a div Dragable and Resizable using Jquery in ASP.Net/C#
- How to implement BalloonPopupExtender in ASP.Net/C# OR Ballon Popup Extender Sample in ASP.Net/C#
- How to create always visible div using Ajax/ Always visible div in ASP.Net using Ajax
- Example for All Types of SQL JOIN (Inner Join, Cross Join, Outer Join, Self Join)
- How to Create a Data Table Dynamically with sample data and Bind to Grid/Create datatable with sample data.
Archives
- June 2013 (1)
- May 2013 (2)
- October 2012 (4)
- September 2012 (6)
- July 2012 (4)
- June 2012 (1)
- May 2012 (1)
- March 2012 (2)
- February 2012 (2)
- January 2012 (1)
- October 2011 (2)
- September 2011 (5)
- August 2011 (1)
- July 2011 (6)
- June 2011 (18)
- May 2011 (14)
Recent Comments