Skip to content

Commit

Permalink
#217, implementation for inproc
Browse files Browse the repository at this point in the history
  • Loading branch information
scale-tone committed Nov 2, 2024
1 parent 9a99d06 commit a6218c6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion durablefunctionsmonitor.dotnetbackend/Common/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static async Task<HashSet<string>> GetAllowedTaskHubNamesAsync()
try
{
var hubNames = new HashSet<string>(
await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(EnvVariableNames.AzureWebJobsStorage),
await DfmEndpoint.ExtensionPoints.GetTaskHubNamesRoutine(DfmEndpoint.StorageConnStringEnvVarName),
StringComparer.InvariantCultureIgnoreCase
);

Expand Down
2 changes: 1 addition & 1 deletion durablefunctionsmonitor.dotnetbackend/Common/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static string GetFullConnectionStringEnvVariableName(string connName)
{
if (IsDefaultConnectionStringName(connName))
{
return EnvVariableNames.AzureWebJobsStorage;
return DfmEndpoint.StorageConnStringEnvVarName;
}
else
{
Expand Down
26 changes: 26 additions & 0 deletions durablefunctionsmonitor.dotnetbackend/Common/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Newtonsoft.Json.Linq;

namespace DurableFunctionsMonitor.DotNetBackend
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -220,9 +237,18 @@ internal static string CustomUserAgent
get { return _customUserAgent; }
}

/// <summary>
/// Provides support for dedicated Storage accounts (different from AzureWebJobsStorage)
/// </summary>
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;

/// <summary>
/// Checks whether we should do our internal initialization (Standalone mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit a6218c6

Please sign in to comment.