Overview
Build a sample app from start to finish in Optimizely Connect Platform (OCP).
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
NoteThe 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.
NoteTypically, 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– stringprice_total– numbercustomer_email– stringcustomer_clubcard_id– stringcustomer_clubcard_creation_date– timestampoffline_store_id– stringitems- an array of order items, where each item contains:product_id– stringquantity– numberprice– numbersubtotal– numberdiscount– number
Offline stores are kept in a single JSONL file that is updated throughout the day:
id– stringname– stringlocation– string
Prerequisites
Bulleted list of requirements that the customer must meet before they can start building the sample app. For example:
- Configure the OPTIHUB CLI.
- An Azure account. If you want a free trial account, see Azure's page on creating a free account.
- A sandbox OPTIHUB account to test your app. Use the same request forms listed in the Request an OCP developer account section.
- Configure resources in Azure.
- Get information from your Azure account so you can test your app.
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 containeroption 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/readMicrosoft.EventGrid/eventSubscriptions/writeMicrosoft.Storage/storageAccounts/blobServices/readMicrosoft.Storage/storageAccounts/blobServices/containers/readNoteThe easiest way is to assign the
EventGrid EventSubscription ContributorandStorage Blob Data Readerroles 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) IDfield of your Azure app registration. - Azure tenant ID – Find your Azure AD tenant or
Directory (tenant) IDof 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.