markjprice / apps-services-net8

Repository for the Packt Publishing book titled "Apps and Services with .NET 8" by Mark J. Price
119 stars 55 forks source link

Errors in CheckGeneratorFunction.cs file #12

Closed Pip1987 closed 8 months ago

Pip1987 commented 9 months ago

When i copied the CheckGeneratorFunctions from the book I noticed I had missing using references

using SixLabors.ImageSharp; // To use Image Class.
using SixLabors.ImageSharp.PixelFormats; // To use Rgba32 type.
using SixLabors.ImageSharp.Processing; // To use mutate.

I needed to change public byte[] Run( [QueueTrigger("checksQueue")] string message) to public byte[] Run([QueueTrigger("checksQueue")] Azure.Storage.Queues.Models.QueueMessage message) and the following mislabeled variables. log.LogInformation($"Blobs folder: {folder}"); to _logger.LogInformation($"Blobs folder: {folder}");

log.LogError(ex.Message); to _logger.LogError(ex.Message);

markjprice commented 8 months ago

Hi Phil, thanks for these issues. I have created an errata item for them here: https://github.com/markjprice/apps-services-net8/blob/main/docs/errata/errata.md#page-462---implementing-a-function-that-works-with-queues-and-blobs

  1. The first issue was due to a breaking change in ImageSharp.
  2. The second issue with the logger was my mistake not updating all the variable references in the book after changing them in code.
  3. The issue you had with the message parameter I think might have been caused by something else: I had not created a .http test file to trigger the check generation. I think you might have run the other test file that calls the NumbersToWords function. I think that because that's exactly what I did too! And that doesn't trigger the queue. So I thought it was broken too initially. But then I noticed the missing test file and tried again and it worked correctly. I also updated the Azure packages to their current latest and they still work with the message parameter as a string as in the book. If you change the parameter to a QueueMessage then that'd work too but only if you also make more changes throughout the code to convert the message.Body into a string value for printing.

Keep up the great work!