Skip to main content

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โ€‹

ArgumentRequiredDescriptionExample
Positional 1โœ… YesDatabase connection string"Host=localhost;Port=5432;Database=mtw;..."
Positional 2โœ… YesScenario ID1
--azure-urlโš ๏ธ If AzureAzure Blob Storage service URL"https://account.blob.core.windows.net"
--azure-sasโš ๏ธ If AzureContainer-scoped SAS token"sv=2023-01-03&ss=b&srt=c&sp=rl&..."
--containerโš ๏ธ If AzureContainer name"dwd-input-files-mtw"
--save-inpโŒ NoExport 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โ€‹

  1. โœ… Configure API's appsettings.json with Azure settings
  2. โœ… Restart API
  3. โœ… Upload a file via frontend (tests API โ†’ Azure)
  4. โœ… Create scenario using uploaded file
  5. โœ… Start scenario (tests API โ†’ Console Core โ†’ Azure)
  6. โœ… Verify in Azure Portal that file exists
  7. โœ… 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:

  1. Its own API with its own appsettings.json
  2. Its own Azure container (e.g., dwd-input-files-mtw, dwd-input-files-xyz)
  3. Its own container-scoped SAS token

All instances can share:

  1. The same EpanetConsoleCore.exe (published once)
  2. The same database server (different databases)
  3. The same Azure Storage Account (different containers)

Example:

  • MTW: API config points to dwd-input-files-mtw with Token A
  • XYZ: API config points to dwd-input-files-xyz with Token B
  • Both: Use the same EpanetConsoleCore.exe published at C:\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