Skip to content

About

This repo is the home base for two talks: Building an Enterprise Chat GPT and Securing Your Azure AI Workload

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CreatingAnEnterpriseAISolution

Caution

THIS REPOSITORY CODE IS NOT READY FOR PRODUCTION USE AND SHOULD NOT BE USED FOR ANYTHING OTHER THAN LEARNING.

  • The functionality is not built to scale. Parts of the design work for a demo with a handful of users and documents, and would not hold up under real load or real data volumes.
  • The application code has a number of known security gaps that would be very dangerous to deploy. These are not about the landing zone or network infrastructure. They are in the application code and how it is implemented.

Use this repository to learn from, not to run anything real.

This repo is the home base for two talks: Building an Enterprise Chat GPT and Securing Your Azure AI Workload.

It holds a complete, private-by-default Azure AI workload in Bicep, a reusable Azure OpenAI library, an ingestion function and a chat web app built on it.

What's here

Folder Contents
iac/ Bicep for the whole workload: VNet and private DNS, AI Services with model deployments, SQL, Key Vault, Event Grid, a Flex Consumption function app with its storage, blob storage, App Service, Log Analytics and Application Insights. Also the RBAC, OIDC and validation scripts.
src-lib/ The AzureAI.Interop library as source: AzureAI.Interop.Abstractions, AzureAI.Interop and AzureAI.Interop.Rag, plus their tests.
src-data/aidata The document and chunk tables (EF Core), shared by both apps. Embeddings live in an Azure SQL vector(1536) column. The web app applies the migrations.
src-web/aiweb ASP.NET Core MVC app with Identity sign-in and two roles, User and Admin. Documents uploads files to blob storage and shows their ingestion status. Chat answers from the uploaded documents with numbered citations, creates images on request (gpt-image-2), takes spoken questions (gpt-4o-transcribe) and reads answers aloud (gpt-4o-mini-tts). Admin grants roles and shows each user's spend for the day.
src-fn/aifunctions Azure Functions (isolated worker) app. IngestUploadedDocument receives BlobCreated events from Event Grid, extracts the text (PDF, DOCX, Markdown, text), chunks and embeds it, and stores the chunks in SQL.
src-web/tests, src-fn/tests Tests for both apps. SQLite in memory stands in for Azure SQL; the vector query is checked by the SQL it generates.
.github/workflows Build and test, infrastructure deploy, and web and function deploys.

How it fits together

Architecture: web app and function app in a Central US VNet reach Blob storage, Azure SQL, Key Vault and function storage through private endpoints, and Azure AI Services in East US 2 through a cross-region private endpoint. Blob uploads raise BlobCreated through Event Grid to the function app.

  1. A signed-in user uploads a file on Documents. The web app writes a Pending row to docs.Documents, then the blob to the uploads container.
  2. Storage raises BlobCreated. Event Grid delivers it to IngestUploadedDocument, which is the only inbound traffic the function app accepts.
  3. The function extracts, chunks and embeds the file, replaces its rows in docs.DocumentChunks, and marks the document Ready (or Failed, with the reason).
  4. On each chat message the web app embeds the question and asks Azure SQL for the nearest chunks with VECTOR_DISTANCE. The matches go to the chat model as delimited, numbered sources.
  5. When the model calls generate_image, the image is saved to generated-images and served back through the web app. The Listen button sends an answer to text-to-speech.
  6. The mic button records a spoken question, transcribes it, and sends the text as an ordinary chat message, then reads the answer aloud. It's turn-based: one recording per question, not a live conversation.

Security posture

  • No public data plane. AI Services, SQL, Key Vault and both storage accounts have public network access disabled and are reachable only through private endpoints in snet-pe.
  • No keys. AI Services has local (key) auth disabled, storage has shared-key access disabled, and BannedSymbols.txt turns any API-key credential in the code into a build error. Apps authenticate with their managed identities.
  • One secret, in Key Vault. The SQL connection string lives in a private Key Vault. The apps get a @Microsoft.KeyVault(...) reference, and the password is seeded once from a GitHub secret, never from a param file.
  • Locked-down function app. Inbound traffic is denied by default, except for the Event Grid service tag. The deployment (SCM) endpoint is closed, and Set-FunctionDeployAccess.ps1 opens it only for the length of a publish.
  • Role-gated app. Anyone can register, but a new account sees nothing until an admin grants the User role.
  • Spend control. Per-user, per-minute rate limits on chat, speech and uploads, plus per-user daily caps on chat tokens, images, speech and spoken questions, counted in SQL (UsageLimits in appsettings.json).
  • Least-privilege deployment. The deployment principal can't assign roles. Role assignments are a separate, reviewed step (iac/RBAC-SETUP.md).

Getting started

  1. Change the globally unique names in iac/main.bicepparam.
  2. Set up GitHub-to-Azure sign-in with iac/OIDC-SETUP.md.
  3. Run Deploy infrastructure from the Actions tab.
  4. Apply the role assignments with iac/scripts/Set-WorkloadRbac.ps1, then verify with iac/scripts/Test-WorkloadDeployment.ps1.
  5. Run Deploy web app first (it creates the database tables on startup), then Deploy function app. The first function deploy in an environment also runs Deploy infrastructure again, to create the Event Grid subscription that connects uploads to ingestion; Event Grid refuses to create it until the function exists.
  6. Open the web app and sign in as the seeded admin, checkov@starfleet.com / NuclearWessels#1!. Create a second admin, then change this password or disable the account; it is in the source.
  7. People who register (the confirmation link is shown on screen, because no email sender is configured) get access once you give them the User role on the Admin tab.

The vector column needs Azure SQL or SQL Server 2025, so the app's migrations don't run against LocalDB.

To build locally:

dotnet build CreatingAnEnterpriseAISolution.slnx
dotnet test CreatingAnEnterpriseAISolution.slnx

License

MIT. See LICENSE.

About

This repo is the home base for two talks: Building an Enterprise Chat GPT and Securing Your Azure AI Workload

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages