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
20 changes: 12 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "Azure AI Proxy",
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// See https://containers.dev/implementors/features/
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:latest": {},
"ghcr.io/azure/azure-dev/azd:latest": {},
"ghcr.io/devcontainers/features/node": {},
"ghcr.io/devcontainers/features/dotnet:2": {
Expand Down Expand Up @@ -47,16 +46,21 @@

"portsAttributes": {
"8000": {
"label": "AzureAIProxy"
"label": "Proxy (http)"
},
"7177": {
"label": "Proxy (https)"
},
"5175": {
"label": "Admin"
"label": "Admin (http)"
},
"5173": {
"label": "Playground (internal)"
"7191": {
"label": "Admin (https)"
},
"4280": {
"label": "Playgroud (SWA proxy)"
}
}
},

"forwardPorts": [8000, 7177, 5175, 7191, 4280]
}
22 changes: 0 additions & 22 deletions .devcontainer/docker-compose.yml

This file was deleted.

25 changes: 8 additions & 17 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
#!/bin/bash

echo setting up postgresql...
echo Setting up .NET environment...

# install postgresql client
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/postgresql.gpg >/dev/null
sudo dotnet workload install aspire
dotnet tool update -g linux-dev-certs
dotnet linux-dev-certs install

sudo apt-get update
sudo apt install postgresql-client -y
dotnet restore src/AzureAIProxy.sln

psql -U admin -d aoai-proxy -h localhost -w -c 'CREATE ROLE azure_pg_admin WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;'

psql -U admin -d aoai-proxy -h localhost -w -c 'CREATE ROLE aoai_proxy_app WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;'

psql -U admin -d aoai-proxy -h localhost -w -c 'CREATE ROLE aoai_proxy_reporting WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;'

psql -U admin -d aoai-proxy -h localhost -w -c 'GRANT aoai_proxy_app TO azure_pg_admin;'
psql -U admin -d aoai-proxy -h localhost -w -c 'GRANT aoai_proxy_reporting TO azure_pg_admin;'


psql -U admin -d aoai-proxy -h localhost -w -f ./database/aoai-proxy.sql
dotnet user-secrets set "POSTGRES_ENCRYPTION_KEY" myencryptionkey123 --project src/AzureAIProxy.AppHost
dotnet user-secrets set "Parameters:pg-password" "mypassword123" --project src/AzureAIProxy.AppHost

echo Setting up Python environment...

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dotnet-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Aspire workload
run: dotnet workload install aspire
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ appsettings.*.json
*.csproj.user
.mono
*.user
.vs

# AZD
.azure/
60 changes: 2 additions & 58 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "Playground",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/src/playground",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"preLaunchTask": "npm: install"
},
{
"type": "node-terminal",
"name": "SWA Playground",
"request": "launch",
"command": "swa start playground",
"cwd": "${workspaceFolder}"
},
{
"name": "Management UI",
"name": "Aspire",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/src/AzureAIProxy.Management/AzureAIProxy.Management.csproj"
},
{
"name": "AzureAIProxy",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/src/AzureAIProxy/AzureAIProxy.csproj"
}
],
"compounds": [
{
"name": "Run all",
"configurations": [
"AzureAIProxy",
"Playground",
"SWA Playground",
"Management UI"
],
"presentation": {
"hidden": false,
"group": "Frontend",
"order": 1
}
},
{
"name": "Admin",
"configurations": ["AzureAIProxy", "Management UI"],
"presentation": {
"hidden": false,
"group": "Frontend",
"order": 1
}
},
{
"name": "End user",
"configurations": ["AzureAIProxy", "Playground", "SWA Playground"],
"presentation": {
"hidden": false,
"group": "Frontend",
"order": 1
}
"projectPath": "${workspaceFolder}/src/AzureAIProxy.AppHost/AzureAIProxy.AppHost.csproj"
}
]
}
18 changes: 12 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@
"-t",
"azureai-proxy",
"-f",
"${workspaceFolder}/src/Dockerfile.proxy",
"${workspaceFolder}/src"
"../Dockerfile.proxy",
"../../"
],
"problemMatcher": ["$msCompile"]
"problemMatcher": ["$msCompile"],
"options": {
"cwd": "${workspaceFolder}/src/AzureAIProxy"
}
},
{
"label": "docker build: managment",
Expand All @@ -76,10 +79,13 @@
"-t",
"azureai-proxy",
"-f",
"${workspaceFolder}/src/Dockerfile.management",
"${workspaceFolder}/src"
"../Dockerfile.management",
"../../"
],
"problemMatcher": ["$msCompile"]
"problemMatcher": ["$msCompile"],
"options": {
"cwd": "${workspaceFolder}/src/AzureAIProxy.Management"
}
}
]
}
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
40 changes: 40 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<AspireVersion>8.1.0</AspireVersion>
<AspNetVersion>8.0.0</AspNetVersion>
<AuthVersion>2.20.0</AuthVersion>
<OpenTelemetryVersion>1.9.0</OpenTelemetryVersion>
</PropertyGroup>
<ItemGroup>
<!-- Aspire Hosting -->
<PackageVersion Include="Aspire.Hosting" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.NodeJs" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="$(AspireVersion)" />

