Azure Storage Queues and Message Shape



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have looked around and searched, and I cannot find anything addressing this, so if my Google Fu has failed me, please just point me in the right direction.



We are using Azure Storage Queues to trigger execution of Azure Functions (V2). (I don't believe that this usage is relevant, but I'm including it just in case.) Over the course of developing the Function, the "shape" of the input data changed (I'm using C# POCO objects and serializing them to JSON to create the queue message content.)



What I discovered was that after pushing the code changes out to Azure, the Storage Queue was continuing to send the JSON message to the Function in the old object JSON format - even though the JSON provided to the Storage Queue was in the new format.



The fix was simple enough - delete the queue and let the code re-create it. However, there's a lot of confusion here:



  1. Azure Storage Queues take messages as string values, so why is a "schema" being attached at all? I realize the message is ultimately provided in a CloudQueueMessage object, so there is probably some sort of JSON goodness happening behind the scenes. But...

  2. If there is one (and there sure appears to be one), why would the Storage Queue accept and successfully process a message that does not match that format? If anything, I would have expected the message to end up in the poison queue, rather than some attempt to "translate" the incoming message into the schema.

  3. Is there a way to deal with this "in code" (other than writing a bunch of my own code to "check the schema")?

  4. What would have happened had I provided a simple string value? (This is really more curiosity for me than anything else...)

Any answers anyone can provide/point me to would be greatly appreciated.










share|improve this question
























  • If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

    – Jerry Liu
    Dec 2 '18 at 12:17











  • I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

    – S. McChesney
    Dec 3 '18 at 19:46











  • Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

    – Jerry Liu
    Dec 14 '18 at 8:27

















0















I have looked around and searched, and I cannot find anything addressing this, so if my Google Fu has failed me, please just point me in the right direction.



We are using Azure Storage Queues to trigger execution of Azure Functions (V2). (I don't believe that this usage is relevant, but I'm including it just in case.) Over the course of developing the Function, the "shape" of the input data changed (I'm using C# POCO objects and serializing them to JSON to create the queue message content.)



What I discovered was that after pushing the code changes out to Azure, the Storage Queue was continuing to send the JSON message to the Function in the old object JSON format - even though the JSON provided to the Storage Queue was in the new format.



The fix was simple enough - delete the queue and let the code re-create it. However, there's a lot of confusion here:



  1. Azure Storage Queues take messages as string values, so why is a "schema" being attached at all? I realize the message is ultimately provided in a CloudQueueMessage object, so there is probably some sort of JSON goodness happening behind the scenes. But...

  2. If there is one (and there sure appears to be one), why would the Storage Queue accept and successfully process a message that does not match that format? If anything, I would have expected the message to end up in the poison queue, rather than some attempt to "translate" the incoming message into the schema.

  3. Is there a way to deal with this "in code" (other than writing a bunch of my own code to "check the schema")?

  4. What would have happened had I provided a simple string value? (This is really more curiosity for me than anything else...)

Any answers anyone can provide/point me to would be greatly appreciated.










share|improve this question
























  • If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

    – Jerry Liu
    Dec 2 '18 at 12:17











  • I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

    – S. McChesney
    Dec 3 '18 at 19:46











  • Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

    – Jerry Liu
    Dec 14 '18 at 8:27













0












0








0








I have looked around and searched, and I cannot find anything addressing this, so if my Google Fu has failed me, please just point me in the right direction.



We are using Azure Storage Queues to trigger execution of Azure Functions (V2). (I don't believe that this usage is relevant, but I'm including it just in case.) Over the course of developing the Function, the "shape" of the input data changed (I'm using C# POCO objects and serializing them to JSON to create the queue message content.)



What I discovered was that after pushing the code changes out to Azure, the Storage Queue was continuing to send the JSON message to the Function in the old object JSON format - even though the JSON provided to the Storage Queue was in the new format.



The fix was simple enough - delete the queue and let the code re-create it. However, there's a lot of confusion here:



  1. Azure Storage Queues take messages as string values, so why is a "schema" being attached at all? I realize the message is ultimately provided in a CloudQueueMessage object, so there is probably some sort of JSON goodness happening behind the scenes. But...

  2. If there is one (and there sure appears to be one), why would the Storage Queue accept and successfully process a message that does not match that format? If anything, I would have expected the message to end up in the poison queue, rather than some attempt to "translate" the incoming message into the schema.

  3. Is there a way to deal with this "in code" (other than writing a bunch of my own code to "check the schema")?

  4. What would have happened had I provided a simple string value? (This is really more curiosity for me than anything else...)

Any answers anyone can provide/point me to would be greatly appreciated.










share|improve this question
















I have looked around and searched, and I cannot find anything addressing this, so if my Google Fu has failed me, please just point me in the right direction.



We are using Azure Storage Queues to trigger execution of Azure Functions (V2). (I don't believe that this usage is relevant, but I'm including it just in case.) Over the course of developing the Function, the "shape" of the input data changed (I'm using C# POCO objects and serializing them to JSON to create the queue message content.)



What I discovered was that after pushing the code changes out to Azure, the Storage Queue was continuing to send the JSON message to the Function in the old object JSON format - even though the JSON provided to the Storage Queue was in the new format.



The fix was simple enough - delete the queue and let the code re-create it. However, there's a lot of confusion here:



  1. Azure Storage Queues take messages as string values, so why is a "schema" being attached at all? I realize the message is ultimately provided in a CloudQueueMessage object, so there is probably some sort of JSON goodness happening behind the scenes. But...

  2. If there is one (and there sure appears to be one), why would the Storage Queue accept and successfully process a message that does not match that format? If anything, I would have expected the message to end up in the poison queue, rather than some attempt to "translate" the incoming message into the schema.

  3. Is there a way to deal with this "in code" (other than writing a bunch of my own code to "check the schema")?

  4. What would have happened had I provided a simple string value? (This is really more curiosity for me than anything else...)

Any answers anyone can provide/point me to would be greatly appreciated.







azure azure-storage azure-functions azure-storage-queues






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 9:59









Jerry Liu

11.6k11335




11.6k11335










asked Nov 15 '18 at 17:05









S. McChesneyS. McChesney

163




163












  • If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

    – Jerry Liu
    Dec 2 '18 at 12:17











  • I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

    – S. McChesney
    Dec 3 '18 at 19:46











  • Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

    – Jerry Liu
    Dec 14 '18 at 8:27

















  • If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

    – Jerry Liu
    Dec 2 '18 at 12:17











  • I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

    – S. McChesney
    Dec 3 '18 at 19:46











  • Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

    – Jerry Liu
    Dec 14 '18 at 8:27
















If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

– Jerry Liu
Dec 2 '18 at 12:17





If my explanation did some help, could you accept it to close your question? Any confusion, just ask.

– Jerry Liu
Dec 2 '18 at 12:17













I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

– S. McChesney
Dec 3 '18 at 19:46





I am not talking about the CloudQueueMessage itself. When I debug my Function and hover over the string parameter that receives the message-queue data, the JSON string I receive is not the shape of the new POCO object - it is the shape of the old POCO object. It's like, internally, the Functions runtime is taking the JSON I pass to the CloudQueueMessage constructor and parsing it into an object - but the object it expects is the shape of the object when the queue was created. So it tried to create that kind of object and then put the JSON I provide into it, which does not work.

– S. McChesney
Dec 3 '18 at 19:46













Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

– Jerry Liu
Dec 14 '18 at 8:27





Sorry for my poor comprehension, could you display the structure of old and new POCO object? IMO once we create a CloudQueueMessage with some string content, the content can only be modified by ourselves. The string parameter in Function method signature is supposed to get exactly the string content with no changes.

– Jerry Liu
Dec 14 '18 at 8:27












1 Answer
1






active

oldest

votes


















0














You probably mistake message content with CloudQueueMessage object.



What we usually handle in code is message content/text/body containing the information we want to process. In your case, i.e. C# POCO and the serialized Json payload.



When we create a queue message in Azure Storage Queue, several properties are populated by Azure. CloudQueueMessage object is composed of message content and these properties. They are used to control how queue messages behave when we process its content, check the doc for their usage.



 public static long MaxMessageSize get; 
public static TimeSpan MaxVisibilityTimeout get;
public static int MaxNumberOfMessagesToPeek get;
public string Id get;
public string PopReceipt get;
public DateTimeOffset? InsertionTime get;
public DateTimeOffset? ExpirationTime get;
public DateTimeOffset? NextVisibleTime get;
public int DequeueCount get;


As for the message content itself, it can be a string or byte array. When Azure Function receives the message, we have several options how queue message are populated, the first three take message content only.



  • Object - The Functions runtime deserializes a JSON payload into an instance of an arbitrary class defined in your code.

  • string

  • byte

  • CloudQueueMessage





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324564%2fazure-storage-queues-and-message-shape%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You probably mistake message content with CloudQueueMessage object.



    What we usually handle in code is message content/text/body containing the information we want to process. In your case, i.e. C# POCO and the serialized Json payload.



    When we create a queue message in Azure Storage Queue, several properties are populated by Azure. CloudQueueMessage object is composed of message content and these properties. They are used to control how queue messages behave when we process its content, check the doc for their usage.



     public static long MaxMessageSize get; 
    public static TimeSpan MaxVisibilityTimeout get;
    public static int MaxNumberOfMessagesToPeek get;
    public string Id get;
    public string PopReceipt get;
    public DateTimeOffset? InsertionTime get;
    public DateTimeOffset? ExpirationTime get;
    public DateTimeOffset? NextVisibleTime get;
    public int DequeueCount get;


    As for the message content itself, it can be a string or byte array. When Azure Function receives the message, we have several options how queue message are populated, the first three take message content only.



    • Object - The Functions runtime deserializes a JSON payload into an instance of an arbitrary class defined in your code.

    • string

    • byte

    • CloudQueueMessage





    share|improve this answer





























      0














      You probably mistake message content with CloudQueueMessage object.



      What we usually handle in code is message content/text/body containing the information we want to process. In your case, i.e. C# POCO and the serialized Json payload.



      When we create a queue message in Azure Storage Queue, several properties are populated by Azure. CloudQueueMessage object is composed of message content and these properties. They are used to control how queue messages behave when we process its content, check the doc for their usage.



       public static long MaxMessageSize get; 
      public static TimeSpan MaxVisibilityTimeout get;
      public static int MaxNumberOfMessagesToPeek get;
      public string Id get;
      public string PopReceipt get;
      public DateTimeOffset? InsertionTime get;
      public DateTimeOffset? ExpirationTime get;
      public DateTimeOffset? NextVisibleTime get;
      public int DequeueCount get;


      As for the message content itself, it can be a string or byte array. When Azure Function receives the message, we have several options how queue message are populated, the first three take message content only.



      • Object - The Functions runtime deserializes a JSON payload into an instance of an arbitrary class defined in your code.

      • string

      • byte

      • CloudQueueMessage





      share|improve this answer



























        0












        0








        0







        You probably mistake message content with CloudQueueMessage object.



        What we usually handle in code is message content/text/body containing the information we want to process. In your case, i.e. C# POCO and the serialized Json payload.



        When we create a queue message in Azure Storage Queue, several properties are populated by Azure. CloudQueueMessage object is composed of message content and these properties. They are used to control how queue messages behave when we process its content, check the doc for their usage.



         public static long MaxMessageSize get; 
        public static TimeSpan MaxVisibilityTimeout get;
        public static int MaxNumberOfMessagesToPeek get;
        public string Id get;
        public string PopReceipt get;
        public DateTimeOffset? InsertionTime get;
        public DateTimeOffset? ExpirationTime get;
        public DateTimeOffset? NextVisibleTime get;
        public int DequeueCount get;


        As for the message content itself, it can be a string or byte array. When Azure Function receives the message, we have several options how queue message are populated, the first three take message content only.



        • Object - The Functions runtime deserializes a JSON payload into an instance of an arbitrary class defined in your code.

        • string

        • byte

        • CloudQueueMessage





        share|improve this answer















        You probably mistake message content with CloudQueueMessage object.



        What we usually handle in code is message content/text/body containing the information we want to process. In your case, i.e. C# POCO and the serialized Json payload.



        When we create a queue message in Azure Storage Queue, several properties are populated by Azure. CloudQueueMessage object is composed of message content and these properties. They are used to control how queue messages behave when we process its content, check the doc for their usage.



         public static long MaxMessageSize get; 
        public static TimeSpan MaxVisibilityTimeout get;
        public static int MaxNumberOfMessagesToPeek get;
        public string Id get;
        public string PopReceipt get;
        public DateTimeOffset? InsertionTime get;
        public DateTimeOffset? ExpirationTime get;
        public DateTimeOffset? NextVisibleTime get;
        public int DequeueCount get;


        As for the message content itself, it can be a string or byte array. When Azure Function receives the message, we have several options how queue message are populated, the first three take message content only.



        • Object - The Functions runtime deserializes a JSON payload into an instance of an arbitrary class defined in your code.

        • string

        • byte

        • CloudQueueMessage






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 '18 at 10:03

























        answered Nov 16 '18 at 9:58









        Jerry LiuJerry Liu

        11.6k11335




        11.6k11335





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324564%2fazure-storage-queues-and-message-shape%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo