How to create a app background job for multi-tenancy Azure App

假装没事ソ 提交于 2020-06-28 06:35:41

问题


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:

  1. Iterating through the databases

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!