How can I use Azure Storage Queue trigger in a BackgroundService with a name resolver

David B 0 Reputation points
2023-11-24T01:01:29.9366667+00:00

I have a custom interface that I want to mix some controller endpoints with a constantly running background service and utilise the trigger functionality available to Azure Storage Queue's.

It wasn't too difficult to add a background service to an asp.net core web app.

	public class ScheduledSyncWorker : BackgroundService
	{
		public ScheduledSyncWorker(	ISyncConfiguration syncConfiguration)
	...

	}

I'm now trying to add the QueueTrigger methods and use a name resolver

// 	SyncingTriggersQueueNameToken = "synctriggerqueue"
public static void HandleIncomingSync([QueueTrigger("%" + SyncingTriggersQueueNameToken + "%")] QueueMessage myQueueItem, ILogger log)
	{
		log.Info($"C# function processed: {myQueueItem}");

		try
		{
	     ... Do some significant processing. More than an azure function can handle like stick it in the database.
		}
		catch (Exception ex)
		{
			_logger.Error(ex);
			throw;
		}
	}

Obviously the "%synctriggerqueue%" needs a resolver with access to configuration but how do I get that into the resolver.

Can I even have a resolver in a backgroundservice??? or do I need to abandon that for a webjob.

Normally I would be able to work this out however the excessive over promotion of azure functions is making it hard to build any proper applications doe to the inability to search the search engines for documentation.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,799 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,816 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.