cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kajalpatel
Regular Visitor

PowerApps connection with EventHubs

I have added Azure EventHub Connector to the PowerApp. 

How can I send and receive events? 

I found this, https://www.carlosag.net/PowerApps/Connectors/Event-Hubs

How can these methods be used?

1 ACCEPTED SOLUTION

Accepted Solutions

@kajalpatel 

 

We had some time to make the test with a full Event Hub Namespace with an Event Hub in it, and using this from a sample Power Apps Canvas App.

 

After a full test, we find that we can send event successfully from Power Apps Canvas App to the Event Hub like this:

 

 

EventHubs.SendEvent("instanceeventhubpowerusersdemo1",{partitionKey:0,ContentData:SamplePdf})

 

 

In fact, only ContentData is required for SendEvent (partitionKey is only required with SendEvents)

We can simplify the above to:

 

 

EventHubs.SendEvent("instanceeventhubpowerusersdemo1",{ContentData:SamplePdf})

 

 

The ContentData must be provided and it must be of data type Blob when sent from Power Apps. So how do you send a Blob out of Power Apps Canvas App? Well, Power Apps has an easy way to simulate a Blob, and that is from a SamplePdf Blob data type that comes included with the PDF Control. Other than this, a Blob may need to be constructed using a value from Power Automate. Other than the potential of using a value from the PDF Control to have a Blob type, we are not sure of another way to construct a Blob data type besides perhaps specifically returning a value using Power Automate that would be interpreted by Power Apps as a Blob data type, and having that called from the Power App (Note that as of this writing, there is no such thing as a native "Blob" function in Power Apps that could convert some other kind of value to a"Blob" data type)

 

Check example below and network response, and evidence it worked in the Event Hub.

 

successblob101.gif

 

 

Check if the above helps @kajalpatel 

View solution in original post

5 REPLIES 5
poweractivate
Super User II
Super User II

@kajalpatel 

 

Use this official documentation instead:

 

https://docs.microsoft.com/en-us/connectors/eventhubs/

 

and also, you use it by using them in Formulas. 

 

For example, OnNewEvents becomes available for use as a Function in a formula, and so forth, of course, presuming the Azure Event Hubs Connector was indeed added to the App.

 

Check if this above helps.

 

 

@poweractivate 

 

How do I use the SendEvent method, from the official documentation I get this

 

KeyType
eventHubNamestring
ContentDatabyte
partitionKeystring

 

Can you help with some sample parameters?

@kajalpatel 

We may have been able to achieve this before actually, but we might have to do a deep check on the answer.

We might have to make a full test about this, and then let you know after a while.

 

We can find many on this topic:

[EventHubs]: Need assistance while sending data from PowerApps to Event Hubs

How to send data from apps to Azure eventHub  
  Sample code for EventHub.SendEvent 

 

However, it seems all of them do not have any answer there.

Also, in the conceptual level, a generic answer like to say use a Record, etc. seems like it would not suffice here.

It is a very specific syntax, we would have to do a deep check how we might have gotten it to work before this SendEvent, and also, test this now to make sure this way still works.

 

In our case, this may take some time, as we may not be able to perform this kind of test right away right now.

 

So we would also kindly ask the community, if someone else knows how to do this specifically, please go ahead and reply with the answer. 

 

If there is no reply here after a while, we might come back and check here, time permitting of course.

@kajalpatel 

 

We had some time to make the test with a full Event Hub Namespace with an Event Hub in it, and using this from a sample Power Apps Canvas App.

 

After a full test, we find that we can send event successfully from Power Apps Canvas App to the Event Hub like this:

 

 

EventHubs.SendEvent("instanceeventhubpowerusersdemo1",{partitionKey:0,ContentData:SamplePdf})

 

 

In fact, only ContentData is required for SendEvent (partitionKey is only required with SendEvents)

We can simplify the above to:

 

 

EventHubs.SendEvent("instanceeventhubpowerusersdemo1",{ContentData:SamplePdf})

 

 

The ContentData must be provided and it must be of data type Blob when sent from Power Apps. So how do you send a Blob out of Power Apps Canvas App? Well, Power Apps has an easy way to simulate a Blob, and that is from a SamplePdf Blob data type that comes included with the PDF Control. Other than this, a Blob may need to be constructed using a value from Power Automate. Other than the potential of using a value from the PDF Control to have a Blob type, we are not sure of another way to construct a Blob data type besides perhaps specifically returning a value using Power Automate that would be interpreted by Power Apps as a Blob data type, and having that called from the Power App (Note that as of this writing, there is no such thing as a native "Blob" function in Power Apps that could convert some other kind of value to a"Blob" data type)

 

Check example below and network response, and evidence it worked in the Event Hub.

 

successblob101.gif

 

 

Check if the above helps @kajalpatel 

View solution in original post

DrEsteban
Microsoft
Microsoft

@poweractivate  Can you please provide a full example of how you loaded data into the PDF Viewer, then pulled it out again for use with the Event Hub connector? (As Blob format.) For example, if I have a JSON string I want to send to Event Hub, what is the full E2E for doing that?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (48,544)