0

I am trying to do some logging for a triggered message(queue), so that if a message fails and it gets picked up by the webjob next time I would have logged some information so that I wouldn't redo the success paths(like sending messages to clients after stage1). So I plan on using the azure blob storage binding to configure as input and output streams. But in order to do it i need a unique name for the blob. I have a guid inside the message and i plan on using that guid to read/write from the blob storage. How do i configure this blob storage name binding dynamically from a guid field inside the queue message. (My message is very big and i don't want to use the entire message as a blob storage name).

public static void ProcessQueueMessage([QueueTrigger("%testQueue%")],
TestMessageModel testMessage,
[Blob("testStorage/{queueTrigger}", FileAccess.ReadWrite)] Stream logstream)
{

}

As you can see, the official documentation only uses queueTrigger that uses the string inside the message as the blob name. But my message looks big like this

public class TestMessageModel
{
  public Guid Id {get; set;}
  public int FromOrg {get; set;}
  public DateTime BatchDate {get; set;}
  public Payments[] payments {get; set;}  // this array is big (many items)
}

I don't want to use something that ridiculous as a blob name. how to use the Id inside the testMessage?

Anurag
  • 78
  • 9
  • Use CloudBlobContainer instead of Stream in your code. So that you can manually create a blockblob and set its name. Answer added. Please have a check. – Jack Jia Jul 16 '19 at 07:29

2 Answers2

2
  1. Add an output integration with Storage Blob. And set the path value as the container name.

enter image description here

  1. In your function code, you can directly use the container, and create a blob with specific name (which you can get from your queue message):

enter image description here

  1. Finally, you will be able to see the blob with specific name in your target container.

enter image description here

Documentation for your reference: Storage Blob Output Usage

Jack Jia
  • 5,268
  • 1
  • 12
  • 14
0

Thanks @jack Jia. That helped. But for the webjob I needed to use Blob before to bind it properly.

public static void ProcessQueueMessage([QueueTrigger("%testQueue%")],
TestMessageModel testMessage,
[Blob("testStorage")] CloudBlobContainer blobContainer)
{
   CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(testmessage.id+".txt");
}
Anurag
  • 78
  • 9