Azure Function or Background Service

Viewed 510

I have a Conversation class and it contains a List of Messages. I have provided the feature for the user to upload an attachment. I am using two separate Database for storage. Conversation class uses SqlServer and Messages are stored in MongoDb.

So when a user deletes his conversation, three tasks are being carried out:

  1. I have to soft delete his/her conversation from Conversation Database.
  2. I have to delete all the messages of that conversation from MessageDb in MongoDb.
  3. I have to remove all the attachment of that conversation from the cloud storage.

Since these three tasks are being carried out after one another,it takes much time to send the response to the user. I am considering whether to use Background Service or Azure Function for the deletion of messages and attachment from cloud storage.It would be much appreciated if you guys could provide me with a suggestion.

1 Answers

I think your needs can be done using azure function, there is no need to use background services. For example, if you use httptrigger, you only need to write the code to delete messages and attachments inside the function body, and then deploy it to Azure to send a request to the URL trigger when needed. You need to note that the azure function has a timeout period. Take a look at this document:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout

You can use App Service plan to avoid this.

For your ideas, I think azure function is easier to do.

Related