Skip to content

Embedding: Adds Microsoft.Azure.Cosmos.AI package scaffold#5845

Open
ananth7592 wants to merge 2 commits into
mainfrom
users/amudumba/5841-embedding-package-scaffold
Open

Embedding: Adds Microsoft.Azure.Cosmos.AI package scaffold#5845
ananth7592 wants to merge 2 commits into
mainfrom
users/amudumba/5841-embedding-package-scaffold

Conversation

@ananth7592
Copy link
Copy Markdown
Member

@ananth7592 ananth7592 commented May 6, 2026

Summary

Scaffolds the new Microsoft.Azure.Cosmos.AI package — an optional, provider-style extension library for the Azure Cosmos DB .NET SDK that delivers AI-powered capabilities to applications built on Cosmos DB.

This PR is infrastructure only — no business logic. The first capability implementation follows in #5842.


Motivation

AI is becoming a first-class requirement for modern data applications. Developers increasingly want their database layer to participate in AI workflows — powering semantic search, retrieval-augmented generation (RAG), and intelligent query augmentation — without having to build and maintain the plumbing themselves.

Microsoft.Azure.Cosmos.AI is the home for these capabilities in the .NET SDK. It is a dedicated, optional package that extends the core Azure Cosmos DB SDK with AI-powered features, keeping them modular and independently evolvable.

Why a separate package?

  • Zero cost for non-AI workloads. Applications that don't use AI features pull in no AI dependencies. Azure.AI.OpenAI and related packages are only present for customers who explicitly opt in.
  • Independent versioning. The AI package ships on its own cadence, allowing rapid iteration on AI capabilities without coupling to the core SDK release cycle.
  • Established extensibility model. This follows the exact pattern already proven by Microsoft.Azure.Cosmos.Encryption — a separate, optional, provider-style package that extends the core SDK without polluting it.
  • Clear separation of concerns. The core SDK owns the data plane. The AI package owns AI service integration. Each can evolve, be tested, and be reviewed independently.

Over time, Microsoft.Azure.Cosmos.AI will be the single, consistent destination for AI-powered Cosmos DB capabilities in .NET — whether that is automatic vector embedding generation, semantic ranking, AI-assisted query construction, or future capabilities as the AI landscape
evolves.


Changes

New project scaffold

  • Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj - netstandard2.0, SNK signing, SdkProjectRef pattern, Azure.AI.OpenAI 2.1.0, explicit Newtonsoft.Json 10.0.2
  • Microsoft.Azure.Cosmos.AI/src/AssemblyInfo.cs - InternalsVisibleTo for test project with strong-name public key
  • Microsoft.Azure.Cosmos.AI/tests/.../Microsoft.Azure.Cosmos.AI.Tests.csproj - Empty MSTest project wired to main project
  • Microsoft.Azure.Cosmos.AI/Directory.Build.props - Delegates up to repo root props

Versioning

  • Directory.Build.props - Added CosmosAIOfficialVersion, CosmosAIPreviewVersion, CosmosAIPreviewSuffixVersion
  • Microsoft.Azure.Cosmos.sln - Added AI solution folder with both projects

Publishing pipelines

  • azure-pipelines-cosmosai-official.yml - Top-level release pipeline with Release Gates stage and Build/Pack/Publish stage
  • templates/static-tools-cosmosai.yml - Static analysis with three build variants (NuGet ref, SdkProjectRef, parity check) plus BinSkim, CredScan, PoliCheck, AntiMalware, Component Governance
  • templates/cosmosai-nuget-pack.yml - Build, .nupkg, .snupkg symbols, SBOM manifest, Azure blob drop, artifact publish

Design Decisions

Why netstandard2.0?
Matches Microsoft.Azure.Cosmos and Microsoft.Azure.Cosmos.Encryption - broadest framework reach without sacrificing modern API access.

Why Newtonsoft.Json with PrivateAssets="All"?
The Cosmos SDK enforces an explicit Newtonsoft.Json >= 10.0.2 reference on all dependents via an MSBuild check. PrivateAssets="All" satisfies the check at build time while keeping the package off the public .nuspec dependency graph for consumers - identical to the Encryption package.

