diff --git a/Controllers/AppController.cs b/Controllers/AppController.cs index a06567a..3a44c92 100644 --- a/Controllers/AppController.cs +++ b/Controllers/AppController.cs @@ -83,7 +83,11 @@ public ActionResult sayhello() var connectionString = app.GetConnectionString("StorageAccount"); if (string.IsNullOrEmpty(connectionString)) { - throw new InvalidOperationException("Storage account connection string is not configured."); + return BadRequest(new { + error = "Storage account connection string is not configured.", + details = "Please configure the 'StorageAccount' connection string in app settings or appsettings.json", + configurationKey = "ConnectionStrings:StorageAccount" + }); } try @@ -94,7 +98,11 @@ public ActionResult sayhello() } catch (Exception ex) { - throw new InvalidOperationException($"Failed to connect to storage account: {ex.Message}", ex); + return StatusCode(500, new { + error = "Failed to connect to storage account", + details = ex.Message, + connectionString = connectionString.Length > 20 ? connectionString.Substring(0, 20) + "..." : connectionString + }); } } diff --git a/appsettings.Development.json b/appsettings.Development.json index 0c208ae..0b5f1ba 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -4,5 +4,8 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "ConnectionStrings": { + "StorageAccount": "UseDevelopmentStorage=true" } }