Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceBusOutput puts entire message in body if returning ServiceBusMessage #3038

Open
codebrane opened this issue Nov 3, 2023 · 0 comments

Comments

@codebrane
Copy link

codebrane commented Nov 3, 2023

I need to return a message with application properties from ServiceBusOutput so can't just use a string return. If I return a ServiceBusMessage the Body contains the entire message and the original Body is lost.

Is there any way to return anything other than a string, byte[] or JSON from ServiceBusOutput as IAsyncCollector<ServiceBusMessage> is not available in isolated worker process.

[Function("TestTrigger")]
[ServiceBusOutput("%OutputQueueName%", Connection = "ServiceBusConnection", EntityType = ServiceBusEntityType.Queue)]
public IEnumerable Run(
    [ServiceBusTrigger(queueName: "%InputQueueName%", Connection = "ServiceBusConnection")] ServiceBusReceivedMessage message
{
    var outputMessage = new ServiceBusMessage
    {
        Body = message.Body,
        MessageId = message.MessageId
    };
    outputMessage.ApplicationProperties["TheRetryCount"] = "111";

    IEnumerable<ServiceBusMessage> outputMessages = new ServiceBusMessage[] { outputMessage };
    return outputMessages;
}

In ServiceBusExplorer the message body contains everything but the original body:

{
  "Body": {},
  "MessageId": "50cd3ad39d714367a339ceb28f2d7564",
  "PartitionKey": null,
  "TransactionPartitionKey": null,
  "SessionId": null,
  "ReplyToSessionId": null,
  "TimeToLive": "10675199.02:48:05.4775807",
  "CorrelationId": null,
  "Subject": null,
  "To": null,
  "ContentType": null,
  "ReplyTo": null,
  "ScheduledEnqueueTime": "0001-01-01T00:00:00+00:00",
  "ApplicationProperties": {
    "TheRetryCount": "111"
  }
}
@codebrane codebrane changed the title ServiceBusOutput makes body null if returning ServiceBusMessage ServiceBusOutput puts entire message in body if returning ServiceBusMessage Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant