Skip to content

Commit d78312e

Browse files
committed
Updated many dependencies:
- Extensions from 6.0.0 to 9.0.9 - Azure Functions from 1.5ish to 2.0.5 - Added a test for Azure Function isolated mode
1 parent a674192 commit d78312e

File tree

47 files changed

+765
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+765
-157
lines changed

Cqrs.sln

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{42553B5E
152152
EndProject
153153
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cqrs.DependencyInjection.Azure.Tests.Unit", "Framework\DependencyInjection\Azure\Tests\Cqrs.DependencyInjection.Azure.Tests.Unit\Cqrs.DependencyInjection.Azure.Tests.Unit.csproj", "{6C8C843C-D380-49B3-A8A4-F0C2DC32EFED}"
154154
EndProject
155+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cqrs.Azure.Functions.Isolated.Test", "Framework\Azure\Tests\Cqrs.Azure.Functions.Isolated.Test\Cqrs.Azure.Functions.Isolated.Test.csproj", "{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}"
156+
EndProject
155157
Global
156158
GlobalSection(SolutionConfigurationPlatforms) = preSolution
157159
Debug|Any CPU = Debug|Any CPU
@@ -420,6 +422,12 @@ Global
420422
{6C8C843C-D380-49B3-A8A4-F0C2DC32EFED}.Release|Any CPU.Build.0 = Release|Any CPU
421423
{6C8C843C-D380-49B3-A8A4-F0C2DC32EFED}.VSIX|Any CPU.ActiveCfg = Debug|Any CPU
422424
{6C8C843C-D380-49B3-A8A4-F0C2DC32EFED}.VSIX|Any CPU.Build.0 = Debug|Any CPU
425+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
426+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.Debug|Any CPU.Build.0 = Debug|Any CPU
427+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.Release|Any CPU.ActiveCfg = Release|Any CPU
428+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.Release|Any CPU.Build.0 = Release|Any CPU
429+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.VSIX|Any CPU.ActiveCfg = Debug|Any CPU
430+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745}.VSIX|Any CPU.Build.0 = Debug|Any CPU
423431
EndGlobalSection
424432
GlobalSection(SolutionProperties) = preSolution
425433
HideSolutionNode = FALSE
@@ -480,11 +488,12 @@ Global
480488
{C5C86CE4-26EE-486A-B760-9195C17185BE} = {874648EE-72F0-4F25-BFD0-FDA65367DCC7}
481489
{42553B5E-EFF5-4323-BF49-C0A56EFD0D4D} = {E9CB4C43-83C3-44C8-A734-49EEF7EE3906}
482490
{6C8C843C-D380-49B3-A8A4-F0C2DC32EFED} = {42553B5E-EFF5-4323-BF49-C0A56EFD0D4D}
491+
{94AED0E9-D99D-4EB4-BBE2-4C9CF94D1745} = {016DAD01-ADF1-4B9D-9EBF-6A119ADC835D}
483492
EndGlobalSection
484493
GlobalSection(ExtensibilityGlobals) = postSolution
485-
SolutionGuid = {657FC3AE-4AFA-447D-B22B-D53587D334D1}
486-
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8
487494
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4;packages\Unity.Interception.2.1.505.2\lib\NET35;packages\Unity.2.1.505.0\lib\NET35;packages\Unity.Interception.2.1.505.0\lib\NET35;packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.WindowsAzure.TransientFaultHandling.5.1.1212.0\lib\NET4;packages\EnterpriseLibrary.WindowsAzure.TransientFaultHandling.5.1.1212.0\DesignTime;packages\TransientFaultHandling.Core.5.1.1209.0\lib\NET4
495+
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8
496+
SolutionGuid = {657FC3AE-4AFA-447D-B22B-D53587D334D1}
488497
EndGlobalSection
489498
GlobalSection(MonoDevelopProperties) = preSolution
490499
StartupItem = Sample\CQRSWeb\CQRSWeb.csproj

Framework/Azure/Cqrs.Azure.ConfigurationManager/Cqrs.Azure.ConfigurationManager.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
</PropertyGroup>
6060

6161
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
62-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
63-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
62+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.9" />
63+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.9" />
6464
</ItemGroup>
6565

