Kintone x Azure Functions (Part 3)

 

This article continues on from the previous Kintone x Azure Functions articles: Kintone x Azure Functions (Part 1) and Kintone x Azure Functions (Part 2).

 

In this article, Kintone will add data into Azure Storage using Azure Functions.
Azure Functions can work flexibly with Azure services, achieving integration using triggers and bindings with minimal amount of code, and is able to store NoSQL table data blobs, queues, and files.

Let's set up the integration by following the steps below.

The Integration Image

Azure Functions is called when a record is added into Kintone, and the record data is added to Azure Table Storage.

The integration flow
US_01.png

 

Data stored in Kintone that will be also stored into Microsoft Azure

US_02.pngUS_03.png

Prepare the Kintone App

We will use the App template below, to create an App to integrate with Azure functions:
AzureFunctions integration (product DB).zip


Refer to the App Templates page in the Kintone Help Center for steps to install App templates into your Kintone domain, and the Creating an App from a Template page for the steps to create an App from a template.


Move on to the next section after successfully creating the App in your Kintone domain.

Prepare Azure Storage

The "Microsoft Azure Storage Explorer" client tool will be used in this article to utilize Azure Storage. Download and install the tool from the Microsoft Azure website.

Learn how to use Azure Storage Explorer with Get started with Storage Explorer.

Prepare Azure Functions

Create the settings with reference to the Create your first function in the Azure Portal article on the Microsoft Azure website.
Choose the "Webhook + API" and "JavaScript" options, as shown in the below image.

US_04.png

Binding settings

Once the function is created, choose "New Output".

US_05.png

 

 

Choose "Azure Table Storage".

US_06.png

 

 

For the "Table name", input a name that matches the table name in Azure Storage.

US_07.png

 

Check that the same name is used in Azure Storage.

US_08.png

 

 

Once you finish configuring Azure Table Storage, delete the default HTTP output settings on Azure Functions.

US_09.png

 


If there is only Azure Table Storage left in the settings for the output, the setup is complete.

US_10.png

 

The Source Code

Prepare some code for Azure Functions.
Refer to the first Kintone x Azure Functions article for information on where to enter the source code for Azure Functions.

index.js for Azure Functions

US_11.png


RowKey, PartitionKey, id, name, and price are the field names of the table where data will be sent to.

 

function.json for Azure Functions

US_12.png


This json configures the in/out settings for Azure Functions. The json sets HTTP Triggers as the input and the Table of Azure Storage as the output.

The values below must be reconfigured accordingly to your Azure Storage environment.

Webhook settings for the Kintone App

Webhooks will be set up on the Kintone App, so that data is sent to Azure Functions when a new record is added.

First on Azure Functions, click on the "Get function URL" link for index.json.

webhooksettings1.png

 

Copy the URL displayed in the dialog.

webhooksettings2.png

 

Navigate to your Kintone domain, and to your App's settings. Click on "Webhook" to access the webhook settings.

webhooksettings3.png

 

Click on the + button to add a new Webhook setting. Paste in the URL that you copied earlier from Azure Functions in the previous step, and also check the "Record is added" option for the Events.
Save your settings, and update your App.

webhooksettings4.png

Now every time you add a new record to your Kintone App, the App will send the record information to Azure Functions, for the index.js code to process.

 

Test the integration

Add several records into your Kintone App. If successful, you should see the contents stored in the Kintone record being added into Azure Storage, as shown below.

US_13.png

Finally

This article introduced a powerful way for Kintone to interact with Azure Storage. Note that you can set several webhooks in Kintone, so that you can further expand this integration to update data in Azure Storage when a record in the Kintone App is updated, or delete data in Azure storage when a record in the Kintone App is deleted.

 

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!