-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathsetup-secrets.ps1
More file actions
49 lines (36 loc) · 2.19 KB
/
Copy pathsetup-secrets.ps1
File metadata and controls
49 lines (36 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env pwsh
# setup-secrets.ps1 — Manually configure user secrets for all samples
# Use this if you already have an Azure OpenAI resource and don't want to use azd.
param(
[Parameter(Mandatory=$true)]
[string]$Endpoint,
[string]$Deployment = "gpt-5-mini",
[string]$EmbeddingDeployment = "text-embedding-3-small"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$secretsId = "genai-beginners-dotnet"
Write-Host "`n=== Generative AI for Beginners .NET — Secret Setup ===" -ForegroundColor Cyan
# Check prerequisites
if (-not (Get-Command "dotnet" -ErrorAction SilentlyContinue)) {
Write-Host "ERROR: 'dotnet' is not installed or not on PATH." -ForegroundColor Red
exit 1
}
Write-Host "Setting User Secrets (ID: $secretsId)..." -ForegroundColor Yellow
dotnet user-secrets set --id $secretsId "AzureOpenAI:Endpoint" $Endpoint
dotnet user-secrets set --id $secretsId "AzureOpenAI:Deployment" $Deployment
dotnet user-secrets set --id $secretsId "AzureOpenAI:EmbeddingDeployment" $EmbeddingDeployment
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host " User Secrets configured!" -ForegroundColor Green
Write-Host " Secrets ID: $secretsId" -ForegroundColor White
Write-Host " Endpoint: $Endpoint" -ForegroundColor White
Write-Host " Chat Model: $Deployment" -ForegroundColor White
Write-Host " Embedding: $EmbeddingDeployment" -ForegroundColor White
Write-Host "========================================`n" -ForegroundColor Cyan
Write-Host "For AI Foundry Agent samples, also run:" -ForegroundColor Yellow
Write-Host " dotnet user-secrets set --id $secretsId `"AIFoundry:Endpoint`" `"<your-foundry-endpoint>`""
Write-Host " dotnet user-secrets set --id $secretsId `"AIFoundry:TenantId`" `"<your-tenant-id>`""
Write-Host "`nFor Azure AI Search (RAG samples), also run:" -ForegroundColor Yellow
Write-Host " dotnet user-secrets set --id $secretsId `"AzureAISearch:Endpoint`" `"<your-search-endpoint>`""
Write-Host " dotnet user-secrets set --id $secretsId `"AzureAISearch:Key`" `"<your-search-key>`""
Write-Host "`nDone! Make sure to run 'az login' first, then run file-based samples with: dotnet run app.cs`n" -ForegroundColor Green