Exemple #1
0
        public IFabricConnector GetConnector(ServiceId serviceId)
        {
            if (!_serviceToQueueMap.TryGetValue(serviceId.ServiceName, out var transitionsQueue))
            {
                // Fall back to the queue of a function currently being executed.
                // This is needed for the Intrinsic Routines.
                // Such code is not needed for the gateway, and you are not allowed to call
                // Intrinsic Routines directly from the gateway.
                transitionsQueue = _currentFunction.Value.Queue;
            }

            if (transitionsQueue == null)
            {
                throw new InvalidOperationException(
                          $"Cannot find queue for the service '{serviceId.ServiceName}'.");
            }

            var configuration = new AzureStorageFabricConnectorConfiguration
            {
                SerializerFormat     = "dasyncjson",
                TransitionsQueueName = transitionsQueue.Name,
                RoutinesTableName    = _routinesTable.Name,
                ServicesTableName    = _servicesTable.Name,
                StorageAccountName   = ConnectionStringParser.GetAccountName(_storageAccountConnectionString)
            };

            return(new AzureStorageFabricConnectorWithConfiguration(
                       serviceId,
                       _idGenerator,
                       transitionsQueue,
                       _routinesTable,
                       _defaultSerializer,
                       configuration));
        }
        public string Resolve(string accountName)
        {
            var defaultConnectionString = _azureWebJobsEnviromentalSettings.DefaultStorageConnectionString;
            var defaultAccountName      = ConnectionStringParser.GetAccountName(defaultConnectionString);

            if (string.Equals(accountName, defaultAccountName))
            {
                return(defaultConnectionString);
            }

            if (_azureWebJobsEnviromentalSettings.TryGetSetting(
                    key: accountName + "_STORAGE",
                    value: out var connectionString))
            {
                return(connectionString);
            }

            throw new InvalidOperationException(
                      $"Could not resolve connection string for a storage account '{accountName}'.");
        }
Exemple #3
0
        public AzureStorageServiceRepository(
            ICloudStorageAccountFactory cloudStorageAccountFactory,
            IAzureWebJobsEnviromentalSettings azureWebJobsEnviromentalSettings)
        {
            var accountNames = new HashSet <string>();

            var defaultAccountName = ConnectionStringParser.GetAccountName(
                azureWebJobsEnviromentalSettings.DefaultStorageConnectionString);

            accountNames.Add(defaultAccountName);

            var defaultStorageAccount = cloudStorageAccountFactory.Create(
                azureWebJobsEnviromentalSettings.DefaultStorageConnectionString);
            var registryTable = defaultStorageAccount.TableClient.GetTableReference("registry");

            _registryTables.Add(registryTable);

            foreach (var setting in azureWebJobsEnviromentalSettings.GetAllSettings())
            {
                if (!setting.Key.EndsWith("_STORAGE"))
                {
                    continue;
                }

                var connectionString = setting.Value;
                var accountName      = ConnectionStringParser.GetAccountName(connectionString);
                if (!accountNames.Add(accountName))
                {
                    continue;
                }

                var storageAccount = cloudStorageAccountFactory.Create(connectionString);
                registryTable = storageAccount.TableClient.GetTableReference("registry");
                _registryTables.Add(registryTable);
            }
        }