Why pipelines in this PR?
Infrastructure is reviewable independently of business logic. The YAML files can merge and be registered in Azure DevOps now; the pipeline should be activated (queued for release) only after #5842 lands and provides real content to gate on.


Verification

  • dotnet build (official + SdkProjectRef variants) -> 0 warnings, 0 errors
  • dotnet test -> No tests yet (empty), exits 0

Related

Closes #5841
Part of #5830

@ananth7592 ananth7592 force-pushed the users/amudumba/5841-embedding-package-scaffold branch from 612d090 to 8f7d3b7 Compare May 6, 2026 23:55
@ananth7592 ananth7592 changed the title Embedding: Adds Microsoft.Azure.Cosmos.Embedding package scaffold Embedding: Adds Microsoft.Azure.Cosmos.AI package scaffold May 8, 2026
@NaluTripician
Copy link
Copy Markdown
Contributor

@sdkReviewAgent

Comment thread templates/cosmosai-nuget-pack.yml Outdated
BlobPrefix: 'cosmosdb/csharp/cosmosai/$(BlobVersion)'
CleanTargetBeforeCopy: ${{ parameters.CleanupFolder }}

- task: PublishBuildArtifacts@1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟡 Pipeline: PublishBuildArtifacts nested inside release-only conditional — CI builds skip artifact publishing

  - ${{ if eq(parameters.ReleasePackage, true) }}:
    ...
    - task: PublishBuildArtifacts@1          # ← 4-space indent = inside conditional

In the sibling encryption-nuget-pack.yml (line 76), PublishBuildArtifacts@1 is at the step root level (2-space indent), meaning it runs unconditionally for both CI and release builds:

  - task: PublishBuildArtifacts@1            # ← 2-space indent = outside conditional

Why this matters: The CI pipeline (azure-pipelines-cosmosai.yml) calls this template with ReleasePackage: false. Because the publish step is inside the conditional, PR/CI builds will silently skip artifact publishing. Reviewers and testers won't be able to download the .nupkg from Azure DevOps to inspect the package output — only the release pipeline produces downloadable artifacts. This appears to be a copy-paste indentation error from mirroring the encryption template.

Suggested fix: Outdent PublishBuildArtifacts@1 to the steps level (2-space indent) to match the encryption template:

    # end of ${{ if eq(parameters.ReleasePackage, true) }} block

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts: Microsoft.Azure.Cosmos.AI'
    inputs:
      artifactName: Microsoft.Azure.Cosmos.AI

⚠️ AI-generated review — may be incorrect. Agree? → resolve the conversation. Disagree? → reply with your reasoning.

Comment thread azure-pipelines-cosmosai.yml
Comment thread Directory.Build.props
Comment thread Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj
@xinlian12
Copy link
Copy Markdown
Member

Review complete (30:54)

Posted 5 inline comment(s).

Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage

@ananth7592
Copy link
Copy Markdown
Member Author

Why a separate azure-pipelines-cosmosai-official.yml rather than folding AI into the main SDK pipelines?

A few concrete reasons, all of which mirror the established pattern in azure-pipelines-encryption-official.yml:

  1. Independent release cadence. The AI package version is governed by its own properties in Directory.Build.props (CosmosAIOfficialVersion, CosmosAIPreviewVersion, CosmosAIPreviewSuffixVersion) — fully decoupled from ClientOfficialVersion / ClientPreviewVersion. We need to be able to ship an AI patch (e.g., a provider bug-fix) without cutting a new core SDK release, and vice versa. A separate official pipeline is the cleanest way to enforce that.

  2. Separate approval gate. Official releases require a manual approval on the publish stage. Keeping the AI release on its own pipeline means the AI release approver list, retention policy, and partner-drop blob path (cosmosdb/csharp/cosmosai/$(BlobVersion)) are scoped independently from the core SDK approval workflow.

  3. Different consumer surface. AI publishes to a distinct NuGet package id (Microsoft.Azure.Cosmos.AI) with its own symbol package, signing manifest, and partner-drop destination. Bundling it into azure-pipelines.yml would either pollute every core-SDK release with AI artifacts or require complex conditional gating inside a single mega-pipeline.

  4. Precedent. Microsoft.Azure.Cosmos.Encryption has used this exact "separate official pipeline + shared template" structure (templates/encryption-nuget-pack.yml, azure-pipelines-encryption-official.yml) for years. The AI pipelines (templates/cosmosai-nuget-pack.yml + azure-pipelines-cosmosai-official.yml) deliberately mirror that layout so the maintenance pattern is consistent across the optional-extension packages.

