Discover ways to create a REST API end-to-end from scratch utilizing the most recent .NET 5 improvements and Visible Studio Code. The API will probably be written in C#.
💻 Get the code: https://youtube.dotnetmicroservices.com/net5restapi-10
✏️ Course developed by Julio Casal. Take a look at his channel: https://www.youtube.com/c/jcasalt
🔗 Julio’s web site: https://dotnetmicroservices.com
⭐️ Course Contents ⭐️
Getting Began
0:00:00 Introduction
0:03:02 Creating the mission
0:04:01 Exploring the generated mission recordsdata
0:10:03 Trusting the self-signed certificates
0:11:36 Exploring the default Swagger UI web page
0:12:30 Configuring Visible Studio Code settings
Entity, Repository, Controller GET
0:14:33 Introduction
0:15:45 Including an entity
0:20:39 Ading an in-memory repository
0:26:40 Creating the controller
0:30:42 Implemeting GET all gadgets
0:33:37 Implemeting GET single merchandise
0:37:47 Returning a 404 NotFound standing code
Dependency Injection, DTOSs
0:39:57 Introduction
0:41:23 What’s dependency injection?
0:46:14 Extracting the repository interface
0:47:44 Injecting the repository into the controller
0:48:53 Registering the repository as a singleton
0:52:32 Including a Knowledge Switch Object DTO
0:55:46 Creating the AsDto extension technique
POST, PUT, DELETE
0:58:59 Introduction
0:59:45 Implementing POST
1:07:39 Including validations through knowledge annotations
1:10:00 Implemeting PUT
1:17:33 Implementing DELETE
Persisting Entities with MongoDB
1:20:46 Introduction
1:24:44 Utilizing Postman
1:27:53 Making a MongoDB repository
1:29:42 Utilizing the MongoDB.Driver NuGet package deal
1:33:28 Implementing MongoDB Create
1:33:57 Working the MongoDB Docker container
1:38:47 Configuring MongoDB connection settings
1:42:38 Registering the MongoClient singleton
1:48:02 Testing the MongoDB integration
1:50:04 Exploring the created database in VS Code
1:52:45 Implemeting MongoDB Get, Replace and Delete
Duties, Async and Await
2:02:27 Introduction
2:06:46 Utilizing the Async suffix
2:09:04 Utilizing duties within the repository
2:11:50 Utilizing async and await
2:14:28 Returning accomplished duties
2:18:16 Utilizing duties within the controller
2:21:23 Testing async strategies in Postman
Secrets and techniques and Well being Checks
2:27:02 Introduction
2:30:06 Enabling authentication in MongoDB
2:33:36 Utilizing the .NET Secret Supervisor
2:36:40 Utilizing the MongoDB credentials within the service
2:40:00 Introduction to Well being Checks
2:42:28 Including an endpoint for well being checks
2:44:46 Including a MongoDB well being examine
2:48:41 Including checks for readiness and liveness
2:53:51 Customizing the well being examine response
2:58:59 Exploring different well being examine NuGet packages
Docker
3:00:44 Introduction
3:08:28 What’s Docker?
3:17:54 Eradicating https redirection
3:20:39 Producing a Dockerfile in VS Code
3:30:40 Constructing the Docker picture
3:33:00 Including a Docker community
3:34:07 Working the containers within the Docker community
3:40:36 Working the REST API in Docker
3:42:02 Pushing the container picture to Docker Hub
3:46:02 Exploring the picture in Docker Hub
3:46:32 Pulling the picture again to the native field
Kubernetes
3:49:20 Introduction
3:54:05 What’s Kubernetes?
4:04:06 Enabling a Kubernetes cluster in Docker Desktop
4:06:12 Putting in the Kubernetes extension for VS Code
4:06:58 Declaring the REST API Kuberentes deployment
4:14:35 Making a secret in Kubernetes
4:17:28 Declaring well being probes
4:19:14 Declaring the REST API Kubernetes service
4:22:56 Creating the REST API assets in Kubernetes
4:26:15 Declaring the MongoDB Kubernetes StatefulSet
4:36:09 Declaring the MongoDB Kubernetes service
4:38:27 Creating the MongoDB assets in Kubernetes
4:40:42 Testing the REST API hosted in Kubernetes
4:42:08 Exploring the Kubernetes self-healing functionality
4:46:04 Scaling Kubernetes pods
4:47:38 Including logs through ILogger
4:52:04 Getting a brand new picture model into Kubernetes
4:53:23 Load balancing requests throughout pods
Unit Testing and TDD
4:56:23 Introduction
4:57:04 What’s unit testing?
5:01:19 What’s take a look at pushed improvement?
5:04:25 Restructuring recordsdata and directories
5:08:25 Creating the xUnit take a look at mission
5:09:15 Constructing a number of initiatives in VS Code
5:13:10 Including NuGet packages for unit testing
5:14:35 Testing GetItemAsync unexisting merchandise
5:18:35 Utilizing the AAA sample
5:19:31 Stubbing dependencies through Moq
5:26:52 Working checks in VS Code
5:28:05 Utilizing the .NET Core Take a look at Explorer extension
5:30:55 Testing GetItemAsync current merchandise
5:38:01 Utilizing FluentAssertions
5:41:46 Testing GetItemsAsync
5:45:41 Testing CreateItemAsync
5:53:13 Testing UpdateItemAsync
5:57:51 Testing DeleteItemAsync
5:59:40 Refactoring and catching regressions
6:10:50 Utilizing TDD to check a but to be created technique
6:19:07 Going again to inexperienced by fixing the failing take a look at
6:21:19 Testing the brand new controller technique in Postman
source
Thanks a lot Beau for sharing the tutorial in this awesome channel. Really hope it helps folks get started with my favorite platform!
Good Day Julio Casal, @ 4:42:08 on running the /items webapi in postman getting nginx – 404 file not found can you help in resolving this.
Incredible bootcamp!!😱😍
Thank you so much!
@32:04 getting an error when I run this that the items controller needs a return type, any thoughts?
thank you my bro benifit
Is there anything special I need to do to get the imports working? In the video it seems to be auto importing, but I'm not sure how to replicate that. Usually if I let VSCode auto-complete what I'm typing, it will also auto-import, but that doesn't seem to be working.
In dotnet core 6.0 you can register the singleton in the Program.cs file after the first comment in the file like so:
// Add services to the container.
builder.Services.AddSingleton<IItemsRepository, InMemItemsRepository>();
Very good tutorial. which helped me to learn a lot about REST Architecture.
I am curious why the lecturer is using Visual Studio Code instead of Visual Studio 2019 ? Thank you in advance for your replies.
I was expecting some insight on c# backend but we got an amazing course going beyond that, even kubernetes!
please try explaining better CUASE I DONT KNOW WHAT YOURE DOING HALF THE TIME
Working through this now and the Instructor and material are great. Really wonderful way to teach the material and not just a step by step tutorial. I am working on a project that uses Azure services for DB, API, etc so I need the conceptual understanding which this course presents very well.
Thank you for the great class!
I don''t get what's the point of a dto class
Great! With some minor changes works with .NET 6. Thanks!
What are all the extensions required
Are there major changes to .NET 6?
Can you please do a video on REST APIs with .NET Core 6.0
Am really grateful I got my IST FILE from the name ⬆️⬆️⬆️⬆️⬆️⬆️above it really work effectively.
Am really grateful I got my IST FILE from the name ⬆️⬆️⬆️⬆️⬆️⬆️above it really work effectively.
Single handedly the best training I have gotten with .Net Rest APIs. Awesome job.
Im just doing a spring boot course. Concepts are simiral can't tell much. At44mins seems like in dotnet the api endpoints handling is simpler than in springboot. Watching the videout out of curiosity. Btw like it some stuff are unlogical yet might be because lack of my knowledge. Will watch a db reply with my opinion. Btw I like the way you teach. Great video.
Seems like I can't get the catalog pod ready? Any solution before I just watch the rest of this video? The file had a minor mistake with the upper case which was supposed to be MongodbSettings__Password instead of "Db" but still nothing
Edit: Looks like I have Mongo connection down but don't know the reason on why that's happenning and can't connect. Any solution?
Hey @Julio Casal. Hope you are doing well.
I am getting below error at 2:38:00 when I try to Get the items
MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.
—> MongoDB.Driver.MongoCommandException: Command saslStart failed: Authentication failed..
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ProcessReply(ConnectionId connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Authentication.SaslAuthenticator.AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)
— End of inner exception stack trace —
at MongoDB.Driver.Core.Authentication.SaslAuthenticator.AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Authentication.DefaultAuthenticator.AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Authentication.AuthenticationHelper.AuthenticateAsync(IConnection connection, ConnectionDescription description, IReadOnlyList`1 authenticators, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.ConnectionInitializer.AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.PooledConnection.OpenAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.ConnectionCreator.CreateOpenedInternalAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.ConnectionCreator.CreateOpenedOrReuseAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.AcquireConnectionAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.GetChannelAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.RetryableWriteContext.InitializeAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.RetryableWriteContext.CreateAsync(IWriteBinding binding, Boolean retryRequested, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.ExecuteWriteOperationAsync[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperationAsync[TResult](IClientSessionHandle session, IWriteOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.BulkWriteAsync(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionBase`1.InsertOneAsync(TDocument document, InsertOneOptions options, Func`3 bulkWriteAsync)
at Catalog.Repositories.MongoDbItemsRepository.CreateItemAsync(Item item) in D:CatalogRepositoriesMongoDbItemsRepository.cs:line 29
at Catalog.Controller.ItemsController.CreateItemAsync(CreateItemDto itemDto) in D:CatalogControllersItemsController.cs:line 57
at lambda_method5(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
HEADERS
=======
Connection: keep-alive
Content-Type: application/json
Accept: /
Accept-Encoding: gzip, deflate, br
Host: localhost:5001
Referer: http://localhost:5000/items
User-Agent: PostmanRuntime/7.29.0
Content-Length: 49
Postman-Token: 5639576c-e3bf-4c47-9ff7-9097b4bc0f9b
However , My connection string is correct and also it is fetching the correct password from Secrets
1:08:00 Executed without name and it gave me a 400 is this a new feature from .net core 6.0? Default is required?
Hit Control + . to fix namespace issues. He doesn't show what namespaces he's using, he's letting vscode determine it with intellisense. Just something I think will help people as it confused me.
good tutorial but he just assumes we know most of the things and he just does it too quickly without too much explanation
Amazing tutorial, I appreciate that, thank you very much. On the unit tests, if somebody had problems with CreateItemAsync_WithItemToCreate_ReturnsCreatedItem on BeCloseTo comparison, I did this and worked:
createdItem.CreatedDate.Should().BeCloseTo(DateTimeOffset.UtcNow, TimeSpan.FromMilliseconds(1000));
I needed to use TimeSpan.FromMilliseconds, only passing 1000 the editor was complaining
readonly struct System.Int32
Represents a 32-bit signed integer.
Argument 2: cannot convert from 'int' to 'System.TimeSpan' [Catalog.UnitTests]
Thank you so much <3
I have a question. I need to have a CPU that supports virtualization for use Docker?
Really great tutorial, we want more of the Julio Casal Videos please
Do you have.a git (or other) repo with the complete project/source code?