# Add e-signatures and clickwrap on Azure Functions

> Run a signup clickwrap on Azure Functions with the esigncomply package in Node.js functions, the key as an application setting, and Azure Table Storage.

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

Last updated November 26, 2026

To add e-signatures and clickwrap on Azure Functions, 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 as a record.

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

Paste this prompt into Cursor, Claude Code or another AI coding tool to have it build the same integration:

```text copy="Copy prompt" open="cursor"
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
```

The rest of this page is the same integration by hand, in eight steps. Steps 1 to 7 run on your machine with Azure Functions Core Tools and the Azurite emulator. Step 8 is the part that happens on Azure.

## Before you start

- A test API key. [Create an account](https://esigncomply.com/signup) with your email, no card, then choose **Create test key** in the dashboard. The key is shown once and starts with `esc_test_`. An AI agent with an agent token creates it with `POST /v1/agent/api-keys`: see the [agent account API](https://esigncomply.com/docs/api/agent.md).
- Nothing else from Esign Comply. Test mode works on `localhost` with no card and no domain, and the Free plan includes it in full.
- Node.js 20.19 or later, which the `esigncomply` package requires. Microsoft's guide names Node.js 24 for new apps on the v4 model. This page was run on Node.js 24.22.1.
- Docker, for the Azurite storage emulator.
- An Azure subscription and the Azure CLI, when you reach step 8. Steps 1 to 7 need neither, and no sign-in.
- `curl` and `jq` for steps 2, 3 and 4.

## Step 1. Install

Install the Functions library, the server package and the Table Storage client, and Azure Functions Core Tools as a development dependency of the project. The page loads the browser SDK from a script tag, so there is nothing to bundle.

```bash
mkdir esigncomply-quickstart && cd esigncomply-quickstart
npm init -y && npm pkg set type=module main="src/functions/*.js" scripts.start="func start"
npm install @azure/functions esigncomply @azure/data-tables
npm install --save-dev azure-functions-core-tools@4
mkdir -p src/functions public
```

`main` is how the v4 model finds your functions: here, every file under `src/functions`. `type=module` makes those files ES modules, which `esigncomply` is. Core Tools inside the project means `npx func` runs it with no global install: its install script downloads the Functions runtime, 1.3 GB in the test. `func init --worker-runtime javascript --model V4` writes the same starting project, as CommonJS.

## Step 2. Set the key

On your machine the key is in two files, and neither is ever committed. `.env` is for the shell commands on this page. `local.settings.json` is what Core Tools gives the functions: you write it in step 4 from the variables in your shell, so the key is typed once. On Azure the key is an application setting of the function app.

```bash
# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...
```

```bash
printf 'node_modules\nlocal.settings.json\n.env\n' > .gitignore
```

Load the file into your shell for the commands in steps 2, 3 and 7, then check that the key works:

```bash
set -a; . ./.env; set +a
curl -s ${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}/usage \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" | jq '{plan_name, test_events}'
```

```json
{
  "plan_name": "Free",
  "test_events": {
    "used_this_month": 0,
    "quota_per_month": 500
  }
}
```

A `401` means the key is wrong or revoked: see [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key). The rules for handling keys are in [/auth.md](https://esigncomply.com/auth.md).

## Step 3. Register a document version

Every record pins the exact version of each document by hash, so the documents are registered first. This block registers a Terms of Service and a Privacy Notice with one version each, and creates a profile: the Federal pack, a checkbox with a button, level L1. It is the same for every stack and needs `curl` and `jq`.

```bash
ESC=${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}
KEY="Authorization: Bearer $ESIGNCOMPLY_API_KEY"
JSON="Content-Type: application/json"

# Two sample documents, one version each.
TERMS=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Terms of Service","type":"terms"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$TERMS/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Terms of Service\n\nThese are sample terms for a test."},"material_change":true}' \
  | jq -r .id; sleep 1
PRIVACY=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Privacy Notice","type":"privacy_notice"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$PRIVACY/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Privacy Notice\n\nThis is a sample privacy notice for a test."}}' \
  | jq -r .id; sleep 1

# A profile: Federal pack, checkbox plus button, L1.
PROFILE=$(curl -s $ESC/profiles -H "$KEY" -H "$JSON" \
  -d '{"name":"Signup","jurisdictions":["US-FED"],"method":"checkbox","assurance_level":"L1"}' | jq -r .id)

printf 'ESIGNCOMPLY_PROFILE_ID=%s\nESIGNCOMPLY_TERMS_ID=%s\nESIGNCOMPLY_PRIVACY_ID=%s\n' "$PROFILE" "$TERMS" "$PRIVACY"
```

It prints the two version IDs, then three lines with your own IDs:

```text
dv_YiWs9cmWoVSGp7ALPeZS
dv_bAYeA7QigKUH0iLhPpV7
ESIGNCOMPLY_PROFILE_ID=prof_SPVEgBT8a8Ror3mJ8M99
ESIGNCOMPLY_TERMS_ID=doc_bDgYFndAoC8tkeYibAVy
ESIGNCOMPLY_PRIVACY_ID=doc_mb2hnWKS0Qa7SKtucDW9
```

Add the three lines to `.env`, then load the file into your shell again. The pauses keep the script under the Free plan's 2 requests per second. Keep the names `Terms of Service` and `Privacy Notice`: the notice on your page names each document by its registered name, and rule [CR-02](https://esigncomply.com/docs/conformance.md#cr-02) checks that it does. With your own documents, publish the text you already have and change the notice to match. See [Documents](https://esigncomply.com/docs/api/documents.md) and [Profiles](https://esigncomply.com/docs/api/profiles.md).

## Step 4. Create a session on the server

Start Azurite, Microsoft's storage emulator. It stands in for the storage account that holds the table:

```bash
docker run -d --name azurite -p 10000:10000 -p 10001:10001 -p 10002:10002 \
  mcr.microsoft.com/azure-storage/azurite
```

`host.json` configures the Functions host. This is the file `func init` writes, plus one setting, the route prefix:

```json file="host.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": ""
    }
  }
}
```

Microsoft's documentation says all function routes are prefixed with `api` by default, and that an empty string removes the prefix. Without that setting the host in the test listed the page at `/api/signup` and the session route at `/api/api/ceremony`, and `/signup` answered `404`. With an empty prefix, Microsoft reserves two paths at the root: no route may begin with `admin` or `runtime`.

One module holds everything that touches the table: the versions a session pinned, and later the record and its receipt.

```js file="src/store.js"
// src/store.js
import { TableClient } from "@azure/data-tables";

// 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");
}

export async function getPinned(signerId) {
  await ready;
  try {
    const entity = await table.getEntity("signer", signerId);
    return JSON.parse(entity.versionIds);
  } catch (error) {
    if (error.statusCode === 404) return [];
    throw error;
  }
}

export async function saveReceipt(signerId, recordId, receipt) {
  await ready;
  await table.updateEntity({ partitionKey: "signer", rowKey: signerId, recordId, receipt, confirmedAt: new Date() }, "Merge");
}
```

The state is in a table and not in a variable of the module, because Azure Functions scales a function app by adding instances of the host, and can scale it to zero after a few idle minutes. The request that confirms a record can reach an instance that never saw the session. `allowInsecureConnection` is set for Azurite only, which speaks plain HTTP: without it the client stopped with `Cannot connect to http://127.0.0.1:10002/devstoreaccount1/Tables while allowInsecureConnection is false`.

The four functions are in one file. `POST /api/ceremony` creates the session and returns three values to the browser: the client token, the API URL and the pinned documents.

```js file="src/functions/signup.js"
// src/functions/signup.js
import { app } from "@azure/functions";
import { readFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { EsignComply } from "esigncomply";
import { getPinned, savePinned, saveReceipt } from "../store.js";

// The secret key stays in the function app. The SDK reads the application setting ESIGNCOMPLY_API_KEY itself.
const esc = new EsignComply();

// The signer. In your app this is the signed-in user, or the account you are about to create.
const signer = {
  external_id: "user_7c1d",
  email: "dana@example.org",
  name: "Dana Whitfield",
  class: "consumer",
  country: "US",
  region: "US-CA",
};

const DOCUMENTS = {
  terms: process.env.ESIGNCOMPLY_TERMS_ID,
  privacy: process.env.ESIGNCOMPLY_PRIVACY_ID,
};
const SEALED = ["recorded", "timestamped", "anchored"];
// An application setting of the production function app only. The test app holds the test key and leaves it unset.
const LIVE = process.env.ESIGNCOMPLY_LIVE === "true";
const HTML = { "Content-Type": "text/html; charset=utf-8" };

// host.json sets routePrefix to "", so each route below is the whole path: /signup, not /api/signup.
// authLevel is anonymous on all four functions: a browser has no function key to send.
app.http("signup", {
  methods: ["GET"],
  authLevel: "anonymous",
  route: "signup",
  handler: async () => ({
    headers: HTML,
    body: await readFile(new URL("../../public/signup.html", import.meta.url), "utf8"),
  }),
});

// The document pages: each one renders a registered version, unmodified.
app.http("legal", {
  methods: ["GET"],
  authLevel: "anonymous",
  route: "legal/{slug}",
  handler: async (request) => {
    const documentId = DOCUMENTS[request.params.slug];
    if (!documentId) return { status: 404, jsonBody: { error: "not_found" } };
    const { data, error } = await esc.documents.versions.getContent(documentId, request.query.get("v") ?? "current");
    if (error) return { status: 404, jsonBody: { error: error.code } };
    return { headers: HTML, body: `<!doctype html><meta charset="utf-8"><article data-esc-document="${data.version_id}">${data.html}</article>` };
  },
});

// 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 } };
  },
});

// 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 } };
  },
});
```

The signer is a fixed test person here. In your app it is the signed-in user or the account you are about to create.

Every function sets `authLevel` to `anonymous`, because a browser has no function key to send. Core Tools hides the difference: Microsoft's documentation says authorization is not enforced locally. In a test with `authLevel: "function"` on the confirm function, `func start` let a request with no key through to the handler, and `func start --enableAuth` answered it `401`. Microsoft's documentation says the requirement is enforced when the app is hosted.

Write `local.settings.json` from the variables in your shell:

```bash
jq -n '{IsEncrypted: false, Values: {
  FUNCTIONS_WORKER_RUNTIME: "node",
  AzureWebJobsStorage: "UseDevelopmentStorage=true",
  TABLES_CONNECTION_STRING: "UseDevelopmentStorage=true",
  ESIGNCOMPLY_API_KEY: env.ESIGNCOMPLY_API_KEY,
  ESIGNCOMPLY_API_URL: (env.ESIGNCOMPLY_API_URL // ""),
  ESIGNCOMPLY_PROFILE_ID: env.ESIGNCOMPLY_PROFILE_ID,
  ESIGNCOMPLY_TERMS_ID: env.ESIGNCOMPLY_TERMS_ID,
  ESIGNCOMPLY_PRIVACY_ID: env.ESIGNCOMPLY_PRIVACY_ID
}}' > local.settings.json   # never commit this file
```

`UseDevelopmentStorage=true` is the shortcut for Azurite on its default ports: the Table Storage client turned it into `http://127.0.0.1:10002/devstoreaccount1`. A variable that is set in the shell wins over the file. In the test Core Tools said so in one line, `Skipping 'TABLES_CONNECTION_STRING' from local settings as it's already defined in current environment variables`, and the function got the shell's value.

Then start the Functions host:

```bash
npx func start
```

```text
Azure Functions Core Tools
Core Tools Version:       4.17.0+fec3d82b386c4e84ecb615cf165effabb3841859 (64-bit)
Function Runtime Version: 4.1055.300.26527

Functions:

	ceremony: [POST] http://localhost:7071/api/ceremony

	confirm: [POST] http://localhost:7071/api/signup/confirm

	legal: [GET] http://localhost:7071/legal/{slug}

	signup: [GET] http://localhost:7071/signup
```

## Step 5. Attach the ceremony in the browser

The browser SDK renders nothing. It observes the checkbox, the notice, the links and the button you built, and reports each step from the signer's browser straight to Esign Comply. Save the page as `public/signup.html`: the `signup` function sends it at `/signup`, so the page, the document pages and the two routes share one origin.

```html file="public/signup.html"
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Create account</title>
    <style>
      body { font: 16px/1.5 system-ui, sans-serif; max-width: 480px; margin: 48px auto; padding: 0 20px; }
      a { color: #0b57d0; text-decoration: underline; }
      button { font: inherit; padding: 10px 16px; }
    </style>
  </head>
  <body>
    <h1>Create account</h1>
    <form id="signup">
      <div id="assent">
        <!-- The page is on screen before the script has a session, so the box stays disabled until the SDK watches it. -->
        <label><input id="agree" type="checkbox" disabled /> I agree to the Terms of Service and Privacy Notice</label>
        <p>
          By checking the box and clicking Create account, you agree to the
          <a id="tos-link" href="/legal/terms">Terms of Service</a> and acknowledge the
          <a id="privacy-link" href="/legal/privacy">Privacy Notice</a>.
        </p>
        <button id="create-account" type="submit" disabled>Create account</button>
      </div>
      <p id="message" role="alert"></p>
    </form>

    <script src="https://esigncomply.com/sdk/v1/esigncomply.js"></script>
    <script type="module">
      const agree = document.querySelector("#agree");
      const submit = document.querySelector("#create-account");
      const message = document.querySelector("#message");

      // Your server creates the session and returns only the client token and the pinned documents.
      const response = await fetch("/api/ceremony", { method: "POST" });
      const { clientToken, apiUrl, documents } = await response.json();

      const ceremony = await EsignComply.attach({ clientToken, apiUrl });
      ceremony.on("change", ({ remainingSteps }) => {
        submit.disabled = remainingSteps.some((step) => step !== "signature.applied");
      });

      // Point each link at the exact version this session pinned, then report it.
      const links = [document.querySelector("#tos-link"), document.querySelector("#privacy-link")];
      for (const [i, link] of links.entries()) {
        link.search = "?v=" + documents[i].version_id;
        await ceremony.presentDocument({ versionId: documents[i].version_id, mode: "hyperlink", link });
      }
      await ceremony.observeAssent({
        region: document.querySelector("#assent"), // notice, links, checkbox, button
        checkbox: agree,
        submit,
      });
      agree.disabled = false; // the SDK watches the box from here on. Only the user ticks it.

      document.querySelector("#signup").addEventListener("submit", async (event) => {
        event.preventDefault();
        try {
          const result = await ceremony.complete(); // the signing act, from the signer's own click
          // The result came to the browser. Your server confirms the record before anything is granted.
          const confirmed = await fetch("/api/signup/confirm", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ recordId: result.recordId }),
          });
          message.textContent = confirmed.ok
            ? `Account created. Record ${result.recordId}`
            : "We could not confirm whether your acceptance was recorded. Please wait while we check.";
        } catch (error) {
          message.textContent = error.message;
        }
      });
    </script>
  </body>
</html>
```

Open [http://localhost:7071/signup](http://localhost:7071/signup). The checkbox starts unchecked and disabled: the page is on screen before the script has a session, and the script enables the box once the SDK observes it. The button stays disabled until the box is ticked. Tick it, click **Create account**, and the page shows:

```text
Account created. Record rec_b1bsmdd08GrLMo2AdgTY
```

One page load sent one `POST /api/ceremony`.

## Step 6. Confirm the record on the server

The result of `complete()` was delivered to the browser, so your function does not trust it. `POST /api/signup/confirm` reads the record with the secret key and the pinned versions from the table, and grants access only when four things hold: the status is `recorded`, `timestamped` or `anchored`; `livemode` is what this function app expects; the signer is the one the session was created for; and the document versions are exactly the ones it pinned. This step is never optional.

`ESIGNCOMPLY_LIVE` is an application setting you set to `true` on the production function app only, the one that holds the live key. Everywhere else it is not set, so test records are accepted and live records are not.

The function logs one line for each confirmation, and the entity then holds the record ID and the receipt:

```text
[2026-11-26T16:51:55.029Z] confirmed rec_b1bsmdd08GrLMo2AdgTY (recorded)
```

A record ID that was made up is refused with status `409`:

```bash
curl -s -X POST http://localhost:7071/api/signup/confirm \
  -H "Content-Type: application/json" -d '{"recordId":"rec_made_up"}'
```

```json
{"confirmed":false}
```

In the test, two Functions hosts ran side by side on the same table. The session was created on the first and the record was confirmed on the second: the pinned versions came from the table. A host started with `ESIGNCOMPLY_LIVE=true` refused a test record with `409`. With the table out of reach the session function answered `500`, the host logged the failed invocation, and the other routes kept answering.

See [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md) for the webhook that backs this route up when the browser closes early.

## Step 7. Check the result

Open the dashboard and choose **Records**. The test record is there with what was observed, what was asserted, and its evidence report, watermarked TEST.

Then run the conformance check against the page. It opens the page in headless Chromium at three window sizes, signs as a visitor would, and tries four things that must be refused. One of them posts a made-up record ID to your confirm route.

```bash
npm install --save-dev playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:7071/signup --callback http://localhost:7071/api/signup/confirm
```

The report for this page's code under `func start`, shortened:

```text
Violations that must be refused
  REFUSED   Submit with the checkbox untouched      No record was made.
  REFUSED   Completion from another origin          The API answered 403 domain_mismatch.
  REFUSED   Programmatic click                      No record was made.
  REFUSED   Forged success posted to your callback  http://localhost:7071/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_9s271WiwnA7w5NcbEJpx  session ses_mmAN0cae9YXgfFCijZ0r, 5 events
  768x1024   record rec_vUPnND2aiPnDhNJD0QKg  session ses_d4DgYdCGQosmYsXLf1Cd, 5 events
  1440x900   record rec_TW8cKiyRTD1P4L8Ykn0a  session ses_pdKvejQPu5rrSRTZBvkS, 5 events

Summary: 0 block, 0 warn, 27 pass.
```

The host logged a `confirmed` line for each of the three records.

Fix every finding marked `block` and read every finding marked `warn`. Each one names the rule the screen missed, the measurement and the fix. In test mode a finding never stops a record from being sealed, so read the report. The rules are on [Conformance rules](https://esigncomply.com/docs/conformance.md), and every flag of the command is on the [CLI page](https://esigncomply.com/docs/sdk/cli.md).

## Step 8. Go live

Going live takes three steps on the Esign Comply side. There is no plan to choose and no checkout: the Free plan records 10 live signatures a month.

1. Register your production domain and verify it. See [Register a domain](https://esigncomply.com/docs/guides/domains.md).
2. Add your organization's legal name, country and address under **Go live** in the dashboard.
3. Create a live key. It is shown once and starts with `esc_live_`.

Test and live share nothing, so create the documents and the profile again with the live key, or copy them to live from the dashboard, and use the live IDs in production.

Then set up the function app. The settings below are from Microsoft's own documentation, read on November 26, 2026: the [Node.js developer guide](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node), the [HTTP trigger](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger) and its [host.json settings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook), [Develop locally with Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local), [Code and test locally](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local), [Configure function app settings](https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings), [Key Vault references](https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references), [Event-driven scaling](https://learn.microsoft.com/en-us/azure/azure-functions/event-driven-scaling), [Hosting options](https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale), [Deployment slots](https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-slots), [Custom domains in App Service](https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain) and [Azurite](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite). The `az` and `func azure` commands in this step need a sign-in and were not run for this page.

**The deployment package.** `func azure functionapp publish <FunctionAppName>` publishes the project folder as a zip package, and `.funcignore` names what stays out of it. This is the file `func init` writes, plus one line, `.env`:

```text file=".funcignore"
*.js.map
*.ts
.git*
.vscode
local.settings.json
.env
test
getting_started.md
node_modules/@types/
node_modules/azure-functions-core-tools/
node_modules/typescript/
```

That line matters. `func pack` builds the same kind of package with no sign-in. With the file as `func init` wrote it, the package in the test held `.env`, key included. It did not hold `local.settings.json` or Core Tools, which the file already named. With `.env` added, the package held neither.

**The key.** Local settings are not published. Set the key as an application setting of the function app, in the portal under **Environment variables** or with the Azure CLI:

```bash
az functionapp config appsettings set --name <FUNCTION_APP_NAME> \
  --resource-group <RESOURCE_GROUP_NAME> \
  --settings ESIGNCOMPLY_API_KEY=esc_live_us_... ESIGNCOMPLY_LIVE=true
```

Microsoft's documentation says application settings are stored encrypted, are read in code as environment variables, and that changing one restarts the function app. Set the profile and document IDs the same way, and `TABLES_CONNECTION_STRING` to the connection string of the storage account that holds the table. `AzureWebJobsStorage` is the host's own storage account in Azure: Microsoft says never to publish it as `UseDevelopmentStorage=true`.

**Key Vault.** The setting can hold a Key Vault reference instead of the key: `@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret)`. The function app needs a managed identity that may read the secret, and the code does not change. Microsoft's documentation says that when a reference is not resolved, the reference string is used instead. In a test with that string as the key, the session route answered `502` with [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key).

**Instances.** Azure Functions scales a function app out by adding instances of the host, and Microsoft's documentation says an app that stays idle for a few minutes can be scaled to zero. Nothing in the memory of one instance reaches another, which is why step 4 keeps the pinned versions in a table.

**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 deployment slots are not supported on the Flex Consumption plan, which it recommends for new apps, so there the test environment is a second function app. On a plan with slots, each slot has its own host name, and a setting marked as a deployment slot setting stays with its slot in a swap: mark every `ESIGNCOMPLY_` setting that way, so a swap never carries the test key into production. A test key refuses a host it does not know with [`domain_mismatch`](https://esigncomply.com/docs/api/errors.md#domain_mismatch). List the exact host of the test app or the slot under Domains in the dashboard, or with the API:

```bash
curl -X PATCH https://esigncomply.com/v1/domains/dom_4Kx9 \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" -H "Content-Type: application/json" \
  -d '{ "test_origins": ["example-test.azurewebsites.net"] }'
```

List exact hosts, up to 25. An entry also covers its subdomains, so never list the shared suffix `azurewebsites.net`.

**The production domain.** Go live on a domain you own. You cannot add a DNS record under `azurewebsites.net`, and the file method is offered only for a fixed list of platform suffixes that does not include it. Map your domain to the function app as App Service documents, with a CNAME record and the `asuid` TXT record that proves ownership to Azure, then register the domain with Esign Comply and verify it with one DNS record. See [Register a domain](https://esigncomply.com/docs/guides/domains.md).

In live mode `context.url` must be inside your registered domain, and browser calls are accepted only from it. By default a live signature with a finding at Block level is recorded and you are told at once which rule failed. Turn on blocking, on the dashboard's Conformance page, and it is refused before it is sealed. Run the check from step 7 until no finding is at Block level before you switch keys.

## Troubleshooting

- **`/signup` answers `404`.** `host.json` has no `routePrefix`, or the host has not read the file. With the default prefix the test host served the page at `/api/signup` and the session route at `/api/api/ceremony`. Set `extensions.http.routePrefix` to an empty string and read the list of addresses `func start` prints.
- **`invalid_api_key` from `/api/ceremony` on Azure.** The key setting is a Key Vault reference that did not resolve, so the function sent the reference string as the key. In a test with that string the route answered `502` with this code. Give the function app's identity read access to the secret and check the reference's status in the portal. See [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key).
- **`domain_mismatch` on an `azurewebsites.net` host.** The host of the test app or the slot is not a test origin of your domain. Add the exact host under Domains in the dashboard. Test keys work on `localhost` with no setup. See [`domain_mismatch`](https://esigncomply.com/docs/api/errors.md#domain_mismatch) and [Test mode](https://esigncomply.com/docs/guides/test-mode.md).
- **`429` when the confirm function reads the record.** The function needs no retry loop: the `esigncomply` package waits for the time in `Retry-After` and tries again, up to twice, inside the invocation. In the test, four confirmations sent at once for one record all answered `200`, two of them a second later than the others. Four reads sent at once through the package showed why: two got `429` with `Retry-After: 1` and passed on the next attempt. See [`rate_limit_exceeded`](https://esigncomply.com/docs/api/errors.md#rate_limit_exceeded) and [Retries and timeouts](https://esigncomply.com/docs/sdk/node.md#retries-and-timeouts).

## Questions about the Azure Functions quickstart

### Why Table Storage and not a variable in the module?

Because instances share no memory. Azure Functions adds instances of the host as load grows and can scale an idle app to zero, so the confirmation can reach an instance that never saw the session. In the test, a second Functions host confirmed a record from the entity the first one wrote.

### Why is routePrefix an empty string?

So the page is at /signup and the document pages are at /legal. Microsoft's documentation says every function route is prefixed with api by default. In the test without the setting, the host served the page at /api/signup and the session route at /api/api/ceremony.

### Does the function app have to be an ES module project?

Not on Node.js 24. The quickstart sets "type": "module" because `esigncomply` is an ES module. In a test on Node.js 24.22.1, the CommonJS project that `func init` writes also loaded the package with `require`. Microsoft's guide describes ES modules as a preview feature of the Node.js worker.

### Does func start need an Azure account?

No. Core Tools 4.17.0, installed from npm into the project, started the host with no sign-in, and the conformance check ran against it. `func pack` needed none either. Publishing does: Microsoft's documentation says Core Tools uses the Azure CLI or Azure PowerShell to authenticate.

### Was this quickstart deployed to Azure?

Not yet. The functions ran under Core Tools with a table in Azurite, two hosts shared that table, and `func pack` built the package. Publishing, application settings, Key Vault references, scaling, slots, the storage account and a custom domain on Azure are proven only by a deployment.

## Next steps

- [E-signatures and clickwrap on Azure Functions](https://esigncomply.com/azure-functions): how the pieces fit on this platform, with the things to watch for.
- [Register a domain](https://esigncomply.com/docs/guides/domains.md): DNS verification, statuses, and test origins.
- [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md): the checks in step 6 and the `record.completed` webhook.
- [Add e-signatures and clickwrap with Node.js](https://esigncomply.com/docs/quickstart/nodejs.md): the same package on a server you run yourself.
- [All quickstarts](https://esigncomply.com/docs/quickstart.md#quickstarts-by-stack-and-platform).