CI coverage is not sacrificed by this split: azure-pipelines-cosmosai.yml runs on every PR touching the AI package (and now also Directory.Build.props after commit 3b1fdb0), so the AI package still gets full pack + parity validation on each change. The "official" pipeline only handles the release-time signing, symbol packaging, and partner-drop publishing.

Happy to consolidate into the main SDK pipelines if the team would rather move that direction across both Encryption and AI together — that would be a larger refactor that should land as its own change rather than be bundled into this scaffold.

Comment thread Microsoft.Azure.Cosmos.AI/src/Mirrored/AssemblyKeys.cs
Introduces Microsoft.Azure.Cosmos.AI - an optional extension library
that will host AI-powered capabilities (embeddings, semantic re-ranking,
OCR, model integrations) layered on the v3 SDK. Infrastructure only;
no public APIs are exposed yet. The first capability - the Azure OpenAI
embedding provider - lands in #5849.

Package layout
- Microsoft.Azure.Cosmos.AI/src - netstandard2.0 library, delay-signed
  with the MSSharedLib key, three-build aware via SdkProjectRef:
  ProjectReference in-source, NuGet pin [3.59.0,) for stable,
  3.60.0-preview.0 for preview.
- Microsoft.Azure.Cosmos.AI/src/AssemblyInfo.cs - assembly-level
  attributes (CLSCompliant, ComVisible).
- Microsoft.Azure.Cosmos.AI/src/Mirrored/AssemblyKeys.cs - local copy of
  the public-key constant so InternalsVisibleTo resolves without a
  cross-project Compile link.
- Microsoft.Azure.Cosmos.AI/Directory.Build.props - package-scoped
  overrides layered above the root props.
- Microsoft.Azure.Cosmos.AI/tests/Microsoft.Azure.Cosmos.AI.Tests -
  MSTest test project skeleton targeting net8.0.

Versioning (root Directory.Build.props)
- Add CosmosAIOfficialVersion, CosmosAIPreviewVersion, and
  CosmosAIPreviewSuffixVersion properties so the AI package versions
  independently from the core SDK.
- Add COSMOSAIPREVIEW to DefineConstants alongside PREVIEW and
  ENCRYPTIONPREVIEW so future preview-gated AI code can #if-guard
  consistently with the established pattern.

