Пример #1
0
        public static CloudTableClient GetTableClient(string connectionStringOrKey = null)
        {
            var key = AzureUtilities.FromConfiguration(connectionStringOrKey ?? "StorageConnectionString");

            if (key == null)
            {
                // NOTE: In the real world, you'd want to remove this, so you didn't log keys.
                Trace.TraceInformation("Couldn't find '{0}' as setting, assuming it's the actual key.", connectionStringOrKey);
                key = connectionStringOrKey;
            }

            var storageAccount = CloudStorageAccount.Parse(key);

            return(storageAccount.CreateCloudTableClient());
        }
Пример #2
0
        public async Task StartAsync()
        {
            var ehConnStr = AzureUtilities.ServiceBusConnectionString(
                AzureUtilities.FromConfiguration("MappyServiceBusNamespace"),
                AzureUtilities.FromConfiguration("MappyEventHubSASName"),
                AzureUtilities.FromConfiguration("MappyEventHubSASKey"));
            var storageConnStr = AzureUtilities.StorageConnectionString(
                AzureUtilities.FromConfiguration("MappyStorageName"),
                AzureUtilities.FromConfiguration("MappyStorageKey"));
            var eventHubName  = AzureUtilities.FromConfiguration("MappyEventHubName");
            var consumerGroup = AzureUtilities.FromConfiguration("MappyConsumerGroupName") ?? "$Default";

            Trace.TraceInformation("Connecting to {0}/{1}/{2}, storing in {3}", ehConnStr, eventHubName, consumerGroup, storageConnStr);

            var factory = new RoutePointProcessorFactory(item =>
            {
                Trace.TraceInformation("From EH: {0} @ ({1}, {2})", item.UserID, item.Latitude, item.Longitude);
                this._onPoint(item);
            });
            await AzureUtilities.AttachProcessorForHub("mappy", ehConnStr, storageConnStr, eventHubName, consumerGroup, factory);
        }