Azure Function Destination
Segment makes it easy to send your data to Azure Function (and lots of other destinations). Once you track your data using our open-source libraries we’ll translate and route your data to Azure Function in the format they understand. Learn more about how to use Azure Function with Segment.
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.
NOTE: Azure Function is currently in beta, and this doc was last updated on May 6, 2019. This means that there may still be some bugs for us to iron out and we’re excited to hear your thoughts. If you are interested in joining or have any feedback to help us improve the Azure Function Destination and its documentation, let us know!
Getting Started
Before you start, make sure Azure Function supports the source type and connection mode you’ve chosen to implement. You can learn more about connection modes here.
| Web | Mobile | Server | |
|---|---|---|---|
| 📱 Device-mode | |||
| ☁️ Cloud-mode | ✅ | ✅ | ✅ |
Build an Azure Function to Process Segment Events
In order to process events from Segment, you will need to provide a Azure Function that can handle your event flow:
- Go to https://portal.azure.com.
-
Click on
Functions App.
-
Click on
+Addto create your Function App.
- In the
App namefield, name your app. - Configure the other fields with your own flavor.
-
Click on the
Createbutton.
-
Once your function app is created, click on its name (you may have to refresh the list by clicking on the
Refreshbutton.
-
On the left pane, click on the
Functionsbutton.
-
In the main frame, click on
New function.
-
Click on
HTTP trigger.
- In the
Namefield, name your function. - In
Authorization levelfield, choseFunction. -
Click on the
Createbutton.
- set up your function code.
-
In the created function screen, click on
</> Get function URL.
- In the
Keyfield, if not already selected, selectdefault (Function key). - Click on the
Copybutton in order to copy the URL. Keep this URL in order to later set up the Azure Function Segment destination.
Configure Azure Function Destination
Once the Azure Function is created, a destination that will call the function must be configured:
- In our
Destinationssection, click onAdd Destination. You will be redirected to ourCatalog. - Search and client on
Azure Functiondestination. - Click on
Configure Azure Function. - Fill the settings.
Settings:
| HTTP Trigger | The URL copied from </> Get function URL button in the Azure function code screen. |
Personas
You can send computed traits and audiences generated using Segment Personas to this destination as a user property. To learn more about Personas, contact us for 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 indicade membership. For example, when a user first completes an order in the last 30 days, Personas 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), Personas sets that value to false.
When you first create an audience, Personas 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.
Settings
Segment lets you change these destination settings from the Segment app without having to touch any code.
HTTP Trigger
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: 17 Jul 2020
Need support?
Questions? Problems? Need more info? Contact us, and we can help!