title: Using a common object between different stages of execution from Azure Functions
body: <p>I am working in an Azure function app development. There are different project dependencies as well. The business logic is implemented at application layer.</p>
  <p>Environment: .NET 6</p>
  <p>The function does different tasks such as</p>
  <ul>
  <li>generate a transaction ID</li>
  <li>Fetch data from Db based on an input parameter</li>
  <li>Transform the data</li>
  <li>Write the transformed data into DB</li>
  <li>Write the transformed data into service bus topic</li>
  </ul>
  <p>When all these steps finishes, it needs to write the log into a service bus queue.
  Also the execution happens at function level as well as application layer</p>
  <p>For example the ID created immediately when Azure function being hit. Tranformation happens at application layer project.</p>
  <p>But I need to hold all these information into a single object and that object I am going to write into a service bus queue as a JSON message.</p>
  <p>Here is my class definition.</p>
  <pre><code>Public class ServiceMessage
  {
  
      public Guid Id { get; set; }
  
      public int ProcessId { get; set; }
  
      public object? ProcessExecutionId { get; set; }
  
      public string? PrimaryObjectName { get; set; }
  
      public string? ServiceName { get; set; }
  
      public Status Status { get; set; }
  
      public List&lt;Message&gt;? Message { get; set; }
  }
  public sealed class Message
  {
  
      public Status Status { get; set; }
  
      public string? Remarks { get; set; }
  
      public string? Timestamp { get; set; }
  
  }
  public enum Status
  {
      Failure = 0,
      InProgress = 1,
      Success = 2
  }
  </code></pre>
  <p>While application progressing, I need to set each of these properties. Also there is a Message Array which is for holding any specific messages/error while any stages of the processing.</p>
  <p>I dont know how to handle this situation.</p>
  <p>I thought about declaring an object initially and passing the same object to different methods and there it got updated and that methods return back the object and the same for everywhere. But I believe its a bad approach.</p>
  <p>Could you please help me to handle this.</p>