Пример #1
0
 public void SetUp()
 {
     account = AzuriteNUnitFixture.Instance.GetAccount();
     account.CreateBlobServiceClient().GetBlobContainerClient(ContainerName).DeleteIfExists();
     // make sure our system containers are present
     account.CreateBlobServiceClient().GetBlobContainerClient("azure-webjobs-hosts").CreateIfNotExists();
     account.CreateQueueServiceClient().GetQueueClient(QueueName).DeleteIfExists();
 }
Пример #2
0
 public ScenarioTests(AzuriteFixture azuriteFixture)
 {
     account = azuriteFixture.GetAccount();
     account.CreateBlobServiceClient().GetBlobContainerClient(ContainerName).DeleteIfExists();
     // make sure our system containers are present
     account.CreateBlobServiceClient().GetBlobContainerClient("azure-webjobs-hosts").CreateIfNotExists();
     account.CreateQueueServiceClient().GetQueueClient(QueueName).DeleteIfExists();
 }
Пример #3
0
        private static QueueClient GetQueueReference(StorageAccount sdkAccount, string queueName)
        {
            var queueServiceClient = sdkAccount.CreateQueueServiceClient();

            return(queueServiceClient.GetQueueClient(queueName));
        }
Пример #4
0
 public void SetUp()
 {
     account = AzuriteNUnitFixture.Instance.GetAccount();
     account.CreateQueueServiceClient().GetQueueClient(QueueName).DeleteIfExists();
 }
Пример #5
0
 public HostCallTests(AzuriteFixture azuriteFixture)
 {
     account = azuriteFixture.GetAccount();
     account.CreateQueueServiceClient().GetQueueClient(QueueName).DeleteIfExists();
     account.CreateQueueServiceClient().GetQueueClient(OutputQueueName).DeleteIfExists();
 }
Пример #6
0
 public DataBindingFunctionalTests(AzuriteFixture azuriteFixture)
 {
     account = azuriteFixture.GetAccount();
     account.CreateQueueServiceClient().GetQueueClient(QueueName).DeleteIfExists();
 }
Пример #7
0
        public async Task <IListener> CreateAsync(CancellationToken cancellationToken)
        {
            // Note that these clients are intentionally for the storage account rather than for the dashboard account.
            // We use the storage, not dashboard, account for the blob receipt container and blob trigger queues.
            var primaryQueueClient = _hostAccount.CreateQueueServiceClient();
            var primaryBlobClient  = _hostAccount.CreateBlobServiceClient();

            // Important: We're using the storage account of the function target here, which is the account that the
            // function the listener is for is targeting. This is the account that will be used
            // to read the trigger blob.
            var targetBlobClient  = _dataAccount.CreateBlobServiceClient();
            var targetQueueClient = _dataAccount.CreateQueueServiceClient();

            string hostId = await _hostIdProvider.GetHostIdAsync(cancellationToken).ConfigureAwait(false);

            string hostBlobTriggerQueueName = HostQueueNames.GetHostBlobTriggerQueueName(hostId);
            var    hostBlobTriggerQueue     = primaryQueueClient.GetQueueClient(hostBlobTriggerQueueName);

            SharedQueueWatcher sharedQueueWatcher = _messageEnqueuedWatcherSetter;

            SharedBlobListener sharedBlobListener = _sharedContextProvider.GetOrCreateInstance <SharedBlobListener>(
                new SharedBlobListenerFactory(hostId, _hostAccount, _exceptionHandler, _blobWrittenWatcherSetter, _loggerFactory.CreateLogger <BlobListener>()));

            // Register the blob container we wish to monitor with the shared blob listener.
            await RegisterWithSharedBlobListenerAsync(hostId, sharedBlobListener, primaryBlobClient,
                                                      hostBlobTriggerQueue, sharedQueueWatcher, cancellationToken).ConfigureAwait(false);

            // Create a "bridge" listener that will monitor the blob
            // notification queue and dispatch to the target job function.
            SharedBlobQueueListener sharedBlobQueueListener = _sharedContextProvider.GetOrCreateInstance <SharedBlobQueueListener>(
                new SharedBlobQueueListenerFactory(_hostAccount, sharedQueueWatcher, hostBlobTriggerQueue,
                                                   _queueOptions, _exceptionHandler, _loggerFactory, sharedBlobListener.BlobWritterWatcher, _functionDescriptor));
            var queueListener = new BlobListener(sharedBlobQueueListener);

            // determine which client to use for the poison queue
            // by default this should target the same storage account
            // as the blob container we're monitoring
            var poisonQueueClient = targetQueueClient;

            if (
                // _dataAccount.Type != StorageAccountType.GeneralPurpose || $$$
                _blobsOptions.CentralizedPoisonQueue)
            {
                // use the primary storage account if the centralize flag is true,
                // or if the target storage account doesn't support queues
                poisonQueueClient = primaryQueueClient;
            }

            // Register our function with the shared blob queue listener
            RegisterWithSharedBlobQueueListenerAsync(sharedBlobQueueListener, targetBlobClient, poisonQueueClient);

            // check a flag in the shared context to see if we've created the singleton
            // shared blob listener in this host instance
            object singletonListenerCreated = false;

            if (!_sharedContextProvider.TryGetValue(SingletonBlobListenerScopeId, out singletonListenerCreated))
            {
                // Create a singleton shared blob listener, since we only
                // want a single instance of the blob poll/scan logic to be running
                // across host instances
                var singletonBlobListener = _singletonManager.CreateHostSingletonListener(
                    new BlobListener(sharedBlobListener), SingletonBlobListenerScopeId);
                _sharedContextProvider.SetValue(SingletonBlobListenerScopeId, true);

                return(new CompositeListener(singletonBlobListener, queueListener));
            }
            else
            {
                // We've already created the singleton blob listener
                // so just return our queue listener. Note that while we want the
                // blob scan to be singleton, the shared queue listener needs to run
                // on ALL instances so load can be scaled out
                return(queueListener);
            }
        }