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

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

To process events from Segment, first create a Azure Function that can handle your event flow.

Create a Functions App

  1. Go to https://portal.azure.com, and click Functions App.

  2. Click +Add to create your Function App.

  3. Enter a name for your app in the App name field, and configure any other fields as needed own flavor.
  4. Click Create. Azure creates your new function app.

Create a new Azure function

  1. Click the new function app’s name. (You might need to click the Refresh button if the new function doesn’t appear.)

  2. On the left pane, click Functions.

  3. In the main frame, click New function.

  4. Choose HTTP trigger.

  5. Enter a name for your function, and choose Function for the Authorization level field.
  6. Click Create.

  7. Set up your function code.
  8. In the created function screen, click on </> Get function URL.

  9. In the Key field, choose default (Function key).
  10. 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.

  1. In the Segment web app, click Destinations.
  2. Click Add Destination to go to the Catalog.
  3. Search for and choose the Azure Function destination.
  4. Click Configure Azure Function.
  5. In the HTTP Trigger field, enter the URL you copied from the </> 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 indicate 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: 15 Oct 2020

Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
or
Create free account