Skip to content

Commit fdb20cb

Browse files
SciencePotatoHou Chi ChanCopilot
authored
docs: simplify the customer setup walkthrough (#41)
Co-authored-by: Hou Chi Chan <houchichan@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 48b94a3 commit fdb20cb

20 files changed

Lines changed: 409 additions & 321 deletions

‎README.md‎

Lines changed: 188 additions & 248 deletions
Large diffs are not rendered by default.

‎TECHNICAL.md‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,29 @@ Azure Front Door is an [optional manual multi-region design](docs/FRONTDOOR.md),
77
enabled by the single-region setup script. Its additional readiness endpoint is not shipped in
88
the release packages, and regional failover does not change the SendOtp contract.
99

10-
A provider-agnostic **OTP-delivery Azure Function** sample, implemented across multiple languages.
11-
Each language folder is a self-contained implementation of the **same design and the same
12-
[contract](docs/CONTRACT.md)**: one engine, drop-in provider adapters, env-provisioned config, and
13-
secrets in Key Vault.
10+
Use this reference when developing or customizing the endpoint. Each language folder implements
11+
the same [HTTP contract](docs/CONTRACT.md), with provider-specific adapters, environment settings,
12+
and managed-identity access to credentials.
13+
14+
## Single-region architecture
15+
16+
![Single-region External Phone Provider architecture](docs/images/single-region-architecture.png)
17+
18+
Microsoft Entra ID sends an authenticated, encrypted request. Easy Auth checks the caller,
19+
then the Function decrypts the request using its Key Vault-backed key. For a live request, the
20+
selected adapter submits the message and returns success after provider acceptance, not after
21+
confirmed recipient delivery. Application Insights collects the available request and log telemetry.
22+
23+
The diagram is an overview, not a portal screenshot. East US is illustrative; select a region
24+
with capacity and quota for your hosting plan. The provider-secret path applies to API-key
25+
integrations; OAuth integrations use managed-identity token exchange instead. Credential caching
26+
depends on the [selected cache settings](docs/CONTRACT.md#credential-caching-and-refresh), and
27+
[log formats vary by runtime](docs/MONITORING.md#runtime-specific-log-discovery).
28+
29+
An authorized, valid encrypted **evaluation request (`mode: 2`)** returns the matching nonce
30+
without submitting a message to the provider. When caching is enabled, credential preparation
31+
can run independently; it never sends an OTP. Authentication failures can return **401 or 403**,
32+
neither of which is a successful evaluation.
1433

1534
## Implementations
1635

‎docs/APPLICATION-INSIGHTS.md‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
# Application Insights for the External Phone Provider
22

3-
Application Insights is the application-performance feature of Azure Monitor. It helps explain
4-
which Function invocations ran, how long they took, and what the application reported while
5-
processing them. It is not a delivery receipt service, an audit ledger, or a replacement for
6-
Azure resource health and platform metrics.
7-
8-
This guide covers telemetry collection and interpretation for the repository's **JavaScript,
9-
.NET isolated, and Python** implementations, in one region or multiple regions. It does not
10-
deploy resources, enable additional instrumentation, or configure alert rules, action groups,
11-
or availability tests. Use the [setup guide](../setup/docs/README.md) for deployment.
12-
Azure Front Door is optional; the Function telemetry described here also applies without it.
13-
14-
**First-time operator:** locate `resources.applicationInsights` and `resources.logAnalytics` in
15-
the [saved deployment summary](../setup/docs/README.md#read-the-deployment-summary). Verify collection
16-
here, then follow the [runtime-specific queries](MONITORING.md#runtime-specific-log-discovery)
17-
and [alert setup](MONITORING.md#5-set-up-notifications-and-alert-rules). Authorized evaluation/live
18-
testing must use the [customer test handoff](ONBOARDING.md#validate-the-deployed-endpoint);
19-
deployment does not provide a customer token for the Microsoft caller.
3+
Application Insights helps you see which requests ran, how long they took, and what the Function
4+
reported along the way. It does **not** confirm that an SMS or voice call reached the recipient.
5+
6+
**Looking for your logs?** Start with the [monitoring guide](MONITORING.md). It shows how to find
7+
the resources from your deployment summary, run queries, and create alerts.
8+
9+
This reference explains how collection works for **JavaScript, .NET isolated, and Python**,
10+
what each signal means, and why data may be missing. Start with
11+
[single-region configuration](#single-region-configuration) to check a guided deployment;
12+
use the remaining sections for runtime differences or a multi-region design.
13+
You do not need Azure Front Door for Function telemetry.
14+
15+
These instructions do not deploy resources or enable extra instrumentation, alerts, or availability
16+
tests. Use the [setup guide](../setup/docs/README.md) for deployment and the
17+
[approved test handoff](ONBOARDING.md#validate-the-deployed-endpoint) to generate test traffic.
2018

2119
## How telemetry reaches Application Insights
2220

‎docs/MONITORING.md‎

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
# Monitoring setup and sample queries
22

3-
Use this guide to operate a **single-region Azure Function** or **multiple regional
4-
Functions**. Azure Front Door is optional; it adds an edge monitoring layer and does
5-
not replace Function, credential, or provider monitoring.
3+
Use this guide to find your endpoint's logs and set up alerts. Guided setup creates Application
4+
Insights and a Log Analytics workspace, but **you still need to configure and test notifications**.
65

7-
These are operator-run examples, not an automatic deployment of monitors. Review
8-
permissions, privacy, charges, and alert routing before creating anything. All
9-
thresholds and intervals below are **starting points, not SLAs**. This guide does not
10-
change deployed diagnostics, sampling, retention, or alert settings.
6+
For your first single-region deployment:
117

12-
For the first deployment, finish the [customer acceptance checks](ONBOARDING.md#validate-the-deployed-endpoint)
13-
with the authorized test operator. Read [Application Insights](APPLICATION-INSIGHTS.md) for
14-
collection/identity details, then use this guide to establish queries and alerts. You do not
15-
need Front Door, a Workbook, or a new exporter merely to locate your existing single-region logs.
8+
1. [Find the monitoring resources and confirm data is arriving](#1-record-the-deployment-and-confirm-telemetry)
9+
after an [authorized test](ONBOARDING.md#validate-the-deployed-endpoint).
10+
2. Check [requests, failures, and latency](#2-single-region-function-queries), then use
11+
[the log format for your runtime](#runtime-specific-log-discovery).
12+
3. [Set up and test alerts](#5-set-up-notifications-and-alert-rules), including certificate
13+
reminders and cost ownership.
14+
15+
The multi-region queries, shared Workbook, and Front Door sections are optional.
16+
You do not need them to find single-region logs. For collection and identity details, see
17+
[Application Insights](APPLICATION-INSIGHTS.md).
18+
19+
These examples do not create monitors automatically. Review permissions, privacy, and charges
20+
before applying them. Thresholds and intervals are **starting points, not SLAs**; tune them to
21+
your deployment.
1622

1723
## 1. Record the deployment and confirm telemetry
1824

@@ -37,6 +43,23 @@ methods can differ. The current setup template requests 30-day retention; confir
3743
effective workspace/table retention and organizational policy before changing it.
3844
It does not create the action groups, Workbooks, or alert rules described here.
3945

46+
### Find the linked resources in the portal
47+
48+
1. Open the Function App named in your deployment summary.
49+
2. Select **Monitoring > Application Insights**. Follow the linked resource name; do not
50+
select **Change your resource** or **Apply** just to view your logs.
51+
52+
![Function App Monitoring menu with Application Insights selected and its connected resource link](images/onboarding/monitoring-link.png)
53+
54+
3. On that Application Insights resource's **Overview**, find **Logs workspace** and open
55+
the linked workspace. Then select **Logs** in the workspace to use the queries below.
56+
57+
![Application Insights Overview showing the Logs workspace link with account and connection details redacted](images/onboarding/monitoring-workspace.png)
58+
59+
These are real portal views of an existing test deployment, with identifying information and
60+
connection details permanently hidden. Resource names, regions, and portal layouts may differ.
61+
The links show where to navigate; they do not prove that test traffic or delivery succeeded.
62+
4063
In the Azure portal, inspect each Function's Application Insights association,
4164
monitoring settings, managed-identity ingestion authorization, and diagnostic
4265
destinations. Do not expose connection strings or credential values. Application
@@ -69,6 +92,35 @@ necessary resource/workspace access; saving a Workbook does not grant its reader
6992
access to its data. Cross-workspace alert evaluation also needs access to each
7093
workspace under the rule's configured identity.
7194

95+
### Run a first query and read the results
96+
97+
1. In your workspace's **Logs**, close any welcome or Queries hub dialog. If the portal opens
98+
in **Agent** mode, switch it off for this walkthrough, then choose **KQL mode**.
99+
2. Paste the query below. Replace `<function-role-name>` with the `AppRoleName` you verified
100+
using the discovery query above. If a workspace contains multiple Application Insights
101+
components with that same role name, also filter by your component's `_ResourceId`.
102+
3. Select **Run**, then read the **Results** grid. Adjust `ago(48h)` to include the time of
103+
your authorized test; this query sets its own time range.
104+
105+
```kusto
106+
AppRequests
107+
| where TimeGenerated >= ago(48h)
108+
| where AppRoleName == "<function-role-name>" and Name == "SendOtp"
109+
| summarize StoredRows = count() by ResultCode, Success
110+
| order by ResultCode asc
111+
```
112+
113+
![Workspace Logs in KQL mode with a scoped request-status query, Run button, and one aggregate result row](images/onboarding/logs-query-results.png)
114+
115+
*This real query returned 11 stored rows with result code 200 and `Success=true` in the example
116+
window. The role and workspace names are hidden. The query shows counts only: no phone numbers,
117+
message bodies, credentials, or raw trace messages. Your result counts will differ.*
118+
119+
`StoredRows` counts stored telemetry records, not delivered messages or necessarily all requests.
120+
Sampling can change the count, and evaluation and live calls can both return HTTP 200. No rows
121+
means no matching records in the selected scope/time range; it is not proof that nothing failed.
122+
Use the scoped and sampling-aware queries below for ongoing monitoring.
123+
72124
## 2. Single-region Function queries
73125

74126
### Requests, failures, and latency

‎docs/MULTI-PROVIDER-IMPLEMENTATION.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The sample still ships with one provider per deployment and **no provider fallba
1010
describes customer code you must implement and review. A timeout, lost response or generic
1111
provider error is not proof of nonacceptance: in those cases, do not automatically send again.
1212

13+
For a normal deployment, follow the [main setup guide](../README.md) instead. This is an advanced
14+
developer walkthrough: it requires custom code, durable operation state, provider-specific
15+
approval, and separate testing. It is not another step in guided onboarding.
16+
1317
## 1. Set a fixed provider order and a deny-by-default policy
1418

1519
Keep the existing HTTP registration in [SendOtp.js](../javascript/src/functions/SendOtp.js).
@@ -103,8 +107,8 @@ see [provider onboarding](ONBOARDING.md#complete-provider-authentication).
103107

104108
## 3. Give each context its own credential service and lifecycle
105109

106-
Open [credentials.js](../javascript/src/functions/credentials.js). Its singleton caches the
107-
first selected configuration; passing another account to it does not switch its cache.
110+
Open [credentials.js](../javascript/src/functions/credentials.js). When caching is enabled, its
111+
singleton retains the first selected configuration; passing another account does not switch that cache.
108112
Create a long-lived service for each account instead, with an immutable configuration:
109113

110114
```javascript
@@ -145,8 +149,12 @@ app.hook.appTerminate(stopProviderCredentialRefresh);
145149
module.exports = { stopProviderCredentialRefresh };
146150
```
147151

148-
Remove the singleton import only after replacing its request/lifecycle uses. Each service begins
149-
periodic refresh when first used. An evaluation request must not start credential acquisition;
152+
Remove the singleton import only after replacing its request/lifecycle uses. With its selected
153+
cache enabled, each service begins periodic refresh when first used. With caching disabled,
154+
each live attempt acquires credentials without a poller or cross-request reuse. Preserve
155+
the [cache switches](CONTRACT.md#credential-caching-and-refresh) in each account's configuration;
156+
setup sets them to `false` for FC1 and `true` for EP1, while omitted values default to `true`.
157+
An evaluation request must not start credential acquisition;
150158
already-running refresh is independent. Rebuild contexts on controlled restart when configuration
151159
changes; never repurpose a live service for another account.
152160

‎docs/ONBOARDING.md‎

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Customer configuration and validation
22

3-
Start with the [root onboarding checklist](../README.md). This is the detailed customer runbook
4-
for values, provider access, and acceptance checks; [the setup guide](../setup/docs/README.md)
5-
covers workstation preparation and the deployment command.
3+
Start with the [five-step setup guide](../README.md). Come here when you need exact IDs,
4+
provider credential names, or the checks to complete before activation.
65

7-
**The normal path is: confirm access, register an app, run setup once, complete provider
8-
authentication, validate, then activate policy.** Setup already builds/publishes the Function and
9-
configures its Azure settings. Local settings, Core Tools, and a second manual deployment are
10-
**not** required. [Optional developer work](#optional-local-development-and-manual-deployment)
11-
is separate.
6+
**After successful guided setup, go straight to [provider authentication](#complete-provider-authentication),
7+
then [validate the endpoint](#validate-the-deployed-endpoint).** The script has already published
8+
the code and configured Azure. You do not need local settings, Core Tools, or a second deployment.
9+
10+
For earlier steps, use [access requirements](#before-purchasing-or-deploying),
11+
the [values worksheet](#values-and-ownership), or the [setup reference](../setup/docs/README.md).
12+
[Local development and manual deployment](#optional-local-development-and-manual-deployment)
13+
are separate, optional paths.
1214

1315
## Before purchasing or deploying
1416

@@ -18,6 +20,12 @@ channel, pricing, and access to the provider's **EPP integration**, not just its
1820
An offer purchase does not deploy Azure resources, enable a Microsoft tenant feature, or install
1921
a missing adapter.
2022

23+
![Cropped examples of phone-provider offer cards in Microsoft Security Store](images/onboarding/security-store-providers.png)
24+
25+
*These are sample cards, not recommendations or a complete provider list. Offers, preview
26+
labels, pricing, and access can change. A store listing does not mean the setup script supports
27+
that integration; check [guided provider support](#provider-credential-names).*
28+
2129
Have your tenant administrator confirm the supported EPP onboarding/activation procedure with
2230
Microsoft and the provider **before incurring deployment costs**. This repository does not define
2331
tenant eligibility, licensing, preview enrollment, or a self-service activation entitlement.
@@ -118,6 +126,39 @@ developer integrations, not additional guided provider offers:
118126
| `infobip` | `infobip-api-key`; `Authorization: App ...` | Adapter only; no guided profile. Validate its account/options separately. |
119127
| `sinch` | `sinch-api-token`; static token | Adapter only; no guided profile. Validate its account/options separately. |
120128

129+
### Where to enter API-key credentials in Key Vault
130+
131+
Use the vault created for **your endpoint**, not a vault chosen from a screenshot:
132+
133+
1. Open the saved deployment summary and find `resources.keyVault`.
134+
2. In **Azure portal > Key vaults**, open that vault.
135+
3. Select **Objects > Secrets**. This list shows secret names and status, not their values.
136+
Select **Generate/Import** to enter a credential.
137+
138+
![Key Vault Objects menu with Secrets selected and the Generate/Import action visible](images/onboarding/key-vault-secrets.png)
139+
140+
*This existing test vault contains examples for more than one adapter. Create only the secrets
141+
required by your chosen integration in the table above. The screenshot does not mean guided
142+
setup configures multiple providers or supports every adapter.*
143+
144+
4. Choose **Manual**. For **Name**, use the exact name in the provider table above.
145+
For **Secret value**, paste the credential obtained through your provider's secure process.
146+
Leave **Enabled** set to **Yes** and set activation/expiry dates to match your provider agreement.
147+
5. Select **Create** only after checking the vault, name, and value. Repeat for any additional
148+
required credential, such as an account/customer ID.
149+
150+
![Unsaved Create a secret form showing a sample name, masked placeholder value, and Enabled set to Yes](images/onboarding/key-vault-create-secret.png)
151+
152+
*The screenshot uses `example-provider-api-key` and a fake masked value to show the form.
153+
Neither is a working configuration. The form was cancelled without saving. Use the exact
154+
provider-specific secret names, not this example name, and never reveal a real key for a screenshot.*
155+
156+
After saving, verify the name, enabled state, and version metadata without selecting
157+
**Show Secret Value**. Do not edit or replace the setup-created encryption certificate secret.
158+
If the vault denies access, ask the approved credential administrator for help; do not disable
159+
vault protection or copy credentials into Function settings. See the permission and runtime
160+
checks in the provider-specific steps below.
161+
121162
### Telesign: enter and verify the two vault secrets
122163

123164
1. Obtain the raw API key and matching Customer ID from your Telesign account's approved secure
@@ -137,8 +178,9 @@ developer integrations, not additional guided provider offers:
137178
the encryption certificate secret, grant broad access, or put credentials into Function
138179
settings to bypass a vault failure.
139180
5. Follow the authorized evaluation and controlled live checks below. Evaluation cannot validate
140-
these secrets. Workers cache credentials; use the [runtime cache behavior](CONTRACT.md#credential-caching-and-refresh)
141-
to plan first-use/rotation checks. Absence of a warning does not prove account authorization.
181+
these secrets. Credential caching depends on your settings: setup disables it for FC1 and
182+
enables it for EP1. Use the [runtime cache behavior](CONTRACT.md#credential-caching-and-refresh)
183+
to plan first-use and rotation checks. Absence of a warning does not prove account authorization.
142184

143185
Use portal secret entry rather than command-line literal values, transcripts, source files,
144186
screenshots, or chat. During rotation, coordinate the matching pair and provider validity window;
37.8 KB
Loading
38.3 KB
Loading
78.7 KB
Loading
25.5 KB
Loading

0 commit comments

Comments
 (0)