How to set up custom header for Azure Service Bus Message in Azure AD B2C Custom Policy?

Nilam Patel 0 Reputation points
2025-01-27T14:44:07.86+00:00

Hello,

I am currently working on an Azure AD B2C custom policy and need to send a message to Azure Service Bus with a custom header. Specifically, I need to set the BrokerProperties.ScheduledEnqueueTimeUtc header while sending the message.

Here is the TechnicalProfile configuration I am using:

<TechnicalProfile Id="SendServiceBusMessage">

  <DisplayName>Send Service Bus Message</DisplayName>

  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

  <Metadata>

    <Item Key="ServiceUrl">serviceUrl</Item>

    <Item Key="SendClaimsIn">Body</Item>

    <Item Key="AuthenticationType">ApiKeyHeader</Item>

<Item Key="ClaimUsedForRequestPayload">serviceBusMessage</Item>

    <Item Key="HttpMethod">POST</Item>

    <Item Key="BrokerProperties.ScheduledEnqueueTimeUtc">Mon, 27 Jan 2025 12:57:20 GMT</Item>

  </Metadata>

  <CryptographicKeys>

    <Key Id="Authorization" StorageReferenceId="TokenKey" />

  </CryptographicKeys>

  <InputClaims>

    <InputClaim ClaimTypeReferenceId="serviceBusMessage" DefaultValue='{"enable": false, "identityObjectId":"id"}' AlwaysUseDefaultValue="true" />

  </InputClaims>

  <OutputClaims>

    <OutputClaim ClaimTypeReferenceId="statusCode" />

  </OutputClaims>

</TechnicalProfile>

This flow works, but it does not set the custom header BrokerProperties.ScheduledEnqueueTimeUtc. If I try the same request with Postman, it works correctly by passing the custom header BrokerProperties with the value {"ScheduledEnqueueTimeUtc":"Mon, 27 Jan 2025 12:57:20 GMT"}.

Thanks in advance

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
661 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jay Rao 0 Reputation points
    2025-01-27T15:54:24.5566667+00:00

    As mentioned by Khadeer Ali, indeed that would be a workaround. Meanwhile, to what you ask specifically a sample example to try could also be this.
    <TechnicalProfile Id="SendServiceBusMessage">

    <DisplayName>Send Service Bus Message</DisplayName>

    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

    <Metadata>

    <Item Key="ServiceUrl">serviceUrl</Item>
    
    <Item Key="SendClaimsIn">Header</Item>
    
    <Item Key="AuthenticationType">ApiKeyHeader</Item>
    
    <Item Key="HttpMethod">POST</Item>
    

    </Metadata>

    <CryptographicKeys>

    <Key Id="Authorization" StorageReferenceId="TokenKey" />
    

    </CryptographicKeys>

    <InputClaims>

    <!-- Claim for the service bus message payload -->
    
    <InputClaim ClaimTypeReferenceId="serviceBusMessage" DefaultValue='{"enable": false, "identityObjectId":"id"}' AlwaysUseDefaultValue="true" />
    
    
    
    <!-- Claim for the custom header: BrokerProperties.ScheduledEnqueueTimeUtc -->
    
    <InputClaim ClaimTypeReferenceId="ScheduledEnqueueTimeUtc" PartnerClaimType="BrokerProperties.ScheduledEnqueueTimeUtc" DefaultValue="Mon, 27 Jan 2025 12:57:20 GMT" AlwaysUseDefaultValue="true" />
    

    </InputClaims>

    <OutputClaims>

    <OutputClaim ClaimTypeReferenceId="statusCode" />
    

    </OutputClaims>

    </TechnicalProfile>

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.