public override void Init() { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); logger?.LogDebugAsync("MQTT adapter audit factory added.").GetAwaiter(); forcePerReceiveAuthn = Channel as UdpChannel != null; session.OnPublish += Session_OnPublish; session.OnSubscribe += Session_OnSubscribe; session.OnUnsubscribe += Session_OnUnsubscribe; session.OnDisconnect += Session_OnDisconnect; ; session.OnConnect += Session_OnConnect; logger?.LogInformationAsync($"MQTT adpater on channel '{Channel.Id}' is initialized.").GetAwaiter(); }
public AzureQueueStorageSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { loadQueue = new ConcurrentQueue <EventMessage>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); queue = nvc["queue"]; string ttlString = nvc["ttl"]; if (!string.IsNullOrEmpty(ttlString)) { ttl = TimeSpan.Parse(ttlString); } Uri.TryCreate(metadata.SymmetricKey, UriKind.Absolute, out Uri sasUri); if (sasUri == null) { storage = QueueStorage.New( $"DefaultEndpointsProtocol=https;AccountName={uri.Authority.Split(new[] { '.' })[0]};AccountKey={metadata.SymmetricKey};", 10000, 1000); } else { string connectionString = $"BlobEndpoint={queue};SharedAccessSignature={metadata.SymmetricKey}"; storage = QueueStorage.New(connectionString, 1000, 5120000); } }
public WsnProtocolAdapter(PiraeusConfig config, GraphManager graphManager, IChannel channel, HttpContext context, ILog logger = null) { this.config = config; this.graphManager = graphManager; this.Channel = channel; this.logger = logger; IdentityDecoder decoder = new IdentityDecoder(config.ClientIdentityNameClaimType, context, config.GetClientIndexes()); identity = decoder.Id; localIndexes = decoder.Indexes; MessageUri messageUri = new MessageUri(context.Request); this.contentType = messageUri.ContentType; this.cacheKey = messageUri.CacheKey; this.resource = messageUri.Resource; this.subscriptions = messageUri.Subscriptions != null ? new List <string>(messageUri.Subscriptions) : null; this.indexes = messageUri.Indexes != null ? new List <KeyValuePair <string, string> >(messageUri.Indexes) : null; auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); }
public override void Init() { Trace.TraceInformation("{0} - MQTT Protocol Adapter intialization on Channel '{1}'.", DateTime.UtcNow.ToString("yyyy-MM-ddTHH-MM-ss.fffff"), Channel.Id); auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); forcePerReceiveAuthn = Channel as UdpChannel != null; session.OnPublish += Session_OnPublish; session.OnSubscribe += Session_OnSubscribe; session.OnUnsubscribe += Session_OnUnsubscribe; session.OnDisconnect += Session_OnDisconnect;; session.OnConnect += Session_OnConnect; logger?.LogInformation($"MQTT adpater on channel '{Channel.Id}' is initialized."); }
public IoTHubSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); string keyName = nvc["keyname"]; deviceId = nvc["deviceid"]; methodName = nvc["method"]; propertyName = nvc["propname"]; propertyValue = nvc["propvalue"]; if (string.IsNullOrEmpty(methodName)) { deviceClient = DeviceClient.CreateFromConnectionString(string.Format( "HostName={0};DeviceId={1};SharedAccessKey={2}", uri.Authority, deviceId, metadata.SymmetricKey)); } else { serviceClient = ServiceClient.CreateFromConnectionString(string.Format( "HostName={0};SharedAccessKeyName={1};SharedAccessKey={2}", uri.Authority, keyName, metadata.SymmetricKey)); } }
public EventGridSink(SubscriptionMetadata metadata) : base(metadata) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); topicHostname = uri.Authority; topicKey = metadata.SymmetricKey; string uriString = new Uri(metadata.SubscriptionUriString).ToString(); resourceUriString = uriString.Replace("/" + uri.Segments[uri.Segments.Length - 1], ""); if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } ServiceClientCredentials credentials = new TopicCredentials(topicKey); clients = new EventGridClient[clientCount]; for (int i = 0; i < clientCount; i++) { clients[i] = new EventGridClient(credentials); } }
private void InitializeAuditor(PiraeusConfig config) { if (!string.IsNullOrEmpty(config.AuditConnectionString) && AuditFactory.CreateSingleton().GetAuditor(AuditType.User) == null) { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString.ToLowerInvariant().Contains("AccountName=")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else { string pathString = config.AuditConnectionString.LastIndexOf("/") == config.AuditConnectionString.Length - 1 ? config.AuditConnectionString : config.AuditConnectionString + "/"; auditFactory.Add(new FileAuditor(string.Format($"{pathString}messageaudit.txt")), AuditType.Message); auditFactory.Add(new FileAuditor(string.Format($"{pathString}useraudit.txt")), AuditType.User); } } }
public RedisSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { tqueue = new TaskQueue(); cqm = new ConcurrentQueueManager(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); connectionString = $"{uri.Authority}:6380,password={metadata.SymmetricKey},ssl=True,abortConnect=False"; NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); if (!int.TryParse(nvc["db"], out dbNumber)) { dbNumber = -1; } if (TimeSpan.TryParse(nvc["expiry"], out TimeSpan expiration)) { expiry = expiration; } if (string.IsNullOrEmpty(metadata.ClaimKey)) { cacheClaimType = metadata.ClaimKey; } connection = ConnectionMultiplexer.ConnectAsync(connectionString).GetAwaiter().GetResult(); database = connection.GetDatabase(dbNumber); }
public WebHookSink(SubscriptionMetadata metadata, ILog logger) : base(metadata, logger) { this.logger = logger; auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); address = new Uri(metadata.NotifyAddress).ToString(); }
public MachineLearningSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { this.logger = logger; auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); token = metadata.SymmetricKey; NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); outputPiSystem = nvc["r"]; }
public CoapRequestDispatcher(CoapSession session, IChannel channel) { this.channel = channel; this.session = session; auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); coapObserved = new Dictionary <string, byte[]>(); coapUnobserved = new HashSet <string>(); adapter = new OrleansAdapter(session.Identity, channel.TypeId, "CoAP"); adapter.OnObserve += Adapter_OnObserve; LoadDurablesAsync().LogExceptions(); }
public OrleansAdapter(string identity, string channelType, string protocolType, HttpContext context = null) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); this.identity = identity; this.channelType = channelType; this.protocolType = protocolType; this.context = context; container = new Dictionary <string, Tuple <string, string> >(); ephemeralObservers = new Dictionary <string, IMessageObserver>(); durableObservers = new Dictionary <string, IMessageObserver>(); }
public EventGridSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); topicHostname = uri.Authority; topicKey = metadata.SymmetricKey; string uriString = new Uri(metadata.SubscriptionUriString).ToString(); resourceUriString = uriString.Replace("/" + uri.Segments[^ 1], "");
public ServiceBusTopicSink(SubscriptionMetadata metadata) : base(metadata) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); keyName = nvc["keyname"]; topic = nvc["topic"]; string symmetricKey = metadata.SymmetricKey; connectionString = String.Format("Endpoint=sb://{0}/;SharedAccessKeyName={1};SharedAccessKey={2}", uri.Authority, keyName, symmetricKey); }
public CoapRequestDispatcher(CoapSession session, IChannel channel, PiraeusConfig config, GraphManager graphManager, ILog logger = null) { this.channel = channel; this.session = session; this.config = config; this.graphManager = graphManager; this.logger = logger; auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); coapObserved = new Dictionary <string, byte[]>(); coapUnobserved = new HashSet <string>(); adapter = new OrleansAdapter(session.Identity, channel.TypeId, "CoAP", graphManager, logger); adapter.OnObserve += Adapter_OnObserve; LoadDurablesAsync().LogExceptions(logger); }
public ServiceBusTopicSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); keyName = nvc["keyname"]; topic = nvc["topic"]; string symmetricKey = metadata.SymmetricKey; connectionString = $"Endpoint=sb://{uri.Authority}/;SharedAccessKeyName={keyName};SharedAccessKey={symmetricKey}"; }
private void InitializeAuditor(PiraeusConfig config) { auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } userAuditor = auditFactory.GetAuditor(AuditType.User); }
public CosmosDBSink(SubscriptionMetadata metadata) : base(metadata) { queue = new ConcurrentQueue <EventMessage>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); string docDBUri = String.Format("https://{0}", uri.Authority); documentDBUri = new Uri(String.Format("https://{0}", uri.Authority)); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); databaseId = nvc["database"]; collectionId = nvc["collection"]; symmetricKey = metadata.SymmetricKey; if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } if (!int.TryParse(nvc["delay"], out delay)) { delay = 1000; } storageArray = new DocumentClient[clientCount]; for (int i = 0; i < clientCount; i++) { storageArray[i] = new DocumentClient(documentDBUri, symmetricKey); } database = GetDatabaseAsync().GetAwaiter().GetResult(); //Task<Database> dbtask = GetDatabaseAsync(); //Task.WaitAll(dbtask); //database = dbtask.Result; collection = GetCollectionAsync(database.SelfLink, collectionId).GetAwaiter().GetResult(); //Task<DocumentCollection> coltask = GetCollectionAsync(database.SelfLink, collectionId); //Task.WaitAll(coltask); //collection = coltask.Result; }
public EventHubSink(SubscriptionMetadata metadata) : base(metadata) { queue = new ConcurrentQueue <byte[]>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); keyName = nvc["keyname"]; partitionId = nvc["partitionid"]; hubName = nvc["hub"]; connectionString = String.Format("Endpoint=sb://{0}/;SharedAccessKeyName={1};SharedAccessKey={2}", uri.Authority, keyName, metadata.SymmetricKey); if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } if (!int.TryParse(nvc["delay"], out delay)) { delay = 1000; } if (!String.IsNullOrEmpty(partitionId)) { senderArray = new PartitionSender[clientCount]; } storageArray = new EventHubClient[clientCount]; for (int i = 0; i < clientCount; i++) { storageArray[i] = EventHubClient.CreateFromConnectionString(connectionString); if (!String.IsNullOrEmpty(partitionId)) { senderArray[i] = storageArray[i].CreatePartitionSender(partitionId.ToString()); } } }
public RestProtocolAdapter(PiraeusConfig config, GraphManager graphManager, IChannel channel, HttpContext context, ILog logger = null) { this.config = config; this.channel = channel; this.logger = logger; method = context.Request.Method.ToUpperInvariant(); messageUri = new MessageUri(context.Request); IdentityDecoder decoder = new IdentityDecoder(config.ClientIdentityNameClaimType, context, config.GetClientIndexes()); identity = decoder.Id; indexes = decoder.Indexes; adapter = new OrleansAdapter(identity, channel.TypeId, "REST", graphManager, logger); if (method == "GET") { adapter.OnObserve += Adapter_OnObserve; } protocolType = ProtocolType.REST; contentType = messageUri.ContentType; resource = messageUri.Resource; subscriptions = messageUri.Subscriptions; auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "messageaudit"), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString, "useraudit"), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); }
public RestWebServiceSink(SubscriptionMetadata metadata) : base(metadata) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); tokenType = metadata.TokenType; symmetricKey = metadata.SymmetricKey; Uri uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); issuer = nvc["issuer"]; audience = nvc["audience"]; nvc.Remove("issuer"); nvc.Remove("audience"); string uriString = nvc.Count == 0 ? String.Format("{0}{1}{2}{3}", uri.Scheme, Uri.SchemeDelimiter, uri.Authority, uri.LocalPath) : String.Format("{0}{1}{2}{3}?", uri.Scheme, Uri.SchemeDelimiter, uri.Authority, uri.LocalPath); StringBuilder builder = new StringBuilder(); builder.Append(uriString); for (int i = 0; i < nvc.Count; i++) { string key = nvc.GetKey(i); string value = nvc[key]; builder.Append(String.Format("{0}={1}", key, value)); if (i < nvc.Count - 1) { builder.Append("&"); } } address = builder.ToString(); SetCertificateAsync().Ignore(); SetClaimsAsync().Ignore(); }
public RestProtocolAdapter(PiraeusConfig config, IChannel channel, HttpContext context, ILogger logger) { this.config = config; Channel = channel; this.context = context; auditFactory = AuditFactory.CreateSingleton(); if (config.AuditConnectionString != null && config.AuditConnectionString.Contains("DefaultEndpointsProtocol")) { auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new AzureTableAuditor(config.AuditConnectionString), AuditType.User); } else if (config.AuditConnectionString != null) { auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.Message); auditFactory.Add(new FileAuditor(config.AuditConnectionString), AuditType.User); } messageAuditor = auditFactory.GetAuditor(AuditType.Message); userAuditor = auditFactory.GetAuditor(AuditType.User); }
public RestWebServiceSink(SubscriptionMetadata metadata, List <Claim> claimset = null, X509Certificate2 certificate = null, ILog logger = null) : base(metadata, logger) { auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); this.certificate = certificate; Uri uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); issuer = nvc["issuer"]; audience = nvc["audience"]; nvc.Remove("issuer"); nvc.Remove("audience"); string uriString = nvc.Count == 0 ? $"{uri.Scheme}{Uri.SchemeDelimiter}{uri.Authority}{uri.LocalPath}" : $"{uri.Scheme}{Uri.SchemeDelimiter}{uri.Authority}{uri.LocalPath}?"; StringBuilder builder = new StringBuilder(); builder.Append(uriString); for (int i = 0; i < nvc.Count; i++) { string key = nvc.GetKey(i); string value = nvc[key]; builder.Append($"{key}={value}"); if (i < nvc.Count - 1) { builder.Append("&"); } } address = builder.ToString(); claims = claimset; }
public RedisSink(SubscriptionMetadata metadata) : base(metadata) { tqueue = new TaskQueue(); cqm = new ConcurrentQueueManager(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); connectionString = String.Format("{0}:6380,password={1},ssl=True,abortConnect=False", uri.Authority, metadata.SymmetricKey); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); if (!int.TryParse(nvc["db"], out dbNumber)) { dbNumber = -1; } TimeSpan expiration; if (TimeSpan.TryParse(nvc["expiry"], out expiration)) { expiry = expiration; } if (string.IsNullOrEmpty(metadata.ClaimKey)) { cacheClaimType = metadata.ClaimKey; } connection = ConnectionMultiplexer.ConnectAsync(connectionString).GetAwaiter().GetResult(); //Task<ConnectionMultiplexer> task = ConnectionMultiplexer.ConnectAsync(connectionString); //Task.WaitAll(task); //connection = task.Result; }
public CosmosDBSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { queue = new ConcurrentQueue <EventMessage>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); uri = new Uri(metadata.NotifyAddress); documentDBUri = new Uri($"https://{uri.Authority}"); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); databaseId = nvc["database"]; collectionId = nvc["collection"]; symmetricKey = metadata.SymmetricKey; if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } if (!int.TryParse(nvc["delay"], out delay)) { delay = 1000; } storageArray = new DocumentClient[clientCount]; for (int i = 0; i < clientCount; i++) { storageArray[i] = new DocumentClient(documentDBUri, symmetricKey); } database = GetDatabaseAsync().GetAwaiter().GetResult(); collection = GetCollectionAsync(database.SelfLink, collectionId).GetAwaiter().GetResult(); }
public AzureBlobStorageSink(SubscriptionMetadata metadata, ILog logger = null) : base(metadata, logger) { queue = new ConcurrentQueue <EventMessage>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); key = metadata.SymmetricKey; uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); container = nvc["container"]; if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } if (!string.IsNullOrEmpty(nvc["file"])) { appendFilename = nvc["file"]; } if (string.IsNullOrEmpty(container)) { container = "$Root"; } string btype = nvc["blobtype"]; blobType = string.IsNullOrEmpty(btype) ? "block" : btype.ToLowerInvariant(); if (blobType != "block" && blobType != "page" && blobType != "append") { logger?.LogWarningAsync($"Subscription '{metadata.SubscriptionUriString}' invalid blob type to write.") .GetAwaiter(); return; } sasUri = null; Uri.TryCreate(metadata.SymmetricKey, UriKind.Absolute, out sasUri); storageArray = new BlobStorage[clientCount]; if (sasUri == null) { connectionString = $"DefaultEndpointsProtocol=https;AccountName={uri.Authority.Split(new[] { '.' })[0]};AccountKey={key};"; for (int i = 0; i < clientCount; i++) { storageArray[i] = BlobStorage.New(connectionString, 2048, 102400); } } else { connectionString = $"BlobEndpoint={(container != "$Root" ? uri.ToString().Replace(uri.LocalPath, "") : uri.ToString())};SharedAccessSignature={key}"; for (int i = 0; i < clientCount; i++) { storageArray[i] = BlobStorage.New(connectionString, 2048, 102400); } } }
public AzureBlobStorageSink(SubscriptionMetadata metadata) : base(metadata) { queue = new ConcurrentQueue <EventMessage>(); auditor = AuditFactory.CreateSingleton().GetAuditor(AuditType.Message); key = metadata.SymmetricKey; uri = new Uri(metadata.NotifyAddress); NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query); container = nvc["container"]; if (!int.TryParse(nvc["clients"], out clientCount)) { clientCount = 1; } if (!string.IsNullOrEmpty(nvc["file"])) { appendFilename = nvc["file"]; } if (String.IsNullOrEmpty(container)) { container = "$Root"; } string btype = nvc["blobtype"]; if (String.IsNullOrEmpty(btype)) { blobType = "block"; } else { blobType = btype.ToLowerInvariant(); } if (blobType != "block" && blobType != "page" && blobType != "append") { Trace.TraceWarning("Subscription {0} blob storage sink has invalid Blob Type of {1}", metadata.SubscriptionUriString, blobType); return; } sasUri = null; Uri.TryCreate(metadata.SymmetricKey, UriKind.Absolute, out sasUri); storageArray = new BlobStorage[clientCount]; if (sasUri == null) { connectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};", uri.Authority.Split(new char[] { '.' })[0], key); for (int i = 0; i < clientCount; i++) { storageArray[i] = BlobStorage.New(connectionString, 2048, 102400); } } else { connectionString = String.Format("BlobEndpoint={0};SharedAccessSignature={1}", container != "$Root" ? uri.ToString().Replace(uri.LocalPath, "") : uri.ToString(), key); for (int i = 0; i < clientCount; i++) { storageArray[i] = BlobStorage.New(connectionString, 2048, 102400); } } }