<!-- Aspire Components -->
<PackageVersion Include="Aspire.Npgsql" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(AspireVersion)" />

<!-- ASP.NET -->
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetVersion)" />
<PackageVersion Include="Microsoft.Identity.Web" Version="$(AuthVersion)" />
<PackageVersion Include="Microsoft.Identity.Web.UI" Version="$(AuthVersion)" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="$(AspireVersion)" />

<!-- Blazor -->
<PackageVersion Include="MudBlazor" Version="6.19.1" />

<!-- OpenTelemetry -->
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="$(OpenTelemetryVersion)" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
host: containerapp
docker:
path: ../Dockerfile.proxy
context: ../
context: ../../
platform: amd64

playground:
Expand All @@ -29,7 +29,7 @@ services:
run: ../../infra/scripts/setup-app-redirect-uris.sh
docker:
path: ../Dockerfile.management
context: ../
context: ../../
platform: amd64

hooks:
Expand Down
5 changes: 5 additions & 0 deletions database/aoai-proxy-dev.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE ROLE azure_pg_admin WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
CREATE ROLE aoai_proxy_app WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
CREATE ROLE aoai_proxy_reporting WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
GRANT aoai_proxy_app TO azure_pg_admin;
GRANT aoai_proxy_reporting TO azure_pg_admin;
21 changes: 21 additions & 0 deletions src/AzureAIProxy.AppHost/AzureAIProxy.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>be2fdb12-16bf-4246-ae61-2bbb16df2a8b</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting.NodeJs" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AzureAIProxy.Aspire.Components\AzureAIProxy.Aspire.Components.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\AzureAIProxy\AzureAIProxy.csproj" />
<ProjectReference Include="..\AzureAIProxy.Management\AzureAIProxy.Management.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions src/AzureAIProxy.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using AzureAIProxy.Aspire.Components;

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("pg")
.WithBindMount("../../database/aoai-proxy-dev.sql", "/docker-entrypoint-initdb.d/01-aoai-proxy.sql")
.WithBindMount("../../database/aoai-proxy.sql", "/docker-entrypoint-initdb.d/02-aoai-proxy.sql")
.WithDataVolume()
.WithPgAdmin();

var db = postgres.AddDatabase("postgres");

var proxy = builder.AddProject<Projects.AzureAIProxy>("proxy")
.WithReference(db)
.WithExternalHttpEndpoints();

var playground = builder.AddNpmApp("playground", "../playground", scriptName: "dev")
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints();

_ = builder.AddProject<Projects.AzureAIProxy_Management>("admin")
.WithReference(playground)
.WithReference(db)
.WithEnvironment("AzureAd:TenantId", builder.Configuration["AzureAd:TenantId"])
.WithEnvironment("AzureAd:ClientId", builder.Configuration["AzureAd:ClientId"])
.WithExternalHttpEndpoints();

_ = builder.AddSwaEmulator("swa")
.WithAppResource(playground)
.WithApiResource(proxy);

builder.Build().Run();
29 changes: 29 additions & 0 deletions src/AzureAIProxy.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17030;http://localhost:15150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21043",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22021"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15150",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19060",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20276"
}
}
}
}
9 changes: 9 additions & 0 deletions src/AzureAIProxy.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

</Project>
Loading