Skip to content

Commit f67098f

Browse files
ananth7592Copilot
authored andcommitted
AI: Scaffold Microsoft.Azure.Cosmos.AI extension package (#5845)
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>
1 parent da4efa8 commit f67098f

10 files changed

Lines changed: 392 additions & 1 deletion

Directory.Build.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
<EncryptionOfficialVersion>2.0.5</EncryptionOfficialVersion>
1010
<EncryptionPreviewVersion>2.1.0</EncryptionPreviewVersion>
1111
<EncryptionPreviewSuffixVersion>preview5</EncryptionPreviewSuffixVersion>
12+
<CosmosAIOfficialVersion>1.0.0</CosmosAIOfficialVersion>
13+
<CosmosAIPreviewVersion>1.0.0</CosmosAIPreviewVersion>
14+
<CosmosAIPreviewSuffixVersion>preview.0</CosmosAIPreviewSuffixVersion>
1215
<CustomEncryptionVersion>1.0.0-preview08</CustomEncryptionVersion>
1316
<HybridRowVersion>1.1.0-preview3</HybridRowVersion>
1417
<LangVersion>10.0</LangVersion>
1518
<AboveDirBuildProps>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</AboveDirBuildProps>
16-
<DefineConstants Condition=" '$(IsNightly)' == 'true' or '$(IsPreview)' == 'true' ">$(DefineConstants);PREVIEW;ENCRYPTIONPREVIEW</DefineConstants>
19+
<DefineConstants Condition=" '$(IsNightly)' == 'true' or '$(IsPreview)' == 'true' ">$(DefineConstants);PREVIEW;ENCRYPTIONPREVIEW;COSMOSAIPREVIEW</DefineConstants>
1720
</PropertyGroup>
1821
<Import Project="$(AboveDirBuildProps)" Condition=" '$(AboveDirBuildProps)' != '' " />
1922
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
4+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// ------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// ------------------------------------------------------------
4+
5+
using System.Runtime.CompilerServices;
6+
7+
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos.AI.Tests" + Microsoft.Azure.Cosmos.AI.AssemblyKeys.TestPublicKey)]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
<AssemblyName>Microsoft.Azure.Cosmos.AI</AssemblyName>
5+
<RootNamespace>Microsoft.Azure.Cosmos.AI</RootNamespace>
6+
<LangVersion>$(LangVersion)</LangVersion>
7+
<CosmosAIVersion Condition=" '$(IsPreview)' != 'true' ">$(CosmosAIOfficialVersion)</CosmosAIVersion>
8+
<CosmosAIVersion Condition=" '$(IsPreview)' == 'true' ">$(CosmosAIPreviewVersion)</CosmosAIVersion>
9+
<CosmosAIVersionSuffix Condition=" '$(IsPreview)' == 'true' ">$(CosmosAIPreviewSuffixVersion)</CosmosAIVersionSuffix>
10+
<Version Condition=" '$(CosmosAIVersionSuffix)' == '' ">$(CosmosAIVersion)</Version>
11+
<Version Condition=" '$(CosmosAIVersionSuffix)' != '' ">$(CosmosAIVersion)-$(CosmosAIVersionSuffix)</Version>
12+
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd))</CurrentDate>
13+
<Company>Microsoft Corporation</Company>
14+
<Authors>Microsoft</Authors>
15+
<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>
16+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
17+
<Title>Microsoft Azure Cosmos DB AI extensions library</Title>
18+
<PackageId>Microsoft.Azure.Cosmos.AI</PackageId>
19+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
20+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
21+
<PackageProjectUrl>https://github.com/Azure/azure-cosmos-dotnet-v3</PackageProjectUrl>
22+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
23+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
24+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
25+
<PackageTags>microsoft;azure;cosmos;cosmosdb;documentdb;nosql;azureofficial;dotnetcore;netcore;netstandard;ai;embedding;vector;openai;semanticranking</PackageTags>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<AdditionalFiles Include="..\..\Microsoft.Azure.Cosmos\src\stylecop.json" Link="stylecop.json" />
30+
</ItemGroup>
31+
32+
<!-- Core SDK reference: project ref when building from source, otherwise NuGet pin -->
33+
<ItemGroup Condition=" '$(SdkProjectRef)' != 'True' AND '$(IsPreview)' != 'True' ">
34+
<PackageReference Include="Microsoft.Azure.Cosmos" Version="[3.59.0,)" />
35+
</ItemGroup>
36+
37+
<ItemGroup Condition=" '$(SdkProjectRef)' != 'True' AND '$(IsPreview)' == 'True' ">
38+
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.60.0-preview.0" />
39+
</ItemGroup>
40+
41+
<ItemGroup Condition=" '$(SdkProjectRef)' == 'True' ">
42+
<ProjectReference Include="..\..\Microsoft.Azure.Cosmos\src\Microsoft.Azure.Cosmos.csproj" />
43+
</ItemGroup>
44+
45+
<ItemGroup>
46+
<None Include="..\..\Icon.png" Pack="true" PackagePath=""/>
47+
</ItemGroup>
48+
49+
<!-- Required by Microsoft.Azure.Cosmos SDK; PrivateAssets=All keeps it off the public dependency graph -->
50+
<ItemGroup>
51+
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" NoWarn="NU1903" PrivateAssets="All" />
52+
</ItemGroup>
53+
54+
<!-- Azure OpenAI provider dependency -->
55+
<ItemGroup>
56+
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
57+
</ItemGroup>
58+
59+
<!-- Analyzers -->
60+
<ItemGroup>
61+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
62+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.0.102" PrivateAssets="All" />
63+
</ItemGroup>
64+
65+
<!-- Strong-name signing -->
66+
<PropertyGroup>
67+
<SigningType>Product</SigningType>
68+
<SignAssembly>true</SignAssembly>
69+
<DelaySign>true</DelaySign>
70+
<AssemblyOriginatorKeyFile>..\..\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
71+
</PropertyGroup>
72+
73+
<PropertyGroup Condition=" '$(SdkProjectRef)' == 'True' ">
74+
<DefineSdkProjectRefSymbol Condition=" '$(DefineSdkProjectRefSymbol)' == '' ">true</DefineSdkProjectRefSymbol>
75+
</PropertyGroup>
76+
77+
<PropertyGroup Condition=" '$(DefineSdkProjectRefSymbol)' == 'true' ">
78+
<DefineConstants>$(DefineConstants);SDKPROJECTREF</DefineConstants>
79+
</PropertyGroup>
80+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// ------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// ------------------------------------------------------------
4+
5+
namespace Microsoft.Azure.Cosmos.AI
6+
{
7+
internal static class AssemblyKeys
8+
{
9+
/// <summary>TestPublicKey is an unsupported strong key for testing and internal use only.</summary>
10+
internal const string TestPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100197c25d0a04f73cb271e8181dba1c0c713df8deebb25864541a66670500f34896d280484b45fe1ff6c29f2ee7aa175d8bcbd0c83cc23901a894a86996030f6292ce6eda6e6f3e6c74b3c5a3ded4903c951e6747e6102969503360f7781bf8bf015058eb89b7621798ccc85aaca036ff1bc1556bb7f62de15908484886aa8bbae";
11+
}
12+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<IsTestProject>true</IsTestProject>
5+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6+
<Platform>AnyCPU</Platform>
7+
<TargetFramework>net8.0</TargetFramework>
8+
<IsPackable>false</IsPackable>
9+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
10+
<RootNamespace>Microsoft.Azure.Cosmos.AI.Tests</RootNamespace>
11+
<LangVersion>$(LangVersion)</LangVersion>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
16+
<PackageReference Include="Moq" Version="4.8.3" />
17+
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
18+
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
19+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
20+
<PackageReference Include="coverlet.collector" Version="3.1.2" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<ProjectReference Include="..\..\src\Microsoft.Azure.Cosmos.AI.csproj" />
25+
</ItemGroup>
26+
27+
<PropertyGroup>
28+
<SignAssembly>true</SignAssembly>
29+
<DelaySign>true</DelaySign>
30+
<AssemblyOriginatorKeyFile>..\..\..\testkey.snk</AssemblyOriginatorKeyFile>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
34+
<PlatformTarget>x64</PlatformTarget>
35+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
36+
</PropertyGroup>
37+
38+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
trigger: none
2+
3+
pr: none
4+
5+
variables:
6+
ReleaseArguments: ' --filter "TestCategory!=Quarantine" --verbosity normal '
7+
VmImage: windows-latest # https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops
8+
BuildConfiguration: Release
9+
Packaging.EnableSBOMSigning: true
10+
11+
stages:
12+
- stage:
13+
displayName: CosmosAI Release Gates
14+
jobs:
15+
- template: templates/static-tools-cosmosai.yml
16+
parameters:
17+
BuildConfiguration: '${{ variables.BuildConfiguration }}'
18+
19+
- stage:
20+
displayName: Build, Pack and Publish
21+
jobs:
22+
- template: templates/cosmosai-nuget-pack.yml
23+
parameters:
24+
BuildConfiguration: Release
25+
ReleasePackage: true
26+
OutputPath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/$(BuildConfiguration)/Microsoft.Azure.Cosmos.AI'
27+
BlobVersion: $(BlobVersion)

azure-pipelines-cosmosai.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# CI pipeline for Microsoft.Azure.Cosmos.AI — runs on every PR touching the AI package.
2+
# Validates the three-build parity strategy (NuGet ref, SdkProjectRef, parity check)
3+
# before changes reach main, complementing the manual release-gate in
4+
# azure-pipelines-cosmosai-official.yml.
5+
trigger: none
6+
7+
pr:
8+
branches:
9+
include:
10+
- main
11+
- releases/*
12+
paths:
13+
include:
14+
- 'Microsoft.Azure.Cosmos.AI/**'
15+
- 'templates/cosmosai-nuget-pack.yml'
16+
- 'templates/static-tools-cosmosai.yml'
17+
- 'azure-pipelines-cosmosai.yml'
18+
- 'azure-pipelines-cosmosai-official.yml'
19+
- 'Directory.Build.props'
20+
21+
variables:
22+
BuildConfiguration: Release
23+
24+
jobs:
25+
- template: templates/static-tools-cosmosai.yml
26+
parameters:
27+
BuildConfiguration: '${{ variables.BuildConfiguration }}'
28+
29+
- template: templates/cosmosai-nuget-pack.yml
30+
parameters:
31+
BuildConfiguration: '${{ variables.BuildConfiguration }}'
32+
ReleasePackage: false
33+
OutputPath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/$(BuildConfiguration)/Microsoft.Azure.Cosmos.AI'

templates/cosmosai-nuget-pack.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# File: templates/cosmosai-nuget-pack.yml
2+
3+
parameters:
4+
- name: BuildConfiguration
5+
type: string
6+
default: ''
7+
- name: Arguments
8+
type: string
9+
default: ''
10+
- name: OutputPath
11+
type: string
12+
default: ''
13+
- name: BlobVersion
14+
type: string
15+
default: ''
16+
- name: ReleasePackage
17+
type: boolean
18+
default: false
19+
- name: CleanupFolder
20+
type: boolean
21+
default: false
22+
23+
jobs:
24+
- job: GenerateNugetPackages
25+
displayName: Generate Nuget packages
26+
pool:
27+
name: 'OneES'
28+
29+
steps:
30+
- task: DotNetCoreCLI@2
31+
displayName: Build Microsoft.Azure.Cosmos.AI
32+
inputs:
33+
command: build
34+
configuration: $(BuildConfiguration)
35+
nugetConfigPath: NuGet.config
36+
projects: Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj
37+
arguments: --configuration ${{ parameters.BuildConfiguration }} -p:Optimize=true ${{ parameters.Arguments }}
38+
versioningScheme: OFF
39+
40+
- task: DotNetCoreCLI@2
41+
displayName: 'Create AI NuGet Package'
42+
inputs:
43+
command: custom
44+
projects: 'Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj'
45+
custom: pack
46+
arguments: '-v detailed -c ${{ parameters.BuildConfiguration }} --no-build ${{ parameters.Arguments }} --no-restore -o "${{ parameters.OutputPath }}"'
47+
48+
- ${{ if eq(parameters.ReleasePackage, true) }}:
49+
- task: DotNetCoreCLI@2
50+
displayName: 'Create AI NuGet Symbols Package'
51+
inputs:
52+
command: custom
53+
projects: 'Microsoft.Azure.Cosmos.AI/src/Microsoft.Azure.Cosmos.AI.csproj'
54+
custom: pack
55+
arguments: '-v detailed -c ${{ parameters.BuildConfiguration }} --no-build --include-symbols /p:SymbolPackageFormat=snupkg ${{ parameters.Arguments }} --no-restore -o "${{ parameters.OutputPath }}"'
56+
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
57+
inputs:
58+
BuildDropPath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/$(BuildConfiguration)/Microsoft.Azure.Cosmos.AI'
59+
60+
- ${{ if ne(parameters.BlobVersion, '') }}:
61+
- task: AzureFileCopy@6
62+
displayName: 'Copy Artifacts to Azure SDK Release blob storage'
63+
condition: succeeded()
64+
inputs:
65+
SourcePath: '$(Build.ArtifactStagingDirectory)/bin/AnyCPU/$(BuildConfiguration)/Microsoft.Azure.Cosmos.AI/**'
66+
azureSubscription: azuresdkpartnerdrops
67+
Destination: AzureBlob
68+
storage: azuresdkpartnerdrops
69+
ContainerName: 'drops'
70+
BlobPrefix: 'cosmosdb/csharp/cosmosai/$(BlobVersion)'
71+
CleanTargetBeforeCopy: ${{ parameters.CleanupFolder }}
72+
73+
- task: PublishBuildArtifacts@1
74+
displayName: 'Publish Artifacts: Microsoft.Azure.Cosmos.AI'
75+
inputs:
76+
artifactName: Microsoft.Azure.Cosmos.AI

0 commit comments

Comments
 (0)