0

The azure-eventhub (1.3.2) lib for python only allows users to send and consume messages from Azure EventHub.

Use the Event Hubs client library for Python to:

  • Publish events to the Event Hubs service through a sender.

  • Read events from the Event Hubs service through a receiver.

For conception and debugging purposes, I tried using the querying console available on the Azure portal but the experience was... unproductive (multiple crashes, reloads, etc.). Is there a way to execute steaming analytics queries from python code?

Example query:

SELECT
    [event],
    DATEDIFF(...)
INTO
    [Output]
FROM
    [input] TIMESTAMP BY Time
Community
  • 1
  • 1
Nicolas Gaborel
  • 549
  • 1
  • 5
  • 16

2 Answers2

1

There is no python sdk for azure stream analytics.

If you have to use python, you can try to use python call related powershell script for your purpose.

Here is an example of how to use python call powershell.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • Even through python, powershell scripts can only be called on a Windows machine, right? I suppose `subprocess.Popen(["powershell.exe"...` wont work on UNIX machines. – Nicolas Gaborel Sep 26 '19 at 09:56
  • @NicolasGaborel, yes, the sample is for windows os. But for UNIX, powershell cmdlet / powershell .ps1 file can be run if you install [powershell core](https://www.starwindsoftware.com/blog/using-powershell-on-linux). I have no experience for UNIX, you can take a try to search / use python to call powershell in UNIX(maybe there should make some changes from the sample). – Ivan Glasenberg Sep 27 '19 at 01:18
0

Unfortunately, Azure Stream Analytics doesn't support queries from a python script.

Queries in Azure Stream Analytics are expressed in a SQL-like query language. The language constructs are documented in the Stream Analytics query language reference guide.

The query design can express simple pass-through logic to move event data from one input stream into an output data store, or it can do rich pattern matching and temporal analysis to calculate aggregates over various time windows as in the Build an IoT solution by using Stream Analytics guide. You can join data from multiple inputs to combine streaming events, and you can do lookups against static reference data to enrich the event values. You can also write data to multiple outputs.

For more details, refer "Query examples for common Stream Analytics usage patterns".

Hope this helps.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42