Giter Site home page Giter Site logo

scale-tone / azure-function-pump-data-to-delta-lake Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 62 KB

Azure Function to pump events from an Azure Service Bus/Event Hub/Storage Queue into a Delta Lake table in Azure Databricks.

License: MIT License

Dockerfile 10.48% Python 79.98% Shell 9.54%
azure-functions databricks delta-lake event-hubs service-bus storage-queues

azure-function-pump-data-to-delta-lake's Introduction

azure-function-pump-data-to-delta-lake

An Azure Function to pump (stream) events to a Delta Lake table in Azure Databricks. Supports Azure Service Bus (queues/topics), Azure Event Hubs and Azure Storage Queues as input source. You can even combine all these three in one single Function App instance.

The function expects each message to be either a JSON or XML representation of a record to be appended. JSON example: {"my-field1":"my-value", "my-field2": 12345}. XML example: <my-message my-field1="my-value"><my-field2>12345</my-field2></my-message>

Resulting field names and types must match the schema of your table. If they don't, specify a JSONPath expression to convert them on-the-fly.

Table must pre-exist.

Uses Databricks Connect client library to connect to your cluster, therefore is written in Python. Needs to be containerized, to maintain the correct list of dependencies. WARNING: may not work locally on your devbox (especially on Windows).

Config Settings

The following settings need to be configured in your Function App instance.

Output settings (required)

  • DATABRICKS_ADDRESS, DATABRICKS_API_TOKEN, DATABRICKS_CLUSTER_ID, DATABRICKS_ORG_ID - connection parameters to communicate with your Azure Databricks cluster. See here on how and where to get them.
  • OUTPUT_TABLE_NAME - name of your Delta Lake table, e.g. default.my-table.

Service Bus input settings (if you use Service Bus)

  • SERVICEBUS_CONN_STRING - connection string to your Azure Service Bus namespace.

  • SERVICEBUS_QUEUE_NAME - name of your input queue

    OR

  • SERVICEBUS_TOPIC_NAME, SERVICEBUS_SUBSCRIPTION_NAME - names of your topic and subscription. Specify either queue name or topic/subscription names, not both.

  • (optional) SERVICEBUS_JSONPATH_QUERY - a JSONPath expression to be applied to each message. Use it if your messages (either JSON or XML) do not match your table's schema.

Event Hubs input settings (if you use Event Hubs)

  • EVENTHUB_CONN_STRING - connection string to your Event Hubs namespace.
  • EVENTHUB_NAME - name of your input event hub.
  • (optional) EVENTHUB_JSONPATH_QUERY - a JSONPath expression to be applied to each message. Use it if your messages (either JSON or XML) do not match your table's schema.

Storage queues input settings (if you use Storage Queues)

  • STORAGE_CONN_STRING - connection string to your Azure Storage account.
  • STORAGE_QUEUE_NAME - name of your input Storage queue.
  • (optional) STORAGE_JSONPATH_QUERY - a JSONPath expression to be applied to each message. Use it if your messages (either JSON or XML) do not match your table's schema.

How to deploy to Azure

Deploy to Azure

The above button will deploy this container to a newly created Azure Functions instance (Premium plan).

Alternatively you can fork this repo and deploy it exactly as described here.

Performance

Test setup:

  • Function App instance in Premium tier locked to 2 EP2 instances (2 vCPU, 7GB memory each).
  • 3-node cluster (4 cores, 14 GB memory each).
  • Service Bus queue with Standard pricing tier, not partitioned.
  • Event Hub with 2 partitions, Standard pricing tier.
  • Storage queue in a General Purpose V2 Storage account.
  • 30000 messages of ~100 bytes each.

The following results were registered:

  • Via a Service Bus queue: 215 messages per second.
  • Via an Event Hub: 230 messages per second.
  • Via a Storage Queue: 75 messages per second.

There is a strong belief that these numbers can be significantly improved by playing with batch size settings (which can be adjusted via config settings)

azure-function-pump-data-to-delta-lake's People

Contributors

scale-tone avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.