This article continues on from the previous Kintone x Azure Functions articles: Get record data with Azure Functions and Schedule cron jobs with Azure Functions.
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
Data stored in Kintone that will be also stored into Microsoft Azure
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 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.
Binding settings
Once the function is created, choose "New Output".
Choose "Azure Table Storage".
For the "Table name", input a name that matches the table name in Azure Storage.
Check that the same name is used in Azure Storage.
Once you finish configuring Azure Table Storage, delete the default HTTP output settings on Azure Functions.
If there is only Azure Table Storage left in the settings for the output, the setup is complete.
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
RowKey, PartitionKey, id, name, and price are the field names of the table where data will be sent to.
function.json for Azure Functions
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.
Copy the URL displayed in the dialog.
Navigate to your Kintone domain, and to your App's settings. Click on "Webhook" to access the webhook settings.
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.
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.
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.