Create a new api proxy

Here is my usecase,

I have to push an event to eventhub for each call (success). Target endpoint is the event hub

Thanks in advance!!

1 4 256
4 REPLIES 4

Is this a developer portal question?

Use a ServiceCallout

"for each call (Success)"

I guess you mean, for every API request received by your Apigee Edge proxy, you'd like to send another request OUT to eventhub. No problem.

Use a ServiceCallout policy to perform that POST. The policy configuration will look like this:

<ServiceCallout name='SC1'>
  <Request>
    <Set>
     <Headers>
       <Header name='Authorization'>SharedAccessSignature sig={sa_signature}&se={sa_timevalue}&skn={sa_skn}&sr={sa_url}'</Header>
     </Headers>
     <QueryParams>
       <QueryParam name='timeout'>60</FormParam>
       <QueryParam name='version'>2014-01</FormParam>
     </QueryParams>
     <Payload contentType='text/plain'>Hello World</Payload>
     <Verb>POST</Verb>
    </Set>
  </Request>
  <Response>eventHubResponse</Response>
  <HTTPTargetConnection>
    <Properties>
      <Property name='success.codes'>2xx, 3xx</Property>
    </Properties>
    <URL>https://nifi-eventhub.servicebus.windows.net/hub1/messages</URL>
  </HTTPTargetConnection>
</ServiceCallout>

Then, you need a separate policy to set all the context variables that are referenced in the Authorization header:

  • sa_skn
  • sa_signature
  • sa_timevalue
  • sa_url

I don't know how you calculate the signature, but presumably you know how to do that. You can run logic in a JS or Python policy to calculate it, or maybe callout to a separate service that gives you a current valid signature.

Connect the JS (calculation) logic and the SC policy into a Shared Flow, and then set that sharedflow on the post-response flowhook. boom.

The SAS Token is the hard part. Can you help shed some light on how to do that? The process to sign the token uses methods that are not natively supported in a JS callout.

Hi Brian, sounds like an addendum to an older question. I posted a new question here: https://community.apigee.com/questions/77918/in-apigee-how-can-i-create-a-signed-sas-token-for.html