Azure Function Destination
Segment makes it easy to send your data to Azure Function (and lots of other destinations). When you track your data using Segment’s open-source libraries, Segment can translate and route your data to an Azure Function in the format it expects.
Azure Function is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. Use Azure Functions to run a script or piece of code in response to a variety of events.
This document is about a destination which is in beta
This means that the Azure Function Destination is in active development, and some functionality may change before it becomes generally available.
Getting Started
Build an Azure Function to Process Segment Events
To process events from Segment, first create a Azure Function that can handle your event flow.
Create a Functions App
-
Go to https://portal.azure.com, and click Functions App.
-
Click +Add to create your Function App.
- Enter a name for your app in the App name field, and configure any other fields as needed own flavor.
- Click Create. Azure creates your new function app.
Create a new Azure function
-
Click the new function app’s name. (You might need to click the Refresh button if the new function doesn’t appear.)
-
On the left pane, click Functions.
-
In the main frame, click New function.
-
Choose HTTP trigger.
- Enter a name for your function, and choose
Function
for the Authorization level field. -
Click
Create
. - Set up your function code.
-
In the created function screen, click on
</> Get function URL
. - In the Key field, choose
default (Function key)
. - Click Copy to the right of the URL. You’ll use this URL to tell Segment where to connect to use this Azure Function.
Configure Azure Function Destination
After you create the Azure Function, configure a Segment destination that calls the function.
- In the Segment web app, click Destinations.
- Click Add Destination to go to the Catalog.
- Search for and choose the Azure Function destination.
- Click Configure Azure Function.
- In the HTTP Trigger field, enter the URL you copied from the
</> Get function URL
button in the Azure function code screen.
Engage
You can send computed traits and audiences generated using Engage to this destination as a user property. To learn more about Engage, schedule a demo.
For user-property destinations, an identify call is sent to the destination for each user being added and removed. The property name is the snake_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Engage sends an Identify call with the property order_completed_last_30days: true
. When the user no longer satisfies this condition (for example, it’s been more than 30 days since their last order), Engage sets that value to false
.
When you first create an audience, Engage sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.
Real-time to batch destination sync frequency
Real-time audience syncs to Azure Function may take six or more hours for the initial sync to complete. Upon completion, a sync frequency of two to three hours is expected.
Settings
Segment lets you change these destination settings from the Segment app without having to touch any code.
Setting | Description |
---|---|
HTTP Trigger (required) |
string . The URL to call the Function. It must follow the ` https://{function app name}.azurewebsites.net/api/{function name}?code={function key}` pattern. |
This page was last modified: 07 Aug 2024
Need support?
Questions? Problems? Need more info? Contact Segment Support for assistance!