Pipelines
- azure-pipelines-cosmosai.yml - PR validation pipeline. Triggers on
  changes under Microsoft.Azure.Cosmos.AI/**, the cosmosai templates,
  the AI pipelines themselves, and Directory.Build.props (so version
  bumps to the CosmosAI* properties run AI parity validation).
- azure-pipelines-cosmosai-official.yml - release pipeline with its
  own approval gate and partner-drop blob path, mirroring the existing
  azure-pipelines-encryption-official.yml layout.
- templates/cosmosai-nuget-pack.yml - shared build + pack template.
  PublishBuildArtifacts is at step-root so CI builds (not just release
  builds) publish the .nupkg as a downloadable artifact.
- templates/static-tools-cosmosai.yml - static-analysis template.

Dependencies
- Pin Newtonsoft.Json 10.0.2 with PrivateAssets=All to satisfy the
  core SDK's transitive contract without leaking onto the public
  dependency graph.

No business logic, no public types, no contract surface change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ananth7592 ananth7592 force-pushed the users/amudumba/5841-embedding-package-scaffold branch from 3b1fdb0 to f67098f Compare May 19, 2026 20:01
@ananth7592
Copy link
Copy Markdown
Member Author

Local validation on commit f67098f96

All review feedback applied. Branch is now a single squashed commit. Local build matrix:

Three-build parity (AI src project)

# Configuration Core SDK source Result
1 Stable Microsoft.Azure.Cosmos NuGet [3.59.0,) ✅ 0 warn / 0 err (5.6 s)
2 Preview (-p:IsPreview=true) Microsoft.Azure.Cosmos NuGet 3.60.0-preview.0 ✅ 0 warn / 0 err (2.6 s)
3 SdkProjectRef (-p:SdkProjectRef=true) In-tree ProjectReference ✅ 0 warn / 0 err (17.6 s)

Command:

dotnet build Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj -c Release [flags] --nologo

Pack

dotnet pack Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj -c Release -p:SdkProjectRef=true -o .\artifacts

✅ Produced Microsoft.Azure.Cosmos.AI.1.0.0.nupkg (6,931 bytes).

Test project build (net8.0 after Pilchie feedback)

dotnet build Microsoft.Azure.Cosmos.AI/tests/Microsoft.Azure.Cosmos.AI.Tests/Microsoft.Azure.Cosmos.AI.Tests.csproj -c Release

✅ 0 warn / 0 err. Output: bin/Release/net8.0/Microsoft.Azure.Cosmos.AI.Tests.dll.

Cross-package smoke test (core SDK still compiles with AI project present)

dotnet build Microsoft.Azure.Cosmos/src/Microsoft.Azure.Cosmos.csproj -c Release

✅ 0 warn / 0 err.

Review-comment status

# Comment Status
1 PublishBuildArtifacts nested inside release-only conditional ✅ Fixed — outdented to step root in templates/cosmosai-nuget-pack.yml, matching encryption-nuget-pack.yml.
2 Directory.Build.props missing from CI trigger paths ✅ Fixed — added to pr.paths.include in azure-pipelines-cosmosai.yml.
3 COSMOSAIPREVIEW define constant missing ✅ Fixed — added alongside PREVIEW;ENCRYPTIONPREVIEW in root Directory.Build.props.
4 No API contract enforcement test infrastructure ✅ Deferred to #5849 (first PR introducing public AI surface).
5 Main CI will NuGet-restore 3.60.0-preview.0 ✅ Verified — 3.60.0-preview.0 is published on nuget.org; restore resolves cleanly.
6 (Pilchie, raised on #5849) net6.0 is out of support; target net8.0 ✅ Applied here too — test project bumped to net8.0. Library stays netstandard2.0 (max consumer reach; matches the core SDK and Encryption library).

Note: pre-existing main-branch build break in Encryption

A solution-level build with -p:SdkProjectRef=true (no -p:IsPreview=true) fails on origin/main HEAD da4efa8c8 with 5× CS0115 in Microsoft.Azure.Cosmos.Encryption / Microsoft.Azure.Cosmos.Encryption.Custom. Root cause is a #if guard mismatch where the base Container.IsFeedRangePartOfAsync / GetPartitionKeyRangesAsync are gated #if PREVIEW but the derived overrides use #if SDKPROJECTREF (or are unguarded). Unrelated to this PR — repro on clean origin/main confirmed.

Ready for re-review. CC @xinlian12.

Copy link
Copy Markdown
Contributor

@NaluTripician NaluTripician left a comment

Choose a reason for hiding this comment

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

Did a structural diff against Microsoft.Azure.Cosmos.Encryption since that's the pattern this scaffold is following.Most of it lines up cleanly; a few items below are worth sorting before this lands, since they get more expensive to fix once #5842 puts real code on top of the scaffold.

Headline items:

  • 🔴 The .sln update mentioned in the PR description doesn't appear in the diff — leaves the AI projects off the per-PR build path that catches core-SDK breakages today.
  • 🟡 Missing the 4th GA-surface parity build step from static-tools-encryption.yml (the one added after PR #5825 had a miss).
  • 🟡 No per-package changelog, README, or contract baseline — easy to seed at scaffold time, ugly to scope-creep into the implementation PR.
  • 🟡 Test project pins (Microsoft.NET.Test.Sdk 16.2.0, MSTest 1.2.0, Moq 4.8.3, coverlet 3.1.2) are 2016–2019 vintage. New test project = cheapest moment to land on the modern stack.
  • 🟡 GDN tasks (BinSkim/CredScan/PoliCheck/PostAnalysis) inherit the disabled condition: eq(1,2) line verbatim from Encryption with a years-old comment — at minimum needs a tracking issue.

Inline comments below.

@@ -0,0 +1,80 @@
<Project Sdk="Microsoft.NET.Sdk">
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.

The PR description says the .sln got an "AI" solution folder with both projects, but the diff doesn't show any change to Microsoft.Azure.Cosmos.sln and I can't find Cosmos.AI referenced anywhere in it. Was this dropped in a rebase?

This matters because templates/build-internal.yml and templates/build-preview.yml both build via Microsoft.Azure.Cosmos.sln on every PR — that's how core-SDK changes get caught against Encryption today (the static-tools-encryption template cites PR #5825 and PR #5783 as prior incidents of exactly this class). The new azure-pipelines-cosmosai.yml only triggers on Microsoft.Azure.Cosmos.AI/**, so any future core-SDK PR that breaks the AI package will sail through and only surface on the next AI-directory PR.

Adding both projects to the .sln under an "AI" solution folder fixes it. Sanity check: dotnet build Microsoft.Azure.Cosmos.sln -p:IsPreview=true -p:SdkProjectRef=true should build AI alongside Encryption.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e — both Microsoft.Azure.Cosmos.AI and Microsoft.Azure.Cosmos.AI.Tests are now in Microsoft.Azure.Cosmos.sln under a new AI solution folder (mirrors the existing Encryption / Encryption.Custom folders). Verified locally with dotnet build Microsoft.Azure.Cosmos.sln -p:IsPreview=true -p:SdkProjectRef=true --configuration Release — 0 errors, 16 pre-existing warnings (all Microsoft.Azure.Cosmos.Performance.Tests net6.0 EOL warnings, unrelated). This now means every PR build that runs the solution will catch core-SDK changes that break the AI package, same as the Encryption guardrail.

<Authors>Microsoft</Authors>
<Description>AI extensions library for Azure Cosmos DB for NoSQL. Provides an Azure OpenAI / Foundry-backed embedding provider for automatic vector embedding generation in hybrid and vector search queries. Designed to be extensible for broader AI scenarios including semantic re-ranking, OCR, and model integrations. For more information, refer to https://aka.ms/CosmosDB</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<Title>Microsoft Azure Cosmos DB AI extensions library</Title>
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.

Nit: <Title>...AI extensions library</Title> is plural — FaultInjection and Encryption both use singular ("Fault Injection library", "encryption library"). Title surfaces on nuget.org, so worth aligning with the sibling convention if not intentional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e — Microsoft Azure Cosmos DB AI extension library (singular), to align with Microsoft Azure Cosmos DB Fault Injection library and Microsoft Azure Cosmos DB client-side encryption library.

<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageTags>microsoft;azure;cosmos;cosmosdb;documentdb;nosql;azureofficial;dotnetcore;netcore;netstandard;ai;embedding;vector;openai;semanticranking</PackageTags>
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.

Two artifacts worth seeding now, before the first preview push to nuget.org:

  1. Microsoft.Azure.Cosmos.AI/changelog.md — both Encryption and FaultInjection ship a per-package changelog. FaultInjection's csproj also has <PackageReleaseNotes> pointing at it so customers can find release notes from nuget.org. Without one, the first preview push has no discoverable release notes and the implementation PR ([Embedding V0] AzureOpenAIEmbeddingGenerator provider implementation #5842) ends up scope-creeping one in.
  2. Microsoft.Azure.Cosmos.AI/README.md — FaultInjection has one, and it's what nuget.org renders when <PackageReadmeFile> is wired up. Trivial to seed with a stub.

Both are essentially free at the scaffold stage and load-bearing once the package is on nuget.org.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e:

  • Seeded Microsoft.Azure.Cosmos.AI/changelog.md (Keep-a-Changelog format, mirrors Encryption) with an Unreleased entry describing the scaffold.
  • Seeded Microsoft.Azure.Cosmos.AI/README.md describing the package, why it's separate, and planned capabilities — mirrors the FaultInjection README structure.
  • Wired pointing at the changelog (FaultInjection pattern) and README.md so nuget.org renders the README.

#5842 inherits the changelog Unreleased bucket — its description should add a customer-facing entry under ### Added for AzureOpenAIEmbeddingGenerator, per the repo's changelog classifier.


namespace Microsoft.Azure.Cosmos.AI
{
internal static class AssemblyKeys
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.

This makes three copies of the same hard-coded test public key in the repo (Encryption, Encryption.Custom, and now AI), all under "Mirrored" folders with no canonical source. If the key is ever rotated, three files diverge.

Out of scope for this PR, but worth a follow-up: extract a single AssemblyKeys.cs (e.g., under Microsoft.Azure.Cosmos/build/) and <Compile Include="..." Link="Mirrored\AssemblyKeys.cs" /> it from all three packages.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed and noted — leaving the 3 Mirrored\AssemblyKeys.cs copies as-is in this PR per your out-of-scope call. I'll file a follow-up issue to extract a single canonical AssemblyKeys.cs under Microsoft.Azure.Cosmos/build/ and it from all three packages (Encryption, Encryption.Custom, AI), and link the issue from this thread once filed.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
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.

These pins are very stale to inherit from Encryption — Encryption is locked into them by accumulated test history, but a brand-new test project with zero tests doesn't have that constraint:

  • Microsoft.NET.Test.Sdk 16.2.0 is from 2019 (current 17.13+)
  • MSTest.TestAdapter / MSTest.TestFramework 1.2.0 is from 2016; MSTest is on 3.x and has consolidated under a single MSTest meta-package
  • Moq 4.8.3 predates the 2023 SponsorLink supply-chain incident
  • coverlet.collector 3.1.2 vs. current 6.x

Cheapest moment to land on the modern stack is right now, before #5842 lands real tests. Worth taking either the Azure SDK Engineering recommended test stack or whatever the newer test projects in this repo are using.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e — modernized to match what the main SDK tests project (Microsoft.Azure.Cosmos.Tests.csproj) uses today:

Pin Before After
Microsoft.NET.Test.Sdk 16.2.0 17.12.0
MSTest.TestAdapter 1.2.0 3.7.3
MSTest.TestFramework 1.2.0 3.7.3
coverlet.collector 3.1.2 6.0.2
Moq 4.8.3 4.8.3 (unchanged — matches main SDK tests pin)

Left Moq at 4.8.3 deliberately so we're not diverging from the rest of the repo on the SponsorLink question in this PR — happy to bump it across the repo (or swap to NSubstitute) as a separate change if you'd like. Tests project builds and runs clean (Passed 1/1).

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Azure.Cosmos.AI.csproj" />
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.

Microsoft.Azure.Cosmos.Encryption.Tests.csproj links in ContractEnforcement.cs from the main SDK tests and ships DotNetSDKEncryptionAPI.net6.json / .net8.json baselines that lock the public surface. This project has neither.

A new GA-track package is the cheapest moment to wire this up — once #5842 lands AzureOpenAIEmbeddingGenerator and whatever options/builder types come with it, a single misplaced public modifier or accidental rename ships into a preview NuGet with nothing in the PR pipeline to catch it. Suggest adding:

<Compile Include="..\..\..\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\ContractEnforcement.cs" Link="Contracts\ContractEnforcement.cs" />
<Compile Include="..\..\..\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\ContractType.cs" Link="Contracts\ContractType.cs" />

plus an empty DotNetSDKCosmosAIAPI.net8.json baseline and a [TestClass] that calls ContractEnforcement.ValidateContractContainBreakingChanges(...). Baseline stays empty for this PR; #5842 fills it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e:

  • Linked ......\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\ContractEnforcement.cs and ContractType.cs into the AI test project (same <Compile Include … Link> pattern as Microsoft.Azure.Cosmos.Encryption.Tests.csproj).
  • Added Contracts\ContractEnforcementTests.cs with a [TestClass] that calls ValidateContract(dllName: "Microsoft.Azure.Cosmos.AI", baselinePattern: "DotNetSDKCosmosAIAPI", breakingChangesPattern: "DotNetSDKCosmosAIAPIChanges").
  • Added Contracts\DotNetSDKCosmosAIAPI.net8.json baseline. The AI assembly currently has no own public types, so the baseline only captures System.Object-inherited members on the assembly-level enumeration; [Embedding V0] AzureOpenAIEmbeddingGenerator provider implementation #5842 fills it with real types via UpdateContracts.ps1.
  • Wired the copy-to-output entry so baselines flow to the test bin folder.

Test run: Passed 1/1 (ContractChanges).

command: build
nugetConfigPath: NuGet.config
projects: Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj
arguments: '-p:Optimize=true -p:IsPreview=true -p:SdkProjectRef=true -p:DefineSdkProjectRefSymbol=false --configuration Release'
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.

The 4th build variant from static-tools-encryption.yml is missing — the one that builds against main SDK source with IsPreview unset, i.e., no PREVIEW / COSMOSAIPREVIEW symbol defined. Encryption added it explicitly after PR #5825 (FFCF GA promotion) had a miss the preview-only parity build let through; the comment block in static-tools-encryption.yml calls that out.

AI is in exactly the same position: Directory.Build.props now defines COSMOSAIPREVIEW as a preview-only constant, so any future #if COSMOSAIPREVIEW block creates the same GA/preview surface divergence. Suggest adding a 4th DotNetCoreCLI@2 step right after this one with arguments: '-p:Optimize=true -p:SdkProjectRef=true -p:DefineSdkProjectRefSymbol=false --configuration Release' (no IsPreview=true), and lifting the explanatory comment from the Encryption template.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in db7ea2e — added the 4th DotNetCoreCLI@2 step right after the SDKPROJECTREF parity step, with �rguments: '-p:Optimize=true -p:SdkProjectRef=true -p:DefineSdkProjectRefSymbol=false --configuration Release' (no IsPreview=true). Lifted the explanatory comment from static-tools-encryption.yml and updated the constant name to COSMOSAIPREVIEW (which Directory.Build.props defines as the preview-only constant for this package). The cross-reference to PR #5825 is preserved.

Comment thread templates/static-tools-cosmosai.yml Outdated

- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@4
displayName: 'BinSkim'
condition: eq(1,2) #disabling as nuget repo failing
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.

The condition: eq(1,2) #disabling as nuget repo failing line (and the matching three on CredScan/PoliCheck/PostAnalysis below) is years-old text copied verbatim from static-tools-encryption.yml. The result is that the official release-gate pipeline for a brand-new package never runs BinSkim, CredScan, PoliCheck, or PostAnalysis — only Component Governance and (continueOnError: true) AntiMalware actually run.

CredScan in particular has real value here since AI scenarios typically take endpoint URIs and token credentials. Default for a new package should arguably be "on." Suggest either (a) removing the condition: eq(1,2) lines (the "nuget repo failing" rationale needs re-validation — it's stale), or (b) keeping them disabled with a # TODO(#NNNN) referencing a real tracking issue and a removal target, not a copy of a comment from a different package.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Partial: in db7ea2e I replaced the verbatim condition: eq(1,2) #disabling as nuget repo failing comments on BinSkim, CredScan, PoliCheck, and PostAnalysis with condition: eq(1,2) # TODO(#5845): re-enable … markers, and added a block comment at the top of the GDN section explaining the intent (verify OneES NuGet feed access for these tasks, then remove the gates) and calling out that CredScan in particular matters for AI endpoint URIs / token credentials.

I stopped short of flipping the conditions on in this PR because I can't validate the OneES feed access from a local dev box, and a release-gate pipeline failing on its first run after this lands would block #5842. Happy to flip them on in a follow-up PR as soon as a release-gate dry run confirms green — or earlier in this PR if you'd prefer I just remove the conditions and let CI tell us. Your call.

Addresses Nalu's structural-diff review of #5845 (vs Microsoft.Azure.Cosmos.Encryption):

- Microsoft.Azure.Cosmos.sln: add Microsoft.Azure.Cosmos.AI and
  Microsoft.Azure.Cosmos.AI.Tests under a new 'AI' solution folder, so
  templates/build-internal.yml and build-preview.yml catch core-SDK
  changes that break the AI package on every PR (same class of bug as
  PR #5825 / #5783 caught for Encryption).

- templates/static-tools-cosmosai.yml: add the 4th GA-surface parity
  build step (IsPreview unset, SdkProjectRef=true,
  DefineSdkProjectRefSymbol=false) that static-tools-encryption.yml
  added post-#5825. Replace stale 'condition: eq(1,2) #disabling as
  nuget repo failing' comments on BinSkim/CredScan/PoliCheck/PostAnalysis
  with TODO(#5845) markers tracking re-enablement.

- Microsoft.Azure.Cosmos.AI/changelog.md, README.md: seed per-package
  changelog and readme (mirroring Encryption / FaultInjection).

- Microsoft.Azure.Cosmos.AI.csproj: singular Title ('AI extension
  library' to match Encryption / FaultInjection), wire
  PackageReleaseNotes -> changelog.md, PackageReadmeFile -> README.md.

- Microsoft.Azure.Cosmos.AI.Tests.csproj: modernize stale test pins
  (Microsoft.NET.Test.Sdk 16.2.0 -> 17.12.0, MSTest 1.2.0 -> 3.7.3,
  coverlet.collector 3.1.2 -> 6.0.2 — Moq stays at 4.8.3 to match
  existing repo pin). Link ContractEnforcement.cs / ContractType.cs
  from main SDK tests and add ContractEnforcementTests +
  DotNetSDKCosmosAIAPI.net8.json baseline so a misplaced 'public' in
  #5842 surfaces at PR review time, not at NuGet publish.

Validation:
- dotnet build Microsoft.Azure.Cosmos.sln -p:IsPreview=true -p:SdkProjectRef=true --configuration Release: 0 errors (16 pre-existing net6.0 EOL warnings on Microsoft.Azure.Cosmos.Performance.Tests).
- AI src builds clean in all 4 static-tools variants.
- AI tests: Passed 1/1 (ContractChanges).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ananth7592
Copy link
Copy Markdown
Member Author

Verification ✅

Re-ran the full test battery from a clean state on commit db7ea2e09. All 4 static-tools build variants (matching what templates/static-tools-cosmosai.yml runs in CI) and the test project are green.

# Variant Command Result
1 NuGet SDK reference (default customer-consumed build) dotnet build ... -p:Optimize=true --configuration Release ✅ 0 warnings, 0 errors
2 SDKREF main SDK source (preview) ... -p:Optimize=true -p:IsPreview=true -p:SdkProjectRef=true --configuration Release ✅ 0 warnings, 0 errors
3 NuGet-surface parity (PREVIEW on, SDKPROJECTREF off) ... -p:IsPreview=true -p:SdkProjectRef=true -p:DefineSdkProjectRefSymbol=false --configuration Release ✅ 0 warnings, 0 errors
4 GA-surface parity (no IsPreview, SDKPROJECTREF off) — NEW step added in db7ea2e09 per @NaluTripician ... -p:SdkProjectRef=true -p:DefineSdkProjectRefSymbol=false --configuration Release ✅ 0 warnings, 0 errors
5 dotnet test AI tests (includes new ContractEnforcementTests) dotnet test ...AI.Tests.csproj --configuration Release ✅ Passed 1/1 (ContractChanges, 69 ms)

Full sln build (validates .sln update)

dotnet build Microsoft.Azure.Cosmos.sln -p:IsPreview=true -p:SdkProjectRef=true --configuration Release

0 errors. 16 warnings, all pre-existing net6.0 EOL warnings on Microsoft.Azure.Cosmos.Performance.Tests (unrelated to this PR; predate it on main).

This confirms Microsoft.Azure.Cosmos.AI and Microsoft.Azure.Cosmos.AI.Tests now compile as part of every per-PR build (templates/build-internal.yml / templates/build-preview.yml), as called for in the inline .sln thread.

Updates the PR description's "Verification" section

The original PR description claimed:

  • dotnet test → No tests yet (empty), exits 0

Now reads:

  • dotnet test1 passed (ContractChanges) — the new contract-enforcement guardrail wired up per the review comment on Microsoft.Azure.Cosmos.AI.Tests.csproj.

Inline replies on each of @NaluTripician's 8 comments already posted (above on this PR).

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.

[Embedding V0] New Microsoft.Azure.Cosmos.Embedding package — scaffold

3 participants