GithubHelp home page GithubHelp logo

markjprice / apps-services-net8 Goto Github PK

View Code? Open in Web Editor NEW
90.0 14.0 42.0 36.85 MB

Repository for the Packt Publishing book titled "Apps and Services with .NET 8" by Mark J. Price

PowerShell 0.11% C# 74.81% HTML 18.65% CSS 5.11% JavaScript 1.32%

apps-services-net8's Issues

Chapter 8 Online Section http linebreaks not working

*** This is a Visual Studio issue see comment below.***
I'm working through chapter 8's online section for odata when I try the request

###
GET {{base_address}}categories/
  ?$select=CategoryId,CategoryName

it returns

{
  "@odata.context": "https://localhost:5084/catalog/$metadata#Categories",
  "value": [
    {
      "CategoryId": 1,
      "CategoryName": "Beverages",
      "Description": "Soft drinks, coffees, teas, beers, and ales",
       .......

and I have an error stating '?$select=CategoryId,CategoryName' is not a valid http header. Expecting a valid http header or a blank line to separate the header section from the request body.
when I run the request as a single line GET {{base_address}}categories/?$select=CategoryId,CategoryName the output is correct.

{
  "@odata.context": "https://localhost:5084/catalog/$metadata#Categories(CategoryId,CategoryName)",
  "value": [
    {
      "CategoryId": 1,
      "CategoryName": "Beverages"
    },
    {
      "CategoryId": 2,
      "CategoryName": "Condiments"
    },
    ...

I've tried both with and without indent on the the ?$select line.

P.S.
And I know I've done a few issues, but honestly this book and the previous have been really helpful on learning new things and how to do other things better with c#. I've been really enjoying the books.

Chapter 8 Online section Spaces in http file cause error.

the http file for visual studio 2022 does not accept spaces. Lines like GET {{base_address}}products/?$filter=startswith(ProductName,'Ch') or (UnitPrice gt 50) must be written as GET {{base_address}}products/?$filter=startswith(ProductName,'Ch')%20or%20(UnitPrice%20gt%2050)

Example switches from Model to ViewData change.

On Page 1027-1028 (Kindle is hard to pinpoint) the example shows:

model.ShipperSummary = "Shipper from gRPC service:" +
    $"ID:{shipperReply.ShipperId}, Name:ShipperReply.CompanyName
    ....

however on page 1040 instead of assigning the information to model.ShipperSummary it assigns the data to ViewData["shipper"].

CosmosDb Product Listing missing currency.

Page 297 Listing all products from the CosmosDB says to set the current culture to french to see the euro symbol. However the output for the unit price is converted to string and not displaying the currency symbol. Removing the ToString from unitPrice fixes this issue.

foreach (ProductCosmos product in products)
{
    WriteLine("id: {0}, productName: {1}, unitPrice: {2}",
    arg0: product.id, arg1: product.productName, 
    arg2: product.unitPrice.ToString());
}

to

foreach (ProductCosmos product in products)
{
    WriteLine("id: {0}, productName: {1}, unitPrice: {2}",
    arg0: product.id, arg1: product.productName, 
    arg2: product.unitPrice);
}

page 166 - stored procedures are the only way to ensure ACID

Stored procedures are the only way to ensure ACID (Atomic, Consistent, Isolated, Durable) transactions
that combine multiple discrete activities into a single action that can be committed or rolled back.
You cannot use client-side code to implement transactions.

What about transactional batch operations?
Cosmos DB supports transactional batch operations within a single partition. This means you can execute a set of operations (such as inserts, updates, and deletes) in an atomic batch within a single logical partition.
https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/transactional-batch?tabs=dotnet

Errors in CheckGeneratorFunction.cs file

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);

Missing Form from Products Chapter 13

The form to search for product in chapter 13 page 1061 (Kindle) is missing from the in text version. The repository version has it.

<form asp-action="Products" method="post">
    <input name="minimumPrice" placeholder="Enter a minimum unit price" />
    <input type="submit" value="Filter Products" />
</form>

Azure function requires async or AllowSynchronousIO

I got the following error:

[2024-02-19T22:04:57.896Z] Function 'NumbersToWordsFunction', Invocation id '1c7e2c25-32c6-4027-b30b-f29216597cfa': An exception was thrown by the invocation.
[2024-02-19T22:04:57.897Z] Result: Function 'NumbersToWordsFunction', Invocation id '1c7e2c25-32c6-4027-b30b-f29216597cfa': An exception was thrown by the invocation.
Exception: System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
...

Changing the following WriteString to WriteStringAsync fixed the issue.

        if (long.TryParse(amount, out long number))
        {
            response = req.CreateResponse(System.Net.HttpStatusCode.OK);
            //response.WriteString(number.ToWords());
            response.WriteStringAsync(number.ToWords());
        }
        else
        {
            response = req.CreateResponse(
                System.Net.HttpStatusCode.BadRequest);
            
            //response.WriteString($"Failed to parse: {amount}");
            response.WriteStringAsync($"Failed to parse: {amount}");
        }

or adding the following lines to program.cs (this option was found on stack overflow.
https://stackoverflow.com/a/55196057

        services.Configure<KestrelServerOptions>(options =>
        {
            options.AllowSynchronousIO = true;
        });

Comments in json docs cause issues for JWT creation.

Creating a JWT token as shown on page 652; dotnet user-jwts create results in '/' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: 5 | BytePositionInLine: 6. if you have any comments in appsettings.json, appsettings.Development.json, or launchSettings.json.

Broken link

Page 33: Second bullet in Exercise 1.2
Benchmarking Performance and Testing: In this section, you will learn how to use types in
the System.Diagnostics namespace and the Benchmark.NET library to monitor your code
to measure performance and efficiency (https://github.com/markjprice/apps-services
net8/blob/main/docs/ch01-benchmarking.md
).

Easy issue fix: The actual URL has a hyphen between the words "services" and "net8", so the link should be:
https://github.com/markjprice/apps-**services-net8**/blob/main/docs/ch01-benchmarking.md

QuestPDF License

QuestPDF.Settings.License = LicenseType.Community; is throwing an error saying Settings does not contain a definition for the License. I'm currently using version 2022.12.6. If you comment out that line everything works fine.

azurefunctions-scrapeamazon.http missing GET command.

Kindle book has the follow

### Configure a variable for the Azure Functions service base address.
@base_address = http://localhost:5101/
### Get information about the NumbersToWordsFunction function.
{{base_address}}admin/functions/NumbersToWordsFunction
### Get information about the ScrapeAmazonFunction function.

how ever Visual Studio 2022 doesn't recognize it as a request until you add GET in front of {{base_address}}

### Get information about the NumbersToWordsFunction function.
GET {{base_address}}admin/functions/NumbersToWordsFunction

### Get information about the ScrapeAmazonFunction function.
GET {{base_address}}admin/functions/ScrapeAmazonFunction

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.