Table of Contents

Connecting to ScaleOut in Microsoft Azure

The AzureBootstrapGatewayProvider class allows the Scaleout.Client library to connect to a ScaleOut cluster in Microsoft Azure to perform ScaleOut hosts discovery by using a certificate that identifies ScaleOut client library as a trusted application within specified Azure tenant.

Background

When a AzureBootstrapGatewayProvider instance is supplied to a GridConnection Connect or ConnectAsync call, your connection string can omit the bootstrapGateway parameter.

The AzureBootstrapGatewayProvider uses tag metadata that is present on your VMSS instances to find ScaleOut hosts. This metadata is present whenever ScaleOut hosts are launched using either ScaleOut PowerShell scripts or via Management Console - in both cases the tag metadata is created by ScaleOut ARM template.

Prerequisites

The AzureBootstrapGatewayProvider is available in the Scaleout.Client.Azure NuGet package.

Procedure

  1. Add a reference to the Scaleout.Client.Azure NuGet package.

  2. Supply an AzureBootstrapGatewayProvider instance to the GridConnection when connecting.

using System.Security.Cryptography.X509Certificates;
using Scaleout.Client;
using Scaleout.Client.Azure;

class Program
{
    static void Main(string[] args)
    {
        X509Certificate2 cert = null;
        var certThumbprint = "A12629F9C36363C5A87C312B48ABCD05506D6264";

        using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
        {
            store.Open(OpenFlags.ReadOnly);

            var certCollection = store.Certificates.Find(X509FindType.FindByThumbprint, certThumbprint, validOnly: true);
            if (certCollection.Count > 0)
                cert = certCollection[0];
        }
        var azureProv = new AzureBootstrapGatewayProvider(
                            tenantId: "7ad67d34-5c4d-7241-c431-e341781214a8",
                            clientId: "534a4463-2634-7b10-c338-3ae41052bc88",
                            certificate: cert,
                            scaleoutStoreName: "MyProdClusterInAzure",
                            gatewayType: GatewayType.Private);

        string connectionString = "useSecure=false;maxPoolsize=16";

        var conn = GridConnection.Connect(connectionString, azureProv);
        var cacheBuilder = new CacheBuilder<string, string>("My Cache", conn);
        var cache = cacheBuilder.Build();
        //...
    }
}
  • A constructor overload is available that takes an ArmClient instance from the Microsoft Azure Resource Manager client library for .NET. This can be used instead of supplying the Azure credential-related information directly to ScaleOut APIs.
  • The AzureBootstrapGatewayProvider constructor requires a scaleoutStoreName argument. All ScaleOut clusters in Azure are assigned names upon deployment--use the name you gave your cluster for this parameter.
  • The gatewayType parameter indicates whether the Scaleout.Client library should connect using your Azure VM instance's public or private IP address. Use GatewayType.Private whenever possible to avoid data egress charges.