-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to .NET 8.0 Updated README
- Loading branch information
Showing
16 changed files
with
238 additions
and
158 deletions.
There are no files selected for viewing
22 changes: 10 additions & 12 deletions
22
priority-queue/PriorityQueueConsumerHigh/PriorityQueueConsumerHigh.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enabled</ImplicitUsings> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.2.0" /> | ||
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" /> | ||
</ItemGroup> | ||
</Project> |
19 changes: 13 additions & 6 deletions
19
priority-queue/PriorityQueueConsumerHigh/PriorityQueueConsumerHighFn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Azure.Functions.Worker; | ||
|
||
namespace PriorityQueueConsumerHigh | ||
{ | ||
public static class PriorityQueueConsumerHighFn | ||
public class PriorityQueueConsumerHighFn | ||
{ | ||
[FunctionName("HighPriorityQueueConsumerFunction")] | ||
public static void Run([ServiceBusTrigger("messages", "highPriority", Connection = "ServiceBusConnection")]string highPriorityMessage, ILogger log) | ||
private readonly ILogger _logger; | ||
|
||
public PriorityQueueConsumerHighFn(ILogger<PriorityQueueConsumerHighFn> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[Function("HighPriorityQueueConsumerFunction")] | ||
public void Run([ServiceBusTrigger("messages", "highPriority", Connection = "ServiceBusConnectionString")] string highPriorityMessage) | ||
{ | ||
log.LogInformation($"C# ServiceBus topic trigger function processed message: {highPriorityMessage}"); | ||
_logger.LogInformation($"C# ServiceBus topic trigger function processed message: {highPriorityMessage}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Microsoft.Extensions.Hosting; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.Build(); | ||
|
||
host.Run(); |
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
priority-queue/PriorityQueueConsumerHigh/local.settings.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", | ||
"ServiceBusConnectionString": "SERVICE_BUS_CONNECTION_STRING" | ||
} | ||
} |
23 changes: 10 additions & 13 deletions
23
priority-queue/PriorityQueueConsumerLow/PriorityQueueConsumerLow.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<UserSecretsId>736bb6a2-68b4-463b-a8fb-3a90cba7cd4f</UserSecretsId> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enabled</ImplicitUsings> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.2.0" /> | ||
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" /> | ||
</ItemGroup> | ||
</Project> |
19 changes: 13 additions & 6 deletions
19
priority-queue/PriorityQueueConsumerLow/PriorityQueueConsumerLowFn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Azure.Functions.Worker; | ||
|
||
namespace PriorityQueueConsumerLow | ||
{ | ||
public static class PriorityQueueConsumerLowFn | ||
public class PriorityQueueConsumerLowFn | ||
{ | ||
[FunctionName("LowPriorityQueueConsumerFunction")] | ||
public static void Run([ServiceBusTrigger("messages", "lowPriority", Connection = "ServiceBusConnection")]string lowPriorityMessage, ILogger log) | ||
private readonly ILogger _logger; | ||
|
||
public PriorityQueueConsumerLowFn(ILogger<PriorityQueueConsumerLowFn> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[Function("LowPriorityQueueConsumerFunction")] | ||
public void Run([ServiceBusTrigger("messages", "lowPriority", Connection = "ServiceBusConnectionString")] string lowPriorityMessage) | ||
{ | ||
log.LogInformation($"C# ServiceBus topic trigger function processed message: {lowPriorityMessage}"); | ||
_logger.LogInformation($"C# ServiceBus topic trigger function processed message: {lowPriorityMessage}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Microsoft.Extensions.Hosting; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.Build(); | ||
|
||
host.Run(); |
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
priority-queue/PriorityQueueConsumerLow/local.settings.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", | ||
"ServiceBusConnectionString": "SERVICE_BUS_CONNECTION_STRING" | ||
} | ||
} |
25 changes: 12 additions & 13 deletions
25
priority-queue/PriorityQueueSender/PriorityQueueSender.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enabled</ImplicitUsings> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.2.0" /> | ||
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" /> | ||
</ItemGroup> | ||
</Project> |
21 changes: 12 additions & 9 deletions
21
priority-queue/PriorityQueueSender/PriorityQueueSenderFn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Azure.Messaging.ServiceBus; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Azure.Functions.Worker; | ||
|
||
namespace PriorityQueueSender | ||
{ | ||
public static class PriorityQueueSenderFn | ||
public class PriorityQueueSenderFn(ILogger<PriorityQueueSenderFn> logger, ServiceBusClient client) | ||
{ | ||
[FunctionName("PriorityQueueSenderFunction")] | ||
public static async Task Run( | ||
[TimerTrigger("0,30 * * * * *")] TimerInfo myTimer, | ||
[ServiceBus("messages", Connection = "ServiceBusConnection")] IAsyncCollector<ServiceBusMessage> collector ) | ||
private readonly ILogger<PriorityQueueSenderFn> _logger = logger; | ||
private readonly ServiceBusClient _client = client; | ||
|
||
[Function("PriorityQueueSenderFunction")] | ||
public async Task Run([TimerTrigger("0,30 * * * * *")] TimerInfo myTimer) | ||
{ | ||
var sender = _client.CreateSender("messages"); | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
var messageId = Guid.NewGuid().ToString(); | ||
var lpMessage = new ServiceBusMessage() { MessageId = messageId }; | ||
lpMessage.ApplicationProperties["Priority"] = Priority.Low; | ||
lpMessage.Body = BinaryData.FromString($"Low priority message with Id: {messageId}"); | ||
await collector.AddAsync(lpMessage); | ||
await sender.SendMessageAsync(lpMessage); | ||
|
||
messageId = Guid.NewGuid().ToString(); | ||
var hpMessage = new ServiceBusMessage() { MessageId = messageId }; | ||
hpMessage.ApplicationProperties["Priority"] = Priority.High; | ||
hpMessage.Body = BinaryData.FromString($"High priority message with Id: {messageId}"); | ||
await collector.AddAsync(hpMessage); | ||
await sender.SendMessageAsync(hpMessage); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Azure.Messaging.ServiceBus; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.ConfigureAppConfiguration((hostingContext, config) => | ||
{ | ||
config.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true); | ||
}) | ||
.ConfigureServices(services => | ||
{ | ||
var configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>(); | ||
|
||
services.AddSingleton(configuration); | ||
|
||
services.AddSingleton<ServiceBusClient>(sp => | ||
{ | ||
var connectionString = configuration.GetValue<string>("ServiceBusConnectionString"); | ||
return new ServiceBusClient(connectionString); | ||
}); | ||
}) | ||
.Build(); | ||
|
||
host.Run(); |
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
priority-queue/PriorityQueueSender/local.settings.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", | ||
"ServiceBusConnectionString": "SERVICE_BUS_CONNECTION_STRING" | ||
} | ||
} |
Oops, something went wrong.