Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,26 @@ This project provides the following features:

![Screenshot of chat app with question about climbing gear](docs/images/screenshot_chat.png)

## Architecture diagram
## Architecture

The deployed app uses a user-assigned managed identity to authenticate to Azure services, and stores logs in Log Analytics.

![Architecture diagram: Azure Container Apps, Azure Container Registry, Managed Identity, Azure OpenAI, Azure Database for PostgreSQL](docs/images/azure_architecture.png)

## Prerequisites

To use this template, you'll need:

* [Azure Developer CLI (azd)](https://aka.ms/install-azd)
* [Node.js 18+](https://nodejs.org/download/)
* [Python 3.10+](https://www.python.org/downloads/)
* [PostgreSQL 14+](https://www.postgresql.org/download/) (for local development)
* [pgvector](https://github.com/pgvector/pgvector) (PostgreSQL extension)
* [Docker Desktop](https://www.docker.com/products/docker-desktop/)
* [Git](https://git-scm.com/downloads)

An Azure subscription is required for deployment.

## Getting started

You have a few options for getting started with this template.
Expand Down
10 changes: 9 additions & 1 deletion infra/backend-dashboard.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates a dashboard for an Application Insights instance.'


@metadata({
description: 'Creates a dashboard for an Application Insights instance.'
requiredResources: [
'Microsoft.Portal/dashboards'
]
})

param name string
param applicationInsightsName string
param location string = resourceGroup().location
Expand Down
16 changes: 16 additions & 0 deletions infra/core/ai/ai-foundry.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@



@metadata({
description: 'Creates an Azure AI Foundry resource with projects and connections.'
requiredResources: [

'Microsoft.CognitiveServices/accounts'
'Microsoft.CognitiveServices/accounts/projects'
'Microsoft.Storage/storageAccounts'
'Microsoft.CognitiveServices/accounts/connections'
'Microsoft.Authorization/roleAssignments'

]
})

@minLength(1)
@description('Primary location for all resources')
param location string
Expand Down
10 changes: 9 additions & 1 deletion infra/core/ai/cognitiveservices.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates an Azure Cognitive Services instance.'


@metadata({
description: 'Creates an Azure Cognitive Services instance.'
requiredResources: [
'Microsoft.CognitiveServices/accounts'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
16 changes: 16 additions & 0 deletions infra/core/database/postgresql/flexibleserver.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@



@metadata({
description: 'Creates an Azure Database for PostgreSQL Flexible Server.'
requiredResources: [

'Microsoft.DBforPostgreSQL/flexibleServers'
'Microsoft.DBforPostgreSQL/flexibleServers/databases'
'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules'
'Microsoft.DBforPostgreSQL/flexibleServers/administrators'
'Microsoft.DBforPostgreSQL/flexibleServers/configurations'

]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
10 changes: 9 additions & 1 deletion infra/core/host/container-app-upsert.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates or updates an existing Azure Container App.'


@metadata({
description: 'Creates or updates an existing Azure Container App.'
requiredResources: [
'Microsoft.App/containerApps'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
10 changes: 9 additions & 1 deletion infra/core/host/container-app.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates a container app in an Azure Container App environment.'


@metadata({
description: 'Creates a container app in an Azure Container App environment.'
requiredResources: [
'Microsoft.App/containerApps'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
10 changes: 9 additions & 1 deletion infra/core/host/container-apps-environment.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates an Azure Container Apps environment.'


@metadata({
description: 'Creates an Azure Container Apps environment.'
requiredResources: [
'Microsoft.App/managedEnvironments'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
13 changes: 12 additions & 1 deletion infra/core/host/container-apps.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
metadata description = 'Creates an Azure Container Registry and an Azure Container Apps environment.'


@metadata({
description: 'Creates an Azure Container Registry and an Azure Container Apps environment.'
requiredResources: [

'Microsoft.ContainerRegistry/registries'
'Microsoft.App/managedEnvironments'

]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
13 changes: 12 additions & 1 deletion infra/core/host/container-registry.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
metadata description = 'Creates an Azure Container Registry.'


@metadata({
description: 'Creates an Azure Container Registry.'
requiredResources: [

'Microsoft.ContainerRegistry/registries'
'Microsoft.Insights/diagnosticSettings'

]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
10 changes: 9 additions & 1 deletion infra/core/monitor/applicationinsights.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates an Application Insights instance based on an existing Log Analytics workspace.'


@metadata({
description: 'Creates an Application Insights instance based on an existing Log Analytics workspace.'
requiredResources: [
'Microsoft.Insights/components'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
10 changes: 9 additions & 1 deletion infra/core/monitor/loganalytics.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates a Log Analytics workspace.'


@metadata({
description: 'Creates a Log Analytics workspace.'
requiredResources: [
'Microsoft.OperationalInsights/workspaces'
]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down
13 changes: 12 additions & 1 deletion infra/core/monitor/monitoring.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
metadata description = 'Creates an Application Insights instance and a Log Analytics workspace.'


@metadata({
description: 'Creates an Application Insights instance and a Log Analytics workspace.'
requiredResources: [

'Microsoft.OperationalInsights/workspaces'
'Microsoft.Insights/components'

]
})

param logAnalyticsName string
param applicationInsightsName string
param location string = resourceGroup().location
Expand Down
10 changes: 9 additions & 1 deletion infra/core/security/registry-access.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Assigns ACR Pull permissions to access an Azure Container Registry.'


@metadata({
description: 'Assigns ACR Pull permissions to access an Azure Container Registry.'
requiredResources: [
'Microsoft.Authorization/roleAssignments'
]
})

param containerRegistryName string
param principalId string

Expand Down
10 changes: 9 additions & 1 deletion infra/core/security/role.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
metadata description = 'Creates a role assignment for a service principal.'


@metadata({
description: 'Creates a role assignment for a service principal.'
requiredResources: [
'Microsoft.Authorization/roleAssignments'
]
})

param principalId string

@allowed([
Expand Down
28 changes: 23 additions & 5 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
targetScope = 'subscription'





@metadata({
description: 'Main deployment template for RAG PostgreSQL OpenAI application infrastructure.'
requiredResources: [

'Microsoft.Resources/resourceGroups'
'Microsoft.CognitiveServices/accounts'
'Microsoft.DBforPostgreSQL/flexibleServers'
'Microsoft.ContainerRegistry/registries'
'Microsoft.App/managedEnvironments'
'Microsoft.App/containerApps'
'Microsoft.OperationalInsights/workspaces'
'Microsoft.Insights/components'
'Microsoft.ManagedIdentity/userAssignedIdentities'
'Microsoft.Authorization/roleAssignments'

]
})

@minLength(1)
@maxLength(64)
@description('Name which is used to generate a short unique hash for each resource')
Expand Down Expand Up @@ -43,11 +65,7 @@ param principalId string = ''
'westus'
'westus3'
])
@metadata({
azd: {
type: 'location'
}
})

param openAILocation string

@description('Name of the OpenAI resource group. If not specified, the resource group name will be generated.')
Expand Down
13 changes: 13 additions & 0 deletions infra/web.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@



@metadata({
description: 'Creates a web container app with managed identity.'
requiredResources: [

'Microsoft.ManagedIdentity/userAssignedIdentities'
'Microsoft.App/containerApps'

]
})

param name string
param location string = resourceGroup().location
param tags object = {}
Expand Down