问题
I would like to create a background task for my Azure Saas application. The task is to look at the date field of an Azure SQL database table and take action based on the the result. The task should run once a day against all SaaS tenants. I have multi-tenancy with ShardMapManager with a separate Azure SQL database per tenant. I cannot find any information on how to set up WebJobs or Web functions to cycle through each of the tenant databases automatically. Would Elastic Job be involved which will run through the different databases? The problem is that it only uses T-SQL code. Would a combination of EasticJobs and WebJobs be required? Basically how can I create a background job that would be processed against all tenant databases?
回答1:
I think you could try going with a Timer trigger for Azure Functions and just place the code that iterates through the databases and perform the required tasks inside as Azure Function.
I would even go further to separate the process into two different functions:
Iterating through the databases
Perform the required logic per database
Hope it helps!
来源:https://stackoverflow.com/questions/53244425/how-to-create-a-app-background-job-for-multi-tenancy-azure-app