feat(azure): allow reusing existing Storage Account via storageAccountName param

- infra.bicep: add storageAccountName param (empty = auto-generate
  '${projectName}store'); effectiveStorageAccountName var resolves the
  final name; Bicep reconciles the existing account idempotently without
  touching other file shares (caddydata, neo4jdata, etc.)
- 1-infra.sh: forward STORAGE_ACCOUNT_NAME (optional) to Bicep
- config.sh.example: document Opció A (existing account, e.g. stgraphiti16852)
  vs Opció B (new account); clarify which vars are inputs vs outputs of 1-infra.sh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-05-05 07:33:30 +00:00
parent 842cf09a10
commit 9ee3dc1d59
3 changed files with 22 additions and 9 deletions

View File

@ -88,6 +88,7 @@ INFRA_OUTPUT=$(az deployment group create \
postgresAdminPassword="$POSTGRES_ADMIN_PASSWORD" \
postgresAdminUser="${POSTGRES_ADMIN_USER:-mirofish}" \
postgresSku="${POSTGRES_SKU:-B_Standard_B1ms}" \
storageAccountName="${STORAGE_ACCOUNT_NAME:-}" \
--output json)
# Extreure outputs del desplegament

View File

@ -81,17 +81,22 @@ POSTGRES_ADMIN_USER="mirofish"
# SKU de PostgreSQL: B_Standard_B1ms (dev/test) | GP_Standard_D2s_v3 (producció)
POSTGRES_SKU="B_Standard_B1ms"
# ── Storage (generats per 1-infra.sh — afegir després d'executar-lo) ─────────
# ── Storage ───────────────────────────────────────────────────────────────────
# Opció A — Compte existent (ex: stgraphiti16852 que ja té caddydata, neo4jdata)
# Deixar STORAGE_ACCOUNT_NAME amb el nom del compte existent.
# 1-infra.sh el reconciliarà sense esborrar els shares existents.
# Opció B — Compte nou (1-infra.sh el crea automàticament com a ${PROJECT_NAME}store)
# Deixar STORAGE_ACCOUNT_NAME buit.
STORAGE_ACCOUNT_NAME="stgraphiti16852" # canvia o deixa buit per crear-ne un de nou
# Nom del File Share per a MiroFish (es crea si no existeix)
FILE_SHARE_NAME="mirofish-uploads"
# ── Storage (valors generats per 1-infra.sh — afegir-los després d'executar-lo) ─
# Connection string d'Azure Files (output de 1-infra.sh)
# Format: DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net
STORAGE_CONNECTION_STRING="<output-de-1-infra.sh>"
# Nom del Storage Account (output de 1-infra.sh)
STORAGE_ACCOUNT_NAME="<output-de-1-infra.sh>"
# Nom del File Share (per defecte: mirofish-uploads)
FILE_SHARE_NAME="mirofish-uploads"
# DATABASE_URL PostgreSQL (output de 1-infra.sh)
# Format: postgresql+psycopg2://mirofish:<password>@<host>/mirofish?sslmode=require
DATABASE_URL="<output-de-1-infra.sh>"

View File

@ -26,6 +26,12 @@ param postgresAdminUser string = 'mirofish'
@description('SKU de PostgreSQL (B_Standard_B1ms per dev; GP_Standard_D2s_v3 per pro)')
param postgresSku string = 'B_Standard_B1ms'
@description('Nom del Storage Account existent (o buit per crear-ne un de nou: ${projectName}store)')
param storageAccountName string = ''
// Nom efectiu: el paràmetre si s'especifica, sinó el nom generat
var effectiveStorageAccountName = empty(storageAccountName) ? '${replace(projectName, \'-\', \'\')}store' : storageAccountName
// ─── Azure Container Registry ─────────────────────────────────────────────────
resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
name: '${projectName}acr'
@ -65,9 +71,10 @@ resource envStorage 'Microsoft.App/managedEnvironments/storages@2023-05-01' = {
// Azure Files és necessari per a:
// - uploads/simulations/ (SQLite DBs, JSONL, IPC files de les simulacions OASIS)
// - uploads/projects/ (fitxers pujats per l'usuari)
// Standard LRS: suficient per a escenaris non-HA
// Si storageAccountName apunta a un compte existent, Bicep el reconcilia sense
// esborrar els File Shares existents (caddydata, neo4jdata, etc.).
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: '${replace(projectName, '-', '')}store' // sense guions, màx 24 chars
name: effectiveStorageAccountName
location: location
sku: { name: 'Standard_LRS' }
kind: 'StorageV2'