From 9ee3dc1d59ebbc1ba651b4ea482a4093f1590914 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 5 May 2026 07:33:30 +0000 Subject: [PATCH] feat(azure): allow reusing existing Storage Account via storageAccountName param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- azure/1-infra.sh | 1 + azure/config.sh.example | 19 ++++++++++++------- azure/infra.bicep | 11 +++++++++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/azure/1-infra.sh b/azure/1-infra.sh index 572a5df9..4e49400b 100755 --- a/azure/1-infra.sh +++ b/azure/1-infra.sh @@ -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 diff --git a/azure/config.sh.example b/azure/config.sh.example index 7361ae44..faf88bfd 100644 --- a/azure/config.sh.example +++ b/azure/config.sh.example @@ -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="" -# Nom del Storage Account (output de 1-infra.sh) -STORAGE_ACCOUNT_NAME="" - -# 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:@/mirofish?sslmode=require DATABASE_URL="" diff --git a/azure/infra.bicep b/azure/infra.bicep index 912f55d5..5270b165 100644 --- a/azure/infra.bicep +++ b/azure/infra.bicep @@ -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'