6666
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
@@ -76,7 +76,7 @@
7676
<ItemGroup>
7777
<PackageReference Include="Chinchilla.StateManagement" Version="4.2.11" />
7878
<PackageReference Include="Chinchilla.Logging" Version="5.3.46" />
79-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
79+
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />
8080
</ItemGroup>
8181

8282
<ItemGroup>

Framework/Azure/Cqrs.Azure.ConfigurationManager/TelemetryCoreHost.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public abstract class TelemetryCoreHost<TAuthenticationToken> : CoreHost<TAuthen
2525
{
2626
#if NETSTANDARD2_0
2727
/// <summary>
28-
/// Gets or sets the <see cref="IConfigurationManager"/>. This must be set manually as dependency injection may not be ready in-time.
28+
/// Gets or sets the <see cref="Cqrs.Configuration.IConfigurationManager"/>. This must be set manually as dependency injection may not be ready in-time.
2929
/// </summary>
30-
protected static IConfigurationManager _configurationManager = null;
30+
protected static Cqrs.Configuration.IConfigurationManager _configurationManager = null;
3131

3232
/// <summary>
33-
/// Set the <see cref="IConfigurationManager"/> to use before the <see cref="DependencyResolver.Current"/> is set.
33+
/// Set the <see cref="Cqrs.Configuration.IConfigurationManager"/> to use before the <see cref="DependencyResolver.Current"/> is set.
3434
/// Will also set <see cref="DependencyResolver.ConfigurationManager"/>.
3535
/// </summary>
3636
/// <param name="configuration"></param>
@@ -49,9 +49,9 @@ public static void SetConfigurationManager(IConfigurationRoot configuration)
4949
#endif
5050

5151
/// <summary>
52-
/// The <see cref="IConfigurationManager"/> that can be use before the <see cref="DependencyResolver.Current"/> is set.
52+
/// The <see cref="Cqrs.Configuration.IConfigurationManager"/> that can be use before the <see cref="DependencyResolver.Current"/> is set.
5353
/// </summary>
54-
protected override IConfigurationManager ConfigurationManager
54+
protected override Cqrs.Configuration.IConfigurationManager ConfigurationManager
5555
{
5656
get { return _configurationManager ?? DependencyResolver.ConfigurationManager; }
5757
}

Framework/Azure/Cqrs.Azure.Functions.Isolated/Cqrs.Azure.Functions.Isolated.csproj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@
6464
<PackageReference Include="Chinchilla.Logging.Azure" Version="5.3.46" />
6565
<PackageReference Include="Chinchilla.Logging.Azure.ApplicationInsights" Version="5.3.46" />
6666

67-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
68-
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
69-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
70-
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
71-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.0" />
67+
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />
68+
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.23.0" />
69+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.1.0" />
70+
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" />
71+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.5" />
7272
</ItemGroup>
7373

7474
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
7575
<FrameworkReference Include="Microsoft.AspNetCore.App" />
7676

77-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
78-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
79-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
80-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
81-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
82-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
83-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
84-
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
77+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.9" />
78+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.9" />
79+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9" />
80+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9" />
81+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
82+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.9" />
83+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
84+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.9" />
8585
</ItemGroup>
8686

8787
<ItemGroup>

Framework/Azure/Cqrs.Azure.Functions.Isolated/CqrsIsolatedFunctionHost.cs

Lines changed: 90 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Extensions.Hosting;
2222
using Microsoft.Extensions.DependencyInjection;
2323
using Microsoft.Extensions.Logging;
24+
using Microsoft.Azure.Functions.Worker.Builder;
2425

2526
#if NET48
2627
#else
@@ -37,9 +38,20 @@ public class CqrsIsolatedFunctionHost<TAuthenticationToken, TAuthenticationToken
3738
where TAuthenticationTokenHelper : class, IAuthenticationTokenHelper<TAuthenticationToken>
3839
where TIsolatedFunctionHostModule : IsolatedFunctionHostModule, new()
3940
{
40-
IHostBuilder hostBuilder { get; set; }
41+
/// <summary>
42+
/// The <see cref="IHostBuilder"/> the <see cref="Host"/> is made from.
43+
/// </summary>
44+
protected IHostBuilder HostBuilder { get; set; }
45+
46+
/// <summary>
47+
/// The <see cref="IHostApplicationBuilder"/> the <see cref="Host"/> is made from.
48+
/// </summary>
49+
protected FunctionsApplicationBuilder HostApplicationBuilder { get; set; }
4150

42-
IHost host { get; set; }
51+
/// <summary>
52+
/// The <see cref="IHost"/> that drives this function.
53+
/// </summary>
54+
protected IHost Host { get; set; }
4355

4456
/// <summary>
4557
/// Indicates if the <see cref="SetExecutionPath"/> method has been called.
@@ -105,12 +117,24 @@ protected static void PrepareConfigurationManager(ConfigurationBuilder configBui
105117
string actualRoot = localRoot ?? azureRoot ?? Environment.CurrentDirectory;
106118

107119
// C# ConfigurationBuilder example for Azure Functions v2 runtime
108-
IConfigurationRoot config = (configBuilder ?? new ConfigurationBuilder())
120+
IConfigurationBuilder _configBuilder = (configBuilder ?? new ConfigurationBuilder())
109121
.SetBasePath(actualRoot)
110122
.AddCommandLine(Environment.GetCommandLineArgs())
111123
.AddJsonFile("cqrs.settings.json", optional: true, reloadOnChange: false)
112-
.AddEnvironmentVariables()
113-
.Build();
124+
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: false)
125+
.AddEnvironmentVariables();
126+
127+
// copied from Microsoft.Extensions.Hosting.WorkerHostBuilderExtensions
128+
var switchMappings = new Dictionary<string, string>
129+
{
130+
{ "--functions-uri", "Functions:Worker:HostEndpoint" },
131+
{ "--functions-request-id", "Functions:Worker:RequestId" },
132+
{ "--functions-worker-id", "Functions:Worker:WorkerId" },
133+
{ "--functions-grpc-max-message-length", "Functions:Worker:GrpcMaxMessageLength" },
134+
};
135+
_configBuilder.AddCommandLine(Environment.GetCommandLineArgs(), switchMappings);
136+
137+
IConfigurationRoot config = _configBuilder.Build();
114138
configurationManager = new CloudConfigurationManager(config);
115139
SetExecutionPath(config);
116140
#endif
@@ -128,6 +152,24 @@ protected static void StartHost()
128152
CoreHost.Run();
129153
}
130154

155+
/// <summary>
156+
/// Creates the <see cref="IHostBuilder"/>.
157+
/// </summary>
158+
protected virtual void CreateHostBuilder()
159+
{
160+
HostBuilder = new HostBuilder();
161+
}
162+
163+
/// <summary>
164+
/// Creates the <see cref="IHostApplicationBuilder"/>.
165+
/// </summary>
166+
protected virtual void CreateApplicationHostBuilder()
167+
{
168+
var _hostApplicationBuilder = FunctionsApplication.CreateBuilder(Environment.GetCommandLineArgs());
169+
HostApplicationBuilder = _hostApplicationBuilder;
170+
171+
}
172+
131173
/// <summary>
132174
/// Prepares the <see cref="IHost"/>.
133175
/// </summary>
@@ -136,37 +178,43 @@ protected virtual void PrepareHost()
136178
#if NET48
137179
FunctionsDebugger.Enable();
138180
#endif
139-
hostBuilder = new HostBuilder()
140-
.ConfigureFunctionsWorkerDefaults(builder => {
181+
CreateHostBuilder();
182+
CreateApplicationHostBuilder();
183+
184+
Func<IConfigurationBuilder, IConfigurationBuilder> cfgBuilder = (configBuilder) =>
185+
{
186+
string localRoot = Environment.GetEnvironmentVariable("AzureWebJobsScriptRoot");
187+
string azureRoot = Environment.GetEnvironmentVariable("HOME");
188+
azureRoot = string.IsNullOrWhiteSpace(azureRoot)
189+
? null
190+
: $"{azureRoot}/site/wwwroot";
191+
192+
string actualRoot = localRoot ?? azureRoot ?? Environment.CurrentDirectory;
193+
194+
(configBuilder ?? (configBuilder = new ConfigurationBuilder()))
195+
.SetBasePath(actualRoot)
196+
.AddCommandLine(Environment.GetCommandLineArgs())
197+
.AddJsonFile("cqrs.settings.json", optional: true, reloadOnChange: false)
198+
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: false)
199+
.AddEnvironmentVariables();
200+
201+
return configBuilder;
202+
};
203+
HostBuilder
204+
.ConfigureFunctionsWorkerDefaults(builder => {
141205
}, options =>
142206
{
143-
options.EnableUserCodeException = true;
144207
})
145-
.ConfigureAppConfiguration(config =>
208+
.ConfigureAppConfiguration(configBuilder =>
146209
{
147210
#if NET48
148211
#else
149-
string localRoot = Environment.GetEnvironmentVariable("AzureWebJobsScriptRoot");
150-
string azureRoot = Environment.GetEnvironmentVariable("HOME");
151-
azureRoot = string.IsNullOrWhiteSpace(azureRoot)
152-
? null
153-
: $"{azureRoot}/site/wwwroot";
154-
155-
string actualRoot = localRoot ?? azureRoot ?? Environment.CurrentDirectory;
156-
157-
// C# ConfigurationBuilder example for Azure Functions v2 runtime
158-
config
159-
.SetBasePath(actualRoot)
160-
.AddCommandLine(Environment.GetCommandLineArgs())
161-
.AddJsonFile("cqrs.settings.json", optional: true, reloadOnChange: false)
162-
.AddEnvironmentVariables();
212+
cfgBuilder(configBuilder);
163213
#endif
164-
/*
165-
*/
166214
})
167215
.ConfigureServices(services =>
168216
{
169-
// ConfigureApplicationInsights(services);
217+
ConfigureApplicationInsights(services);
170218
ConfigureHostServices(services);
171219
});
172220
}
@@ -206,7 +254,7 @@ protected override void Start()
206254
{
207255
base.Start();
208256

209-
host.Run();
257+
Host.Run();
210258
}
211259
/// <summary>
212260
/// Sets the execution path
@@ -239,16 +287,25 @@ Microsoft.Extensions.Configuration.IConfigurationRoot config
239287
/// </summary>
240288
protected override void ConfigureDefaultDependencyResolver()
241289
{
242-
host = hostBuilder
243-
.ConfigureServices(services => {
244-
foreach (Module supplementaryModule in GetSupplementaryModules(services))
245-
DependencyResolver.ModulesToLoad.Add(supplementaryModule);
290+
Action<IServiceCollection> configureDependencyResolver = (services) =>
291+
{
292+
foreach (Module supplementaryModule in GetSupplementaryModules(services))
293+
DependencyResolver.ModulesToLoad.Add(supplementaryModule);
294+
DependencyResolver.Start(services, prepareProvidedKernel: true);
295+
};
246296

247-
DependencyResolver.Start(services, prepareProvidedKernel: true);
297+
/*
298+
var _host = HostBuilder
299+
.ConfigureServices(services => {
300+
configureDependencyResolver(services);
248301
})
249302
.Build();
303+
*/
304+
305+
configureDependencyResolver(HostApplicationBuilder.Services);
306+
Host = HostApplicationBuilder.Build();
250307

251-
((DependencyResolver)Cqrs.Configuration.DependencyResolver.Current).SetKernel(host.Services);
308+
((DependencyResolver)Cqrs.Configuration.DependencyResolver.Current).SetKernel(Host.Services);
252309
}
253310

254311
/// <summary>

Framework/Azure/Cqrs.Azure.Functions.ServiceBus.Isolated/Cqrs.Azure.Functions.ServiceBus.Isolated.csproj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,25 @@
6969
<PackageReference Include="Chinchilla.StateManagement" Version="4.2.11" />
7070
<PackageReference Include="Chinchilla.Logging" Version="5.3.46" />
7171

72-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
73-
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
74-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
75-
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
76-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.22.0" />
72+
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />
73+
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.23.0" />
74+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.1.0" />
75+
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" />
76+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.24.0" />
7777

7878
<PackageReference Include="System.Linq.Async" Version="5.1.0" />
79-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
79+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.9" />
8080
</ItemGroup>
8181

8282
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
83-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
84-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
85-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
86-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
87-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
88-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
89-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
90-
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
83+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.9" />
84+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.9" />
85+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9" />
86+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9" />
87+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
88+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.9" />
89+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
90+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.9" />
9191
</ItemGroup>
9292

9393
<ItemGroup>

0 commit comments

Comments
 (0)