Maintenance on SuperOffice Core systems 6th to 9th of November Click to learn more

Get your mirroring service up and running in 10 minutes or less using NuGet

In this article

    Although you are free to implement the mirroring service to support any database you prefer, SuperOffice provides a complete implementation of the database mirroring interface as a NuGet package.

    This walkthrough will guide you through creating a new WCF service from scratch using the SuperOffice.Crm.Online.Mirroring package, and help you have a running service in just a few minutes.

    These steps were documented using Visual Studio 2015.

    Create a new WCF Service Application in Visual Studio

    1. In Visual Studio, click File, then New, and then Project.

    2. In the New Project dialog, expand the WCF section and select to create a new WCF Service Application.

    3. In the Solution Explorer, delete the following files: IService1.cs, Service1.svc, and Service1.cs.

      Before:

      After:

    Install the NuGet package

    1. Open the Package Manager Console:

      • Click Tools, then NuGet Package Manager, and then Package Manager Console.

    2. Start the installation by typing:

      Install-Package SuperOffice.Crm.Online.Mirroring

    3. Verify that the packages have been added:

      1. When you see the successfully installed message in the Package Manager Console, go back to the Solution Explorer.

      2. Confirm that you have a new assembly references and that the following files have been added to your project: MirroringClientService.svc, MirroringClientService.cs, and Private.txt.
      3. Open the package.config file and check that you now have the new Mirroring package and its 2 dependencies:

        Your package versions may be different, and that is OK.

    During installation, you will see a lot of data scroll by in the NuGet Package Manager Console. The Package Manager inspects the SuperOffice.Crm.Online.Mirroring package and tries to download and add dependencies to your project.

    Key points during package installation

    • package name (SuperOffice.Crm.Online.Mirroring)
    • System.IdentityModel.Tokens.Jwt dependency
    • SuperOffice.Crm.Online.Core dependency
    • successfully installed message

    These are underlined with red in the following screenshot:

    Update settings in the web.config file

    The functionality in the MirroringClientService.cs file helps you resolve a tenant's context identifier to a particular database, create the database if necessary, discover and provide the service's ApplicationToken, as well as the private certificate key it must use to sign the token placed in the AuthenticationResponse message. However, you must still provide those key pieces of information in the project's web.config file.

    appSettings section

    SoAppId: set to client ID (application environment-specific)

    ConnectionBase: the partial connection string used to connect your SQL Server host

    MirrorDatabaseName: will be used as a template for accessing the specific database on that server based on the context identifier passed to this service from SuperOffice

    PrivateFileKey: the name of the file that contains your private certificate key in the RSA XML <RSAKeyPair> and <RSAKeyValue> format. Critical for initial authentication!

    You get the private certificate key for SOD from SuperOffice. You must provide your own certificates for the stage and production environments.

    system.serviceModel section

    Now present is a binding ExtendedMaxSize, because synchronizing database requires a lot of data, and in the services section a new service entry for the mirroring service.

    Expose service to a public secure URL

    Open the service in a browser:

    In the solution directory, right-click the MirroringClientServer.svc file, then click View in Browser.

    Assuming everything is correctly in place, you will see the default IIS or IISExpress web service page.

     

    Finally, you will want to expose this service to a public HTTPS URL for the SuperOffice Mirroring Task to access it.

    This will be the URL you must give SuperOffice when registering your application. 
    Remember to specify this URL as the Database Mirror URL, not the Redirect URL.