3

I routed incoming iot-hub message to Blob Storage. Then, messages will be parsed and stored in to SQL database. I plan to use: EnqueueTime as primary key, so is Eventhub message's enqueue time unique? Here is an example of enqueue time: 2019-10-29T04:32:54.6770000Z

Thanks.

duy
  • 579
  • 5
  • 16
  • Risky strategy IMO, if you need a surrogate key you could use the `MessageId` – James Oct 30 '19 at 09:26
  • Unfortunately, there is no MessageId in blob file. – duy Oct 30 '19 at 09:30
  • 2
    it won't be in the payload of the message, it will be in the metadata, it does exist though. Also, do you intend on using the ID for any other reason other than having a unique surrogate key? If not, then I'd just generate a random UUID instead e.g. [NEWID()](https://learn.microsoft.com/en-us/sql/t-sql/functions/newid-transact-sql?view=sql-server-ver15) – James Oct 30 '19 at 11:09
  • Thanks James, I think UUID is the best solution. – duy Oct 30 '19 at 22:45

1 Answers1

1

Using TimeStamp for any system as a unique identifier is risk idea. You can use the messageId OR sequence-number of the IOT hub message properties or You should generate a new property named Id which is unique before you are storing to blob storage.

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396