Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Arcus.Templates.AzureFunctions.Http/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"IsEncrypted": false,
"Values": {
//#if(Isolated)
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
//#else
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
//#endif
//#if (Serilog_AppInsights)
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=<key>",
//#endif
"AzureWebJobsStorage": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ protected override ProcessStartInfo PrepareProjectRun(
};
Logger.WriteLine("> {0} {1}", processInfo.FileName, processInfo.Arguments);

Environment.SetEnvironmentVariable(ApplicationInsightsConnectionStringKeyVariable, $"InstrumentationKey={ApplicationInsightsConfig.InstrumentationKey}");
return processInfo;
}

Expand Down Expand Up @@ -164,14 +163,5 @@ await Policy.TimeoutAsync(TimeSpan.FromSeconds(30))
+ "please check any build or runtime errors that could occur when the test project was created");
}
}

/// <summary>
/// Performs additional application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <param name="disposing">The flag indicating whether or not the additional tasks should be disposed.</param>
protected override void Disposing(bool disposing)
{
Environment.SetEnvironmentVariable(ApplicationInsightsConnectionStringKeyVariable, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ protected override ProcessStartInfo PrepareProjectRun(
Environment.SetEnvironmentVariable(ApplicationInsightsMetricNameVariable, ApplicationInsightsConfig.MetricName);
Environment.SetEnvironmentVariable(DatabricksUrlVariable, AzureFunctionDatabricksConfig.BaseUrl);

ApplicationInsightsConfig appInsightsConfig = Configuration.GetApplicationInsightsConfig();
Environment.SetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING", $"InstrumentationKey={appInsightsConfig.InstrumentationKey}");

return startInfo;
}

Expand All @@ -143,6 +146,7 @@ protected override void Disposing(bool disposing)
base.Disposing(disposing);
Environment.SetEnvironmentVariable(ApplicationInsightsMetricNameVariable, null);
Environment.SetEnvironmentVariable(DatabricksUrlVariable, null);
Environment.SetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING", null);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Arcus.Templates.Tests.Integration.AzureFunctions.Databricks.JobMetrics.Configuration;
using Arcus.Templates.Tests.Integration.Fixture;
using Arcus.Templates.Tests.Integration.Worker.Configuration;
using Arcus.Templates.Tests.Integration.Worker.EventHubs;
Expand Down Expand Up @@ -132,6 +133,9 @@ private async Task StartAsync()
Environment.SetEnvironmentVariable("EVENTGRID_TOPIC_URI", eventGridConfig.TopicUri);
Environment.SetEnvironmentVariable("EVENTGRID_AUTH_KEY", eventGridConfig.AuthenticationKey);

ApplicationInsightsConfig appInsightsConfig = Configuration.GetApplicationInsightsConfig();
Environment.SetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING", $"InstrumentationKey={appInsightsConfig.InstrumentationKey}");

Run(Configuration.BuildConfiguration, TargetFramework.Net6_0);
await MessagePump.StartAsync();
}
Expand All @@ -145,6 +149,7 @@ public async ValueTask DisposeAsync()
Environment.SetEnvironmentVariable("EventHubsConnectionString", null);
Environment.SetEnvironmentVariable("EVENTGRID_TOPIC_URI", null);
Environment.SetEnvironmentVariable("EVENTGRID_AUTH_KEY", null);
Environment.SetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING", null);

Dispose();
await MessagePump.DisposeAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using GuardNet;
using Polly.Retry;
using Polly;
using Xunit;
using Xunit.Abstractions;

namespace Arcus.Templates.Tests.Integration.AzureFunctions.Http
Expand Down Expand Up @@ -208,8 +209,18 @@ public static AzureFunctionsHttpProject CreateNew(TestConfig configuration, Azur

var project = new AzureFunctionsHttpProject(configuration, options, outputWriter);
project.CreateNewProject(options);
project.AddLocalSettings(options.FunctionsWorker);

project.UpdateFileInProject(
"local.settings.json",
contents =>
{
var json = JsonObject.Parse(contents);
json["Host"] = new JsonObject(new[]
{
new KeyValuePair<string, JsonNode>("LocalHttpPort", project.RootEndpoint.Port)
});

return json.ToString();
});
project.UpdateFileInProject(project.RuntimeFileName, contents => project.RemovesUserErrorsFromContents(contents));

return project;
Expand Down