Azure Blob Storage Configuration - Quick Reference
๐ฏ Key Principleโ
EpanetConsoleCore NEVER uses appsettings.json for Azure configuration.
All Azure Blob Storage configuration MUST be passed via command-line arguments.
โ Correct Setupโ
API appsettings.jsonโ
{
"InputFileStorage": {
"ContainerName": "dwd-input-files-mtw",
"AzureBlob": {
"ServiceUrl": "https://yourstorageaccount.blob.core.windows.net",
"ContainerSasToken": "sv=2023-01-03&ss=b&srt=c&sp=rwdlac&se=2026-12-31T23:59:59Z&..."
}
},
"ConnectionStrings": {
"PSQLDB": "Host=localhost;Port=5432;Database=your_db;..."
},
"EpanetConsoleCore": {
"Path": "C:\\path\\to\\EpanetConsoleCore.exe"
}
}
API Automatically Launches Console Coreโ
When the API starts a scenario, it automatically passes Azure config:
EpanetConsoleCore.exe "Host=localhost;..." 1 \
--azure-url "https://account.blob.core.windows.net" \
--azure-sas "sv=2023..." \
--container "dwd-input-files-mtw"
You don't need to do anything manually - the API handles this!
โ What Happens If Config Is Missing?โ
If you try to run a scenario that uses Azure Blob Storage without passing the required command-line arguments, EpanetConsoleCore will fail immediately with this error:
โ AZURE BLOB STORAGE CONFIGURATION MISSING
This scenario uses Azure Blob Storage (StorageProvider=AzureBlob),
but required command-line arguments are missing:
โข --azure-url
โข --azure-sas
โข --container
EpanetConsoleCore must be launched with Azure configuration:
EpanetConsoleCore.exe "<connection-string>" <scenario-id> \
--azure-url "https://account.blob.core.windows.net" \
--azure-sas "sv=2023..." \
--container "dwd-input-files-mtw"
๐ก Note: This is a shared executable serving multiple networks.
Configuration MUST be passed via command-line arguments, not appsettings.json.
This is intentional! It prevents silent failures where the wrong network's configuration is used.
๐ง Command-Line Arguments Referenceโ
| Argument | Required | Description | Example |
|---|---|---|---|
| Positional 1 | โ Yes | Database connection string | "Host=localhost;Port=5432;Database=mtw;..." |
| Positional 2 | โ Yes | Scenario ID | 1 |
--azure-url | โ ๏ธ If Azure | Azure Blob Storage service URL | "https://account.blob.core.windows.net" |
--azure-sas | โ ๏ธ If Azure | Container-scoped SAS token | "sv=2023-01-03&ss=b&srt=c&sp=rl&..." |
--container | โ ๏ธ If Azure | Container name | "dwd-input-files-mtw" |
--save-inp | โ No | Export INP file path (no simulation) | "C:\output\scenario_1.inp" |
"If Azure" means: Required only if the scenario's InputFile.StorageProvider = AzureBlob
๐ SAS Token Permissionsโ
API Token (Read + Write)โ
- Permissions:
rwdlac(Read, Write, Delete, List, Add, Create) - Use: Upload, download, delete files
- Where: API's
appsettings.json
Console Core Token (Read-Only)โ
- Permissions:
rl(Read, List) - Use: Download files only
- Where: Passed via command-line by API
Best Practice: Use the same token (with rwdlac) for both API and Console Core for simplicity. The API will pass it to Console Core automatically.
๐งช Testing Checklistโ
- โ
Configure API's
appsettings.jsonwith Azure settings - โ Restart API
- โ Upload a file via frontend (tests API โ Azure)
- โ Create scenario using uploaded file
- โ Start scenario (tests API โ Console Core โ Azure)
- โ Verify in Azure Portal that file exists
- โ Check logs for successful download message
๐จ Common Mistakesโ
โ Creating appsettings.json in EpanetConsoleCore directoryโ
Problem: Someone creates an appsettings.json in the EpanetConsoleCore published directory thinking it will be used.
Result: File is ignored. Console Core ONLY uses command-line arguments.
Solution: Configure API's appsettings.json instead. The API will pass config to Console Core.
โ Forgetting to restart API after updating configโ
Problem: Update API's appsettings.json but don't restart the API.
Result: API still uses old configuration.
Solution: Always restart the API after changing appsettings.json.
โ Using account key instead of SAS tokenโ
Problem: Configure AccountKey instead of ContainerSasToken.
Result: Works initially, but violates security best practices. Account keys have full access to ALL containers.
Solution: Always use container-scoped SAS tokens with minimal required permissions.
๐ฏ Multi-Instance Deploymentโ
Each network instance should have:
- Its own API with its own
appsettings.json - Its own Azure container (e.g.,
dwd-input-files-mtw,dwd-input-files-xyz) - Its own container-scoped SAS token
All instances can share:
- The same EpanetConsoleCore.exe (published once)
- The same database server (different databases)
- The same Azure Storage Account (different containers)
Example:
- MTW: API config points to
dwd-input-files-mtwwith Token A - XYZ: API config points to
dwd-input-files-xyzwith Token B - Both: Use the same
EpanetConsoleCore.exepublished atC:\Apps\EpanetConsoleCore\
Each API passes its own Azure configuration to the shared executable via command-line arguments!
๐ Full Documentationโ
For detailed information, see: _docs/azure_blob_storage_configuration.md