1

I have a need to generate a next number for each file type my Logic Apps is generating. My Logic App is doing some translations between an WMS and a customer's ERP. The issue is the customer is requiring us to generate and maintain a sequence number to be placed in the files. The full list of requirements are:

  1. Generate a unique sequence number. No two calls, for the same file type, should get the same result.
  2. Number sequence is maintained separately by file type. There are 3 files types, so each would have their own sequence.
  3. Should be able to handle spurts of 10 calls a second for a few seconds at a time, which can be the same file type.
  4. Data should be stored in Azure.

I'm at the point I know I'll need to write an Azure Function to do this. It will accept one parameter, "fileType", to determine which sequence number to return. I also know I'll need to store the current number "somewhere" and that the Azure Functions itself or the database/file (thru locking) needs to be pessimistic in nature. I don't know from a cost perspective what azure storage option would work best for this scenario, as well as to make sure of the lock/release to use with that technology decision. To me, it feels like using a database to store three numbers seems like overkill.

1

2 Answers 2

1

Fun question - sounds like an interview question.

You'll need some sort of persistence. I don't think it matters much which one. I would do this:

  1. Write '100' to disk (or read previous number from disk)
  2. Set counter to zero
  3. lock and increment or interlocked increment and hand out numbers
  4. If counter reaches '100', write '200' to disk
  5. Go to 3

If it crashes, you will have a gap, but you don't have to do sync I/O on every call.

1

In case others are interested, we decided to use Azure Blob Storage using Containers with a HOT setting. It seems to work well in testing. We haven't gone live yet.

The .NET code uses the StorageInfo, CloudBlobClient, CloudBlobContainer and CloudBlockBlob classes. Also had to adapt a routine, LockingEntity, to "lock or wait for release" to get a reference to the CloudBlockBlob.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.