Skip to content

Add Foundry vector search options to ARM template - #6098

Draft
Brendan Kowitz (brendankowitz) wants to merge 4 commits into
mainfrom
personal/bkowitz/foundry-vector-search-deploy
Draft

Brendan Kowitz (brendankowitz) wants to merge 4 commits into
mainfrom
personal/bkowitz/foundry-vector-search-deploy

Conversation

@brendankowitz

Copy link
Copy Markdown
Member

Description

Follow-up to the merged SQL semantic (vector) search feature. Makes it deployable from the sample ARM template with a new or existing Azure Foundry account, and adds a sample SearchParameter for Composition narrative text.

samples/templates/default-azuredeploy-docker.json

  • New vectorSearchFoundryNewOrExisting parameter: none (default, no change to existing deployments) | new | existing, plus account location/name, network, and embedding model/deployment parameters.
  • new: creates an AIServices (S0) account with local auth disabled (Entra ID only) and an embedding deployment with NoAutoUpgrade (model version is stored with every vector). By default the account firewall denies all traffic except the web app's possibleOutboundIpAddresses plus optional foundryAdditionalAllowedIpAddresses; foundryRestrictNetworkAccess=false opens it to public networks.
  • existing: does not modify the account (an ARM PUT would overwrite its configuration); only assigns the role and reads endpoint/model from the existing deployment.
  • Both: assigns Cognitive Services OpenAI User to the web app's system-assigned identity and sets FhirServer__CoreFeatures__VectorSearch__* app settings (endpoint, deployment, model name/version, SendDimensionsParameter only for text-embedding-3-large). Foundry can be in another resource group/subscription via a nested deployment.
  • Applies only to FhirServerSqlServer; ignored for Cosmos DB. When disabled, reference() calls are inside if() and never evaluated.

samples/search-parameters/composition-narrative-semantic.json — semantic SearchParameter (narrative-semantic) over Composition.text and all nested section.text narratives, stripping XHTML tags and decoding basic entities, with perValueRow so each narrative block is embedded separately.

  • Note: div is a FHIRPath keyword and must be written as text.`div` (as in the FHIR dom-6 invariant). Firely tolerates the unescaped form; Ignixa correctly rejects it, and the indexer logs a warning and indexes nothing. Documented in SemanticSearch.md.

Docs — docs/SemanticSearch.md: "Deploying with the sample template" and "Example: Composition narrative" sections; pointer from docs/DefaultDeployment.md.

Affected layers: deployment samples and docs only. No code, schema, or FHIR-version-specific changes.

Related issues

Addresses [issue #].

Testing

Acceptance criterion Implemented in Evidence and result
Template deploys unchanged by default vectorSearchFoundryNewOrExisting default none; Foundry resources and settings conditional Offline: template parses as JSON (after stripping existing // comments); a script checked every parameters()/variables() reference resolves in its scope (outer and nested inner) and brackets balance — passed. PR ARM validation (build/pr-arm.yml, -serviceName only) — pending CI.
New Foundry account accepts only the web app's IPs by default Nested deployment networkAcls with ipRules copy from possibleOutboundIpAddresses Static review (self + reviewer agent) — no issues found. Not deployed to Azure; no what-if run.
Existing account is used without modification Nested deployment creates only the role assignment when existing Static review only. Not deployed.
Web app can call Foundry with its managed identity Role assignment + VectorSearch__Embedding__* app settings Static review against AzureFoundryEmbeddingClient (AzureOpenAIClient + DefaultAzureCredential). Not deployed.
Sample SearchParameter extracts Composition narrative text on both FHIRPath providers composition-narrative-semantic.json Throwaway xUnit test (not committed) loading the sample file, run with dotnet test --project src\Microsoft.Health.Fhir.R4.Core.UnitTests\... --filter-class SpikeNarrativeTests — passed: Firely and Ignixa both returned the same 3 decoded narrative strings; vector config parsed as perValueRow/8000/cosine.

Not verified: an actual Azure deployment for new/existing, cross-subscription Foundry, or end-to-end $reindex + semantic query. az bicep decompile fails on this template both before and after the change, so it was not usable as a validator.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Skip

…narrative sample

- default-azuredeploy-docker.json: optional new/existing Azure Foundry account for SQL
  semantic search. A new account is Entra-only and, by default, accepts traffic only from
  the web app's outbound IPs. Assigns Cognitive Services OpenAI User to the web app's
  managed identity and sets the VectorSearch app settings.
- samples/search-parameters/composition-narrative-semantic.json: sample semantic
  SearchParameter over Composition and section narrative text.
- docs: deployment and narrative example sections in SemanticSearch.md.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.13%. Comparing base (d3c04c8) to head (9f7b769).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6098      +/-   ##
==========================================
+ Coverage   81.51%   82.13%   +0.61%     
==========================================
  Files        1036     1036              
  Lines       40497    40500       +3     
  Branches     6611     6611              
==========================================
+ Hits        33013    33265     +252     
+ Misses       5916     5665     -251     
- Partials     1568     1570       +2     

see 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI added 3 commits November 24, 2026 15:40
- Infer the default embedding model version for ada-002 versus embedding-3.
- Document existing deployment version pinning, private networking, R5
  processingMode, and strict semantic-search verification.
- Make the existing-account firewall example fail on lookup or rule errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Clarify that changing an in-use embedding model is not a supported migration
  and a plain $reindex does not rebuild enabled SearchParameters.
- Show the async reindex request and Content-Location polling before strict search.
- Make IP list parsing reject empty entries without a failing subshell pipeline.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Explain that model identity settings refresh only with deployment and that
  in-use changes can mix vectors or leave old resources unsearchable.
- Reject malformed multiline and trailing-comma App Service IP output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Image-only narratives normalize to an empty string that fails StringSearchValue’s whitespace guard, causing Composition saves or reindexing to fail instead of skipping the block.

1 open issue
What changed in this PR

Adds Azure Foundry deployment options to the sample ARM template for SQL semantic search, plus a Composition narrative SearchParameter and setup guidance. Changes are limited to deployment samples and documentation.

Changes:

  • Supports new or existing Foundry accounts, managed-identity access, embedding configuration, and network restrictions for new accounts.
  • Adds a semantic SearchParameter for Composition and nested-section narratives.
  • Documents deployment, network access, reindexing, and FHIR-version requirements.
File Description
samples/​templates/​default-azuredeploy-docker.json Adds optional Foundry provisioning and vector-search app settings.
samples/​search-parameters/​composition-narrative-semantic.json Adds per-narrative semantic indexing for Compositions.
docs/​SemanticSearch.md Explains Foundry setup and the Composition search example.
docs/​DefaultDeployment.md Links to semantic-search deployment guidance.

Review effort: Balanced

"Composition"
],
"type": "special",
"expression": "(Composition.text.`div` | Composition.repeat(section).text.`div`).select(toString().replaceMatches('<[^>]*>', ' ').replace('&lt;', '<').replace('&gt;', '>').replace('&amp;', '&').replaceMatches('\\\\s+', ' ').trim())",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants