Dev Guide
Dev GuideUser GuidesGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Overview

Build a sample app from start to finish in Optimizely Connect Platform (OCP).

Description of what the sample app will do. For example:

Build a sample app in OPTIHUB that lets customers synchronize data from an Azure storage account to Optimizely Data Platform (ODP).

Bulleted list of what you will learn from following this quickstart guide. For example:

You will learn how to:

  • register and scaffold an app
  • add objects and fields to OPTIHUB schema
  • build a setting form that allows authentication in a third-party service (in this case, an Azure storage account)
  • build a function that listens to events from an Azure storage account and imports new data to OPTIHUB
  • build a job that periodically imports data from an Azure storage account to OPTIHUB
  • test and troubleshoot your app in a sandbox environment
  • publish your app to the OPTIHUB App Directory
Callout for the source code of this sample app. For example:
📘

Note

The full source code of this sample app is available in the ocp-quickstart GitHub repository.

App considerations

List any assumptions about the customer's access or environment to be able to build the sample app. For example:

Any customers using this app should have a third-party system that can send data to an Azure storage account. For simplicity, this quickstart guide assumes that the data format is fixed and defined by the app.

📘

Note

Typically, the app needs to handle the data format defined by a third-party service.

App description

Provide a detailed description of what the app does (what use case does it solve). Provide a bulleted list of any specific data that this app will handle. For example:

Ecommerce clients have successfully integrated their online stores with OPTIHUB. However, some also have offline stores that they want to integrate. These clients push their offline store data and order information to an Azure storage account.

This quickstart guide shows how to write an OPTIHUB app that pulls this data from Azure and writes it to OPTIHUB.

Orders are pushed individually as JSON files that contain the following details for order, customer, and offline store:

  • order_id – string
  • price_total – number
  • customer_email – string
  • customer_clubcard_id – string
  • customer_clubcard_creation_date – timestamp
  • offline_store_id – string
  • items - an array of order items, where each item contains:
    • product_id – string
    • quantity – number
    • price – number
    • subtotal – number
    • discount – number

Offline stores are kept in a single JSONL file that is updated throughout the day:

  • id – string
  • name – string
  • location – string

Prerequisites

Bulleted list of requirements that the customer must meet before they can start building the sample app. For example:

Configure resources in Azure

A subsection like this is only required if there are additional steps or context to provide for any of the prereqs. For example:

Configure the following resources in Azure:

  • An Azure resource group and storage account. Standard performance and local redundancy are sufficient, and other default settings are okay.
  • Two containers in your Azure storage account; one for offline store data and one for offline orders data. Select the private container option for both.
  • Register the Event Grid resource provider for your subscription.
  • An app registration in Azure (Azure app) to access Azure resources programmatically. Default settings are okay.
  • A client secret for the app registration.
    📘

    Note

    Store the secret securely when you create it because you cannot view it again.

  • The service principal associated with your app registration must have the following permissions:
    • Microsoft.EventGrid/eventSubscriptions/read
    • Microsoft.EventGrid/eventSubscriptions/write
    • Microsoft.Storage/storageAccounts/blobServices/read
    • Microsoft.Storage/storageAccounts/blobServices/containers/read
      📘

      Note

      The easiest way is to assign the EventGrid EventSubscription Contributor and Storage Blob Data Reader roles to your service principal at the resource scope. Alternatively, you can assign roles at another scope (such as a storage account or subscription) or create and assign a custom role.

Get information from your Azure account

A subsection like this is only required if there are additional steps or context to provide for any of the prereqs. For example:

After you configure everything in Azure, you need the following information from your Azure account to test your app:

  • Azure client ID – Application (client) ID field of your Azure app registration.
  • Azure tenant ID – Find your Azure AD tenant or Directory (tenant) ID of your Azure app registration.
  • Azure client secret – The secret you created for your Azure app registration.
  • Azure Subscription Id – Find your Azure subscription.
  • Azure resource group
  • Azure storage account name
  • Azure storage container name

Your next step is to scaffold the app and define its schema.