# Add e-signatures and clickwrap to an Azure Functions app

> Add e-signatures and clickwrap to an Azure Functions app: the esigncomply package in Node.js v4 functions, an application setting and Azure Table Storage.

Source: https://esigncomply.com/azure-functions

Platform · Azure Functions

To add e-signatures and clickwrap to an Azure Functions app, run the `esigncomply` package in HTTP functions on the Node.js v4 model and keep the secret key in an application setting. One function creates the session, another confirms the record, and Azure Table Storage keeps the pinned versions and the receipt for every instance. Esign Comply seals each acceptance.

Follow the quickstart and each signature is a valid electronic signature under the U.S. ESIGN Act, state UETA laws and New York's ESRA, and each clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/azure-functions)

`npm install @azure/functions esigncomply @azure/data-tables`

[Azure Functions quickstart](https://esigncomply.com/docs/quickstart/azure-functions)

Free plan: 10 live signatures a month and a full test mode. No card required.

Last updated November 26, 2026

Run locally for Azure Functions before publishing

**Session function**

src/functions/signup.js (excerpt)

```js
// Step 4: create the session with the secret key. The browser gets the client token only.
app.http("ceremony", {
  methods: ["POST"],
  authLevel: "anonymous",
  route: "api/ceremony",
  handler: async (request) => {
    // The page that runs the ceremony: the origin the browser reports, plus its path.
    const origin = request.headers.get("origin") ?? new URL(request.url).origin;
    const { data: session, error } = await esc.sessions.create(
      {
        profile: process.env.ESIGNCOMPLY_PROFILE_ID,
        signer,
        documents: [
          { document: DOCUMENTS.terms, version: "current" },
          { document: DOCUMENTS.privacy, version: "current" },
        ],
        context: { url: `${origin}/signup`, locale: "en-US", purpose: "account_signup" },
      },
      { idempotencyKey: `signup-${signer.external_id}-${randomUUID()}` },
    );
    if (error) return { status: 502, jsonBody: { error: error.code } };
    // In Table Storage, not in memory: the confirmation can reach another instance.
    await savePinned(signer.external_id, session.documents.map((d) => d.version_id).sort());
    return { jsonBody: { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents } };
  },
});
```

**host.json**

`host.json`

```json
{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  },
  "extensions": {
    "http": {
      "routePrefix": ""
    }
  }
}
```

**Confirm function**

src/functions/signup.js (excerpt)

```js
// Step 6: confirm the record with the secret key before the account exists.
app.http("confirm", {
  methods: ["POST"],
  authLevel: "anonymous",
  route: "api/signup/confirm",
  handler: async (request, context) => {
    const { recordId } = await request.json().catch(() => ({}));
    const { data: record, error } = await esc.records.get(String(recordId));
    const expected = await getPinned(signer.external_id);
    const confirmed =
      !error &&
      SEALED.includes(record.status) &&
      record.livemode === LIVE &&
      record.signer.external_id === signer.external_id &&
      expected.length > 0 &&
      JSON.stringify(record.documents.map((d) => d.version_id).sort()) === JSON.stringify(expected);
    context.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused");
    if (!confirmed) return { status: 409, jsonBody: { confirmed: false } };
    // Only now create the account. The record ID and the receipt go in the same entity.
    await saveReceipt(signer.external_id, record.id, record.receipt);
    return { jsonBody: { confirmed: true, recordId: record.id } };
  },
});
```

**Table store**

src/store.js (excerpt)

```js
// One table for every instance of the function app: instances share no memory.
// TABLES_CONNECTION_STRING is an application setting. On your machine it names Azurite, which speaks plain HTTP.
const connection = process.env.TABLES_CONNECTION_STRING ?? "";
const table = TableClient.fromConnectionString(connection, "acceptances", {
  allowInsecureConnection: /UseDevelopmentStorage=true|DefaultEndpointsProtocol=http;/.test(connection),
});

// Created once by each instance, when it loads this module. An existing table is left as it is.
const ready = table.createTable();
ready.catch(() => {}); // a failure is thrown again by the first call below, inside an invocation

// One entity per signer: the versions the session pinned, then the record and its receipt.
// A row key cannot hold / \ # or ?: encode your user ID if it can.
export async function savePinned(signerId, versionIds) {
  await ready;
  await table.upsertEntity({ partitionKey: "signer", rowKey: signerId, versionIds: JSON.stringify(versionIds) }, "Replace");
}
```

Integrate with Azure Functions

## How do you integrate Esign Comply with Azure Functions?

On Azure Functions the server half is four HTTP functions registered with `app.http()` on the Node.js v4 model. `host.json` sets the route prefix to an empty string, so the page is at `/signup` and not at `/api/signup`. Instances share no memory and an idle app can scale to zero, so the pinned versions go to a table in Azure Table Storage.

Azure Functions is a serverless solution that allows you to build robust apps while using less code, and with less infrastructure and lower costs.

Source: [Microsoft Learn, Azure Functions overview](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview), read on November 26, 2026.

[Azure Functions quickstart](https://esigncomply.com/docs/quickstart/azure-functions) · [All platforms](https://esigncomply.com/platforms)

Where each part lives on Azure Functions

- **Session function** · `src/functions/signup.js`
- **host.json** · `host.json`
- **Confirm function** · `src/functions/signup.js`
- **Table store** · `src/store.js`

Run on 2026-11-26 under Azure Functions Core Tools 4.17.0 (func start, Functions runtime 4.1055.300.26527) on the Node.js v4 programming model, with @azure/functions 4.17.1 on Node.js 24.22.1, a table in the Azurite emulator 3.38.0 in Docker through @azure/data-tables 13.3.2, esigncomply 1.0.4, the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode. Two hosts shared the table, and func pack built the deployment package. Azurite listened on other ports than its defaults on the test machine, named in an explicit connection string. The Azure settings are from Microsoft's documentation as of that date, and the az and func azure commands in step 8 were not run. Nothing has been deployed to Azure yet.

Three steps

## How does Esign Comply fit with Azure Functions?

Each step uses a feature Azure Functions already has. The secret key stays on the server side of Azure Functions in all three.

1. **An application setting holds the key**

   Set `ESIGNCOMPLY_API_KEY` as an application setting of the function app, or put a Key Vault reference in that setting. Microsoft's documentation says application settings are stored encrypted and reach the code as environment variables, so the SDK reads the key from `process.env`. Source: [Microsoft Learn, Configure function app settings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings), read on November 26, 2026.

2. **An HTTP function creates the session**

   `app.http()` registers `POST /api/ceremony` on the Node.js v4 model. The function calls `esc.sessions.create` and returns the client token. Another function serves the signup page from the same origin, and the browser SDK records the ceremony from the signer's device. Source: [Microsoft Learn, Functions Node.js developer guide](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node), read on November 26, 2026.

3. **A table keeps the receipt**

   The session function stores the pinned versions in a table in Azure Table Storage, through `@azure/data-tables`. The confirm function reads the record with the secret key, compares it with the entity, and writes the record ID and the receipt into it. Source: [Microsoft Learn, Azure Table storage overview](https://learn.microsoft.com/en-us/azure/storage/tables/table-storage-overview), read on November 26, 2026.

Azure Functions setup

## Where do the key, the preview hosts and the webhook go on Azure Functions?

Four settings carry an Esign Comply integration on Azure Functions. What is said here about Azure Functions was read from its own documentation, and the quickstart has each command.

### Application settings and Key Vault

Local settings are not published: set each value on the function app, in the portal or with `az functionapp config appsettings set`. Changing a setting restarts the app. A Key Vault reference needs a managed identity that may read the secret. Microsoft's documentation says an unresolved reference is used as its own string: in the test that string as the key gave `invalid_api_key`.

Source: [Microsoft Learn, Key Vault references as app settings](https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references), read on November 26, 2026.

### host.json and the routes

Set `extensions.http.routePrefix` to an empty string, or every route starts with `/api`. With an empty prefix no route may begin with `admin` or `runtime`: Microsoft reserves both. Give all four functions `authLevel: "anonymous"`, because a browser has no function key to send.

Source: [Microsoft Learn, Azure Functions HTTP trigger](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger), read on November 26, 2026.

### A test app, slots and test mode

Keep the test key in a function app or a slot of its own. Microsoft's documentation says the Flex Consumption plan has no deployment slots, and that a deployment slot setting stays with its slot in a swap. The host is under `azurewebsites.net`: list that exact host under Domains in the Esign Comply dashboard as a test origin, never the shared suffix.

Source: [Microsoft Learn, Azure Functions deployment slots](https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-slots), read on November 26, 2026.

### The registered domain and the webhook

Go live on a domain you own: `azurewebsites.net` is not a suffix that verifies with a file. Map the domain to the function app with a CNAME record and the `asuid` TXT record, then register it with Esign Comply and verify it with one DNS record. For the `record.completed` webhook, add an HTTP function and register its production URL under Webhooks in the Esign Comply dashboard.

Source: [Microsoft Learn, App Service custom domains](https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain), read on November 26, 2026.

Read on November 26, 2026: [Microsoft Learn, Functions Node.js developer guide](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node), [Microsoft Learn, Azure Functions HTTP trigger](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger), [Microsoft Learn, Functions HTTP triggers and bindings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook), [Microsoft Learn, Develop Functions locally, Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local), [Microsoft Learn, Code and test Azure Functions locally](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local), [Microsoft Learn, Configure function app settings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings), [Microsoft Learn, Key Vault references as app settings](https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references), [Microsoft Learn, Event-driven scaling in Functions](https://learn.microsoft.com/en-us/azure/azure-functions/event-driven-scaling), [Microsoft Learn, Azure Functions hosting options](https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale), [Microsoft Learn, Azure Functions deployment slots](https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-slots), [Microsoft Learn, App Service custom domains](https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain), [Microsoft Learn, Use the Azurite emulator](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite), [Microsoft Learn, Azure Table storage overview](https://learn.microsoft.com/en-us/azure/storage/tables/table-storage-overview).

Copy-paste prompt

## What prompt adds Esign Comply clickwrap to a Azure Functions app?

Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes on Azure Functions, what to build and what never to do, and it ends with the rules block for your project.

The rules block lives at [/rules.md](https://esigncomply.com/rules.md). Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The [prompt generator](https://esigncomply.com/product/prompt-generator) writes the long version, with your own document and profile IDs.

[Pages for each AI tool](https://esigncomply.com/build)

Prompt: Esign Comply clickwrap on Azure Functions

```
Add Esign Comply clickwrap to my app on Azure Functions: a signup form where the user accepts the Terms of Service and the Privacy Notice with a checkbox and a button.

Read these first and follow them exactly. If something conflicts with existing code, or you are unsure how to implement a step, stop and ask. Do not invent API methods, packages or legal wording.
- https://esigncomply.com/docs/quickstart/azure-functions.md (the steps and the tested code for Azure Functions)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Azure Functions facts
- Packages (the only ones that exist): esigncomply (server, Node.js 20.19 or later, an ES module) and @esigncomply/browser. Without a bundler, load the browser SDK from https://esigncomply.com/sdk/v1/esigncomply.js.
- Use the Node.js v4 programming model: app.http() in files under src/functions, and "main": "src/functions/*.js" in package.json. Do not write function.json files.
- The secret key is the application setting ESIGNCOMPLY_API_KEY of the function app, or a Key Vault reference in that setting. On the machine it is in local.settings.json, which is never committed and never published. Never print it.
- Set extensions.http.routePrefix to "" in host.json. The default prefix is "api", which puts the page at /api/signup. With an empty prefix, no route may start with admin or runtime.
- Set authLevel "anonymous" on all four functions: a browser has no function key. Core Tools does not ask for keys locally, so a route that needs one works on the machine and answers 401 on Azure.
- Instances share no memory and the app can scale to zero. Keep the pinned version IDs in Azure Table Storage, or in the database the app already has, never in a variable of the module.
- If the project has a .env file, list it in .funcignore: the deployment package takes every file that .funcignore does not name.
- Expect live records only where the application setting ESIGNCOMPLY_LIVE is "true": the production function app.
- The page is on screen before the script has a session: render the checkbox disabled and enable it when observeAssent has resolved.

Build
1. Verify the key: GET /v1/usage with ESIGNCOMPLY_API_KEY. Stop if it fails.
2. Register the Terms of Service and the Privacy Notice as documents and publish one version of each from the documents in this project. If the project has none, register short sample documents and say so in your report. Never write or change the wording of the real documents. Create a profile: jurisdictions ["US-FED"], method "checkbox", assurance_level "L1".
3. Function for POST /api/ceremony: create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs in Table Storage, and return only clientToken, apiUrl and documents.
4. Function for GET /legal/{slug}: render the registered version from esc.documents.versions.getContent inside <article data-esc-document>, unmodified.
5. Browser: EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }), then complete() from the user's real click.
6. Function for POST /api/signup/confirm: read the record with esc.records.get and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the entity in Table Storage. Only then create the account, and store the record ID and the receipt in the same entity.

Never
- Never pre-check the box, auto-submit, or call .click() on the user's behalf.
- Never use "By continuing" or "By clicking below" wording. The notice names the button by its label and each document by its registered name.
- Never put the secret key, or any call that uses it, in code that reaches the browser.
- Never show "signed" or "accepted" before the server has confirmed the record.
- Never fall back to an acceptance with no record when a session is refused.

Check before you report success
- Run: npx esigncomply check --url http://localhost:7071/signup --callback http://localhost:7071/api/signup/confirm
  Fix every finding marked "block". List every finding marked "warn".
- Report the files you created or changed, anything you did not implement and why, and the conformance summary.

Then add the rules block to this project's instruction file: https://esigncomply.com/rules.md
```

3 things to watch

## What goes wrong when you add e-signatures on Azure Functions?

These are specific to Azure Functions. Each one was seen while the quickstart's code was run, or is in Azure Functions's own documentation.

- **The default route prefix puts the page at /api/signup**

  Microsoft's documentation says all function routes are prefixed with `api` by default, and that an empty `routePrefix` in `host.json` removes the prefix. In the test without that setting, Core Tools 4.17.0 listed the page at `/api/signup` and the session route at `/api/api/ceremony`, and `/signup` answered `404`. The quickstart's `host.json` sets the prefix to an empty string.

  Source: [Microsoft Learn, Azure Functions HTTP trigger](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger), read on November 26, 2026.

- **Core Tools does not ask for function keys, and Azure does**

  Microsoft's documentation says authorization is not enforced locally, and that the requirements you configure are still enforced when the app is hosted. In the test a confirm function with `authLevel: "function"` ran for a request with no key under `func start`, and answered `401` under `func start --enableAuth`. A browser has no key to send: the quickstart sets `anonymous` on all four functions.

  Source: [Microsoft Learn, Develop Functions locally, Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local), read on November 26, 2026.

- **The deployment package takes .env unless .funcignore names it**

  The `.funcignore` that `func init` writes names `local.settings.json` and Core Tools, not `.env`. In the test, `func pack` from Core Tools 4.17.0 built a package that held the quickstart's `.env`, key included. With `.env` added to `.funcignore`, the package held neither file. The quickstart's `.funcignore` carries that line.

## Where are the Azure Functions quickstart and the API reference?

Start with the quickstart: it carries every file this page excerpts, in the order you write them.

- Quickstart

  **[Azure Functions quickstart](https://esigncomply.com/docs/quickstart/azure-functions)**

  Step by step, from install to your first sealed test record, with every file and the output of each step.

- Reference

  **[API reference](https://esigncomply.com/docs/api)**

  Every endpoint, field and error code. Sessions, records and documents are the three this page uses.

- Guide

  **[Server confirmation](https://esigncomply.com/docs/guides/server-confirmation)**

  The one place access is granted: what to compare, and the webhook that backs the check up.

Verifiable

## What does Esign Comply record for a signature on Azure Functions?

The same record on every stack and platform. Your Azure Functions code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on [Evidence and verification](https://esigncomply.com/product/evidence).

- **Observed and asserted fields**

  Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.

- **A signed receipt**

  `complete()` returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, and `GET /v1/records/{id}/receipt` returns it again.

- **An external timestamp**

  An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.

- **An offline verifier**

  Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source `esigncomply-verify`, without an account.

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Observed and asserted, in the docs](https://esigncomply.com/docs/concepts/observed-and-asserted) · [The offline verifier](https://esigncomply.com/docs/sdk/verify)

Record

`rec_Z4m8`

simple · L1

Recorded

Written durably, receipt signed with ES256

Timestamped

External RFC 3161 token over the record hash

Anchored

Public anchor pending

Checkbox changed by a trusted user event · observed

Terms of Service, version dv_3kT9 · observed

Server time 2026-11-21T15:03:20.291Z · observed

Signer email dana@example.org · asserted

record_hash sha256:5be7… · example record

## Questions about e-signatures on Azure Functions

### How does test mode work on Azure Functions slots and test apps?

A slot or a second function app answers on a host of its own under `azurewebsites.net`, which a test key refuses until you list that exact host under Domains as a test origin. Keep the test key in the settings of that app or slot. On `localhost`, under `func start`, a test key works with no setup.

### Where should the receipt be stored on Azure Functions?

In a table in Azure Table Storage, beside the signer ID and the record ID, or in the database your app already has. The confirm function writes both once the record is confirmed. Instances share no memory and an idle app can scale to zero, so a variable is no place for it.

### Why set routePrefix to an empty string in host.json?

Because every route starts with `/api` otherwise. Microsoft's documentation gives `api` as the default prefix. In the test without the setting, the host served the page at `/api/signup` and the session route at `/api/api/ceremony`. With an empty prefix the paths are `/signup`, `/legal/{slug}`, `/api/ceremony` and `/api/signup/confirm`.

### Why does a route work under func start and ask for a key on Azure?

Because Core Tools does not enforce function keys. Microsoft's documentation says local requests are handled as anonymous unless you pass `--enableAuth`. In the test a function-level route ran with no key under `func start` and answered `401` with that option. Set `authLevel` to `anonymous` on every route a browser calls.

### What ran under Core Tools, and what does only Azure prove?

The four functions ran under `func start` from Core Tools 4.17.0 with a table in the Azurite emulator, two hosts shared that table, and `func pack` built the deployment package. Nothing was deployed: publishing, application settings, Key Vault references, scaling, slots and custom domains are proven only on Azure.

### Other platforms

- [AWS Lambda](https://esigncomply.com/aws-lambda)
- [Netlify](https://esigncomply.com/netlify)
- [Cloudflare Workers](https://esigncomply.com/cloudflare-workers)

### Stacks used with Azure Functions

- [Node.js](https://esigncomply.com/nodejs)
- [Express](https://esigncomply.com/express)
- [Next.js](https://esigncomply.com/nextjs)

[All platforms](https://esigncomply.com/platforms) · [All stacks](https://esigncomply.com/stacks) · [Clickwrap API](https://esigncomply.com/clickwrap) · [E-signature API](https://esigncomply.com/sign)

## Run the signing flow in your function app. Leave the record to us.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/azure-functions)

Free plan: 10 live signatures a month and a full test mode. No card required.

Azure Functions is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Azure Functions is from Azure Functions's documentation or from a test run, as marked, on November 26, 2026. `/azure-functions.md` is this page as Markdown.

---

Every page on esigncomply.com has a Markdown version at the same URL plus `.md` (the home page is `https://esigncomply.com/index.md`). https://esigncomply.com/llms.txt lists them.

---

Esign Comply is the e-signature API and clickwrap API for developers who build their own signing flow in their own UI: it supplies the ceremony rules as a generated prompt for AI coding tools, records events in direct browser ceremonies, and seals independent, verifiable evidence.
