diff --git a/durablefunctionsmonitor.dotnetbackend/Common/Auth.cs b/durablefunctionsmonitor.dotnetbackend/Common/Auth.cs index 0b1d965..35b4fba 100644 --- a/durablefunctionsmonitor.dotnetbackend/Common/Auth.cs +++ b/durablefunctionsmonitor.dotnetbackend/Common/Auth.cs @@ -204,7 +204,7 @@ public static async Task> GetAllowedTaskHubNamesAsync() try { var hubNames = new HashSet( - await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(EnvVariableNames.AzureWebJobsStorage), + await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(DfmEndpoint.StorageConnStringEnvVarName), StringComparer.InvariantCultureIgnoreCase ); diff --git a/durablefunctionsmonitor.dotnetbackend/Common/Globals.cs b/durablefunctionsmonitor.dotnetbackend/Common/Globals.cs index 5366080..5e028a7 100644 --- a/durablefunctionsmonitor.dotnetbackend/Common/Globals.cs +++ b/durablefunctionsmonitor.dotnetbackend/Common/Globals.cs @@ -100,7 +100,7 @@ public static string GetFullConnectionStringEnvVariableName(string connName) { if (IsDefaultConnectionStringName(connName)) { - return EnvVariableNames.AzureWebJobsStorage; + return DfmEndpoint.StorageConnStringEnvVarName; } else { diff --git a/durablefunctionsmonitor.dotnetbackend/Common/Setup.cs b/durablefunctionsmonitor.dotnetbackend/Common/Setup.cs index bdf1e9f..a16b61f 100644 --- a/durablefunctionsmonitor.dotnetbackend/Common/Setup.cs +++ b/durablefunctionsmonitor.dotnetbackend/Common/Setup.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.Azure.WebJobs.Extensions.DurableTask; +using Newtonsoft.Json.Linq; namespace DurableFunctionsMonitor.DotNetBackend { @@ -185,6 +186,22 @@ public static void Setup(DfmSettings settings = null, DfmExtensionPoints extensi { _customUserAgent = $"DurableFunctionsMonitor-Injected/{GetVersion()}"; } + + // Checking host.json for a custom dedicated Storage account + string hostJsonFileName = Globals.GetHostJsonPath(); + if (File.Exists(hostJsonFileName)) + { + dynamic hostJson = JObject.Parse(File.ReadAllText(hostJsonFileName)); + + string connStringNameFromHostJson = + hostJson?.extensions?.durableTask?.storageProvider?.azureStorageConnectionStringName ?? + hostJson?.extensions?.durableTask?.storageProvider?.connectionStringName; + + if (!string.IsNullOrEmpty(connStringNameFromHostJson)) + { + _storageConnStringEnvVarName = connStringNameFromHostJson; + } + } } internal static DfmSettings Settings @@ -220,9 +237,18 @@ internal static string CustomUserAgent get { return _customUserAgent; } } + /// + /// Provides support for dedicated Storage accounts (different from AzureWebJobsStorage) + /// + internal static string StorageConnStringEnvVarName + { + get { return _storageConnStringEnvVarName; } + } + private static DfmSettings _settings = null; private static DfmExtensionPoints _extensionPoints = new DfmExtensionPoints(); private static string _customUserAgent; + private static string _storageConnStringEnvVarName = EnvVariableNames.AzureWebJobsStorage; /// /// Checks whether we should do our internal initialization (Standalone mode) diff --git a/durablefunctionsmonitor.dotnetbackend/Functions/TaskHubNames.cs b/durablefunctionsmonitor.dotnetbackend/Functions/TaskHubNames.cs index 0086433..4a365d9 100644 --- a/durablefunctionsmonitor.dotnetbackend/Functions/TaskHubNames.cs +++ b/durablefunctionsmonitor.dotnetbackend/Functions/TaskHubNames.cs @@ -30,7 +30,7 @@ ILogger log if (!string.IsNullOrEmpty(dfmNonce)) { // For VsCode loading Task Hubs directly and without validation - hubNames = await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(EnvVariableNames.AzureWebJobsStorage); + hubNames = await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(DfmEndpoint.StorageConnStringEnvVarName); } else {