call to replace anchor tags contains '/admin' in href

Writing Azure Functions

StoreHippo uses azure functions to execute background long-running jobs like Import and Export jobs and scheduled tasks like getting shipping status from providers.

Github Repository

  • Functions are stored in a separate github repository hippofunctions which is synced automatically to Azure functions.
  • Any commits to the master branch of hippofunctions repository gets automatically pushed to Azure. So if you are working on a feature of change, please work on a local branch and then merge into master.

Writing a function

  • Create a file function.js that will hold the class for the function. 

  • The function class must extend the BaseFunction class and implements the start function.
  • The superclass BaseFunction makes the ms object available as a class property.

 Logger class that provides ms.logger.log and ms.logger.error functions.

The log function logs the message in the ms.function_logs entity in azure table storage.

The error function logs the message as well as sends the message to Azure stackdriver.

ms.sdk   StoreHippo SDK instance for the current store. In case of store-specific jobs, the temporary access key is automatically generated.
ms.funcThe current function object
ms.functionExecutionThe current function execution object



Every function should call ms.touch at regular intervals (at least every 30 s) to update the function execution with the current status and to tell the controller that it is still alive. The touch function should be called synchronously and function should proceed once it returns. 


(err, response)

Call this function to complete the function execution.


Basic function returning success

"use strict";

class Test extends BaseFunction {
    start() {, "success");

module.exports = Test;

Basic function calling SDK

"use strict";

class Test extends BaseFunction {
    async start() {
        var ms =;
        var request = {
            entity: 'ms.brands',
            command: 'list'
        var response = await ms.sdk.callAsync(request).catch((err) => {
            ms.logger.error("Failed getting list of brands");
        if(!response) {
            return ms.done("Failed getting the brand list");
        await this.touch({brands:});

        this.done("failed test case 2", null);

module.exports = Test;

Handling Errors

  • Use ms.logger.log and ms.logger.error to log messages and report errors.
  • Throw an Error for any unexpected error. The function controller automatically tries failed functions 3 times.
  • To complete the function execution with error, call ms.done function with error as first argument.

Maintaining State

Every function should be written in a way so that it can be restarted without having any adverse effects or data inconsistency. To keep the last state, the function must use ms.touch function to update the state at regular intervals. For example, if you are importing 10,000 products in a batch of 10 products at a time, you can update the state after every batch. That way, if the function is restarted, it will start from the last batch that was left.