.NET 7 πŸ’₯ - Intro to Background Services (Hangfire) with ASP.NET Core Web Api πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign thank you for watching this video I am Muhammad and today we're gonna be discussing how we can actually implement the background jobs inside our dotnet application we're going to be seeing how we can utilize a library that's going to make this easy for us outside of the box we're going to missing different implementation for the different types of background jobs that we can Implement and we're going to be understanding the full logic behind it of how it actually works within our.net application if you like this video please like share and subscribe it will really help the channel as well if you'd like to support me please consider supporting me on patreon or buying me a coffee now with that said grab a cup of coffee and let's get started so the first thing that we need to do is we need to actually understand how Hank Fire Works and from there we're going to be seeing the different implementation pattern that hikefire provides and then once we have covered all of that we can actually start within the code so just a quick summary Hank fire is a way where we can actually run background Services inside our dotnet application without drawing on any third-party services before hosting it on Windows without try relying on the Windows services in order for us to do that all of the background services will actually be directly running from our application it will create different threads within our application and it will dedicate those threads and those resources into the background services that we currently have so that's a very nice way that Hank fire give us this capability because basically we don't have to worry about any third-party services about any additional resources whenever the application startup those background services will start up with it and that's going to be the main Keen area here is basically all of the implementation that we're going to be currently having is going to be directly linked to Hang Fire and to all.net application so for example if our.net application stop the background services will not work so that's that's the only downside for it so even if the application is not working the Hank file will not will not work and vice versa whenever the application is working all of the different background Services would work so this is something that we need to keep in mind but other than that time fire is a very fast secure and free of charge to a certain extent when it comes to actually having background Services there's a lot of different capabilities that Hank fired give us for free and there's two capabilities that we have to pay for we're gonna be diving into those details and a bit more once we start implementing but other than that I think hunt fire is a really really good way to start actually creating background processes before we jump into the code let me go back to the drawing Port here so we can understand how this works so basically right now we want to imagine is all of this is currently happening within our application so this is our application and the reason here I chose the keyword client and server and it's basically just a way where we can actually have logic separation inside our refer what we're referring to inside the net core application so this is our application and inside this application we have installed our Hang Fire libraries so once we install the Hank file Library what will hang file actually do inside our application well Hank fire is going to create a client and it's going to create a server and these are basically instances that they're going to be running whenever aware.net application is running we don't have to really worry about how do they work how do they run everything is automatically configured with an ank fire once you add it to the our program.cs it will take care of financing all of that the only thing we need to provide is a way a storage location so if we're utilizing SQL Server we need to give it a SQL Server database if we're using SQL Lite postgres we need to give it those queries thing in order for it to connect to but basically Hank file will utilize a database to store all of the jobs that it needs to do so for example let's say I want to run an email service which runs after uh three hours after a user register for example like a Sunday welcome email and all of the setup stuff we can allocate that and the way where Hank fired stores this information inside a database and once the time allocates I think I will pick up that job and execute it so the main thing that we need to provide the Hank file once we are setting up is going to be the connections link for the database this could be our own database that we are using or with the better approach is to have a dedicated database for hangfire because basically once we have a dedicated database for hangfire it will directly know that it has separation of concerns so in case for any reason we want to completely scrap the database and rebuild it we can do that we want to backup specifically those jobs and basically restore them later on we can do that we don't really have to worry about it conflicting with our own data so that's something really important to keep in mind it will really be helpful if we can have two databases one for the application and one specifically for rank file but again if you don't have that you can integrate it directly with your application and it will work so let us understand the process flow so again all of these are running within our.net application so basically when after we set up a job we're basically utilizing the Hank fire client we're telling it please we want to create some kind of a job and there's different types of jobs so we're going to be discussing a bit after that so once we decided to create a job what will Hank fire do it will start inside this database saying I need to execute this types of job and then with what it will do it will return to us the confirmation that this shops has been created and that's it that's the only row that the client will have it's only responsible for taking any jobs that you want to do from our side so once we have done that the second part is the Hank fire server and here the Hank fire server is main responsibility is to actually keep scanning this database keep actually looking at the information there and see whatever job that needs to be executed and then execute them so it will actually go into the database do a scan if every I think every second or every something along those line check do I need to execute anything right now if it does it will take that job and it will execute it and then once it finish it will fetch another job another another job another job so as we can see here that the first step is for us to create a job and then it will give us back the confirmation and then it will perform the background job which is pulled up from this database and once it does it will actually fetch another one another one so all of this is running in the background inside our DOT not application we don't have to worry about it but it's really important for us to understand the background and how does it work before we can actually start implementing because if something goes wrong it's really important for us to actually understand where it it potentially overgrown in order for us to resolve it so once we have covered that now we want to understand what can we do with a free version that tank fire provide and what are the ones that we need to pay for so they are separated into free and paid so the three ones as you can see is much more than the paid one and you can see it's pretty much almost what you ever need to do so the first one is fire and forget shops so it's something like you want to send an email so after I use a register for example you want to send them a welcome email you can use foreign because you're not really waiting on anything from them so you just initiate it and Hank fire will take care of the rust the second one is delayed jobs so you want to say for example after someone applied to upload their profile picture within the next five minutes you want to create a thumbnail of that picture so that's a delay jobs you don't want to do it directly because the user could have been still updating their profile or for any reason so the delay job is basically after that has been after a certain amount of time that job will be picked up so you trigger it after a certain amount of time the recurring job say is for example every day around midnight I want to do a cleanup on my database so every day at that time it will for example run and allow to execute that job and that's a recurring job because we can specify the Clone time frame for it and once we specify the current time frame for it it will automatically keep on execute and executing until it's actually accidentally stopped manually stop it and lastly it's a continuous jobs continuous Jobs means that we have one job attached to another so for example let's say we have a user who have uploaded their profile pictures once they have uploaded their profile picture we first of all we can create a thumbnail once we create a thumbnail we want to copy it to a different storage location then we want to for example upload it to our cache so and so forth so all of these different stuff what we can do them is our continuous jobs because we don't want the main thread of our application doing that we want to some some background terms executing all of this for us so that's where Hank fire comes into place we can have this there in order for us to actually execute all of these different requirements in a continuous way and we can attach jobs to one another so only on upon successful of one job we can execute another and that's the main thing but then continuous jobs and as for the paid one is basically Bus jobs it will allow us to execute multiple jobs simultaneously and that's basically a self-defined here and batch continuous it will actually continue on the continuous pass again it will actually be a batch continuous so instead of running one continuous action we can run three four five continuous actions as many as we need so that's going to be the main thing and oh within this video we're going to be focusing on the free one I don't have a paid license unless 951 sponsored me we can go through it but we're gonna be focusing on the main jobs and we're going to see how actually we can Implement them within our web.net application so now that we have actually covered what tank fire does and why do we might need it and the main implementation of it let's jump back to our source code and basically what I'm using here is I'm using the application that we have created previously which is the base application which contain a default connection strings it contain some controllers etc etc it container DB context which is available for us so instead of redoing the work every single time we're just using the space application if you're interested in learning how we build this I have a video which I've been linked here somewhere on the description down below where you can actually watch it in full and you basically have the exact exact same version of the application as I do right here so what we're going to be doing here is we're going to be starting by installing some packages and those packages are going to be crucial for Hank fire in order for us to utilize it so the first package is going to be.net and package Hang Fire so we need to navigate to the application so I always forget and then let's install the package perfect let's clear this up right now then what I want to do I want to sew another packet so it's not add package heinfire.com perfect another package has been installed now we wanna because we want to utilize if we go back here we want to utilize a storage and because I'm using SQL Lite I want to install the package for SQL Lite if you're using SQL Server install the package for SQL server for postgres postgres etc etc so for now right here I'm gonna install the SQL light so I'm gonna be let's clear it up not not add package Hang Fire dot storage Dot SQL light Hang Fire Dot oops here we have a typo perfect and then I need to install again let's clean this up .net add package and this is gonna be Hang Fire dot dashboard dot basic dot authentication and because Hank file is such a powerful tool we're actually able to have full dashboard capabilities for us and we'll actually have the capability to add authentication mechanism to it so that way we're only us would be able to manage these jobs see what's going on and basically try to identify if there's anything going wrong and all of that is out of the box provided by Hank fire I don't really have to do any extra work and we're going to be exploring how we can set up these dashboards later on so now that we have done this the next step is going to go to our connection string and inside my connection string I'm going to add a new conduction string I'm gonna call it tank fire connection and I'm just gonna call it Hang Fire DB and here what I'm doing is because basically I'm using sqlite I don't really have to worry about having a different data utilizing the same data source because it's on my local machine I can create as many databases that I want so and for this reason I'm just utilizing a different database to store the Hang fires tables in it and once we created those Hang Fire tables we're gonna actually able to see what's going to be inside of them so once I created my conduction string The Next Step that I want to do is I want to specify the level of information inside the logs for hang fired so I'm just gonna add here hang fire and I'm gonna add a level for it as information as well perfect so now that I have done that the All I'm gonna do right now is go to my program.cs and basically notify my application that I'm going to utilizing Hang Fire and add all of the required configuration to it so before I do any build so I'll have to add it here I need to add actually first of all let us get the conduction string for our Hang Fire so we already have here a suction to get conduction string so I'm gonna put War Hang Fire connection string equal Builder dot configuration dot get connection string and then what did I call this conduction string and fire connection very creative and now I want to utilize this conduction string here so before I do any build I want to add it here I'm going to put Builder dot Services dot add ing fire and then from here what I want to do I want to specify the configuration let's make it config easier okay so let's add it here so we're gonna put set data compatibility level and I'm gonna put compatibility level to 180 and here if we take a look at this this is basically going to allow us to see the how many data that we want to utilize the different compatibility that we want there is a big section inside the Hang Fire website where it actually goes to different compatibilities I'm not gonna delve into this right now but the general rule of thumb use the 180 because it's the most versatiles one but again for more information about this check the Hang Fire website to distract the different compatibility levels so once we have set the compatibility levels now I want to utilize the use Simple assembly name Siri and type serializer and this is basically it will allow us to actually scan all of the assemblies inside our application in order for it to actually find the right jobs because the jobs that we're going to utilizing that are going to be injected with the dependency instruction so it's really good for it to actually knows what a type of assembly exists inside our application so it will scan those assemblies and figure out the jobs from there and then actually inject them inside it's on the eye container so it will able to execute them I'm going to put use recommended serialization settings and lastly I want to delete that it need to use the SQL light actually I'm going to tell it to use the SQL light storage and here I need to specify the connection string so I'm going to put time for our connection string and that's the first part of the configuration so a lot of just do not not build quickly to make sure everything is building so now if you take a look at here what I did is I configured the actually the Hang Fire client basically I'm telling you the Hang Fire client it needs to be compatible it needs to be able to scan all the different assemblies use the recommended serialization settings and for it to be running it needs to actually use the connection string now what I want to do is I want to specify the Hang Fire server again it's all based on this architecture so now we have configured the client inside our application so it will run automatic when the application runs now we want to configure the server so it will automatically run whenever our application runs as well and this is also going to be pretty straightforward so I'm gonna put Builder services and hiring for your server and that's going to be it we're not going to be delving into more details for the server because most of the configuration that we have done here is already available on backline side so these are going to be the main current configuration there's going to be more but this is going to be the main thing right now and once we have done that the next is I want to actually enable it so let's go here let me remove this I don't need https right now so the first thing that I need to do here is I need to add the following up Dot use Hang Fire dashboard and I'm gonna specify that you endpoint for it I'm just gonna say voice like hand fire we're going to be seeing all of that in action and then actually this one will not be here this one it will be inside the app dot ma Pine fire dashboard yeah and let's put this is us forward slash Hang Fire and lastly what I want to do is I want to create some kind of uh background job so we can just actually see it running unless this is going to be pretty straightforward I'm just going to put recurring job dot add or update and let's utilize a Lambda function I'm gonna put just console Dot rightline I'm gonna say here hello from Hang Fire and here is going to ask us for a Grand job let me just copy one con job here so it will directly be available for us and now as you can see Hank file will take a con expression because basically what we're doing is we're just adding a fire and forget the crown job and once we have done this then now let's run our application and as you can see as soon as we have run our application there's a lot of configuration which is happening and you can see here Hank fire server is connected it's starting to register all of the different Services it started to utilize the SQL Server SQL light storage and all of the different implementation there and if we take a look here on the left hand side we can see here that now we have a new database called hindquierdb and now let's give it a few seconds and we're going to be able to see Hello from hand fire automatically popping up here while we're doing with that let us check this Hang Fire DB let's check the connection is connected let's open it up and let me open it here and first of all we can see that the background job has started running hello from playing fire I did not do anything it automatically run by itself and now here let me just open the main open the tables and we can see that these are all of the tables the tank fire will need to utilize in order for it to run it all manages by itself would not get any of this as soon as I provide the connections thing it automatically generated and if I want to take a look at the job so let me open it oops let me open it up and we can see here that this is a job that has actually run hello from Hank fire we can see created ad and the expiring ad and we take if we open this we can see the actual argument which has been passed to it and we can see the actual invocation data which is here it was more of a console.log and we can see the status of it succeeded so now once a new one will execute it will automatically run again and again and basically it will record it more and more here so in essence all of this has been automatically managed so now we can see it automatically added another one for us so if I click on refresh we can see that there's another job automatically added into our table in order for us to be able to monitor it from there so that's one level of it if you remember here inside my program.cs I have added the forward slash Hank fire so let's see what this will give us inside our application so now if I go to my browser and put localhost five thousand and I put forward slash Hang Fire we can see that I have a dashboard which is automatically running and inside this dashboard I can see the recording jobs that's going to happen if I look at it I can see here that it has been executed successfully in a few seconds a few seconds ago it has been created three seconds ago this is the current job that's spacing on and if I look here we can see that different information about the job that has been succeeded if I click on it we can see different data we can see where it's been executed so on so forth and we can see the actual execution code that we have and all of that if you notice I have not done anything I can see here the jobs that I have I can see that it is in queue right now to execute again we can see the ID for it etc etc and all of that has been automatically provided for me out of the box without me actually needing to do anything and that's the really powerful fan the usability and usability to manage all of these background jobs out of the box so now that we have done this and you have explored a bit the dashboard that has stopped our application and let's take it as a step a bit further and start create some kind of a background services so what I want to do here is I want to add a new project and I'm gonna call this project let's call it Formula One Dot services yeah you can call it whatever you want and basically here I'm just gonna create any random services so I'm just going to delete this I'm going to create a new directory and I'm gonna call this see uh email services for example email and inside this email again you're gonna have a much better structure for your services but this is again all for the demo I'm just going to create interface here all I'm gonna do is for example create an interface I'm gonna say email service I email service and the only thing we're gonna have here is void send welcome email for example that's gonna take a string as name we're not going to be building those Services we're just gonna be mimicking an actual email service we're not going to be really something and I'm going to use another one void send getting started email again string email here I'm gonna put [Music] email and name let's close this I don't really need it similarly here I need to put an email um what else can I say okay let's ask let us add something when I use a driver has been added so we I have added like I will send them a welcome email send them a getting started email let's send them something for example after another service after they score for example certain points or let's just keep with the registration let us create a merge for them so I'm gonna add a new interface I'm gonna call it I merge service like new merchandise for them like clothing etc etc it's going to be an interface and I'm just gonna put void create merge and I'm gonna take a driver ID that should be it should we create another one okay let's put another one for it remove merge let's say for example after a driver has stopped driving or it has been deleted so again go with driver ID okay so now that we have these different interfaces and services now let's just get a quick implementation again they're going to be pretty straightforward so okay everything in a single file that's fine let's just move it here let's just rename this to General and let's just update this again this is not a good name by any mean but just some things that we can utilize and here I'm gonna just create an implementation so the first one is going to be for the email service yeah I'm just going to inherit from the I email service it's gonna annoy us because we don't implement the missing numbers so we're going to implement them now and all I'm gonna be doing here pretty straightforward I'm gonna say console.writeline let me use string concatenation I'm gonna say this will send an email to no let's use the name and using the following email and we need to pass the email okay send a welcome email okay and then let's copy this put it here and set up for welcome email we're gonna put the cutting started email it's basically the implementation for the email service now let's create one for the merge so add new one I'm gonna put merge service oh again I'm gonna inherit from the image service it's gonna complain because we did not Implement them so let's Implement them now and here all I'm gonna do is I'm just gonna say this will create merge for that driver let's put the ID driver ID and here let's copy this just remove this I'm here I'm gonna say this will remove verse for the driver okay perfect so now I'm gonna go back to my terminal and I'm gonna go back to my library Formula One service and I'm just going to put.net build okay perfect build succeeded everything is running as it should be so now what I want to do here is I want to inject these Services inside my program.ts so I'm gonna come back here I'm gonna inject them also as scoped so we're gonna put Builder dot Services put add scoped and I'm gonna use the first one which is going to be the I email service and it's going to be email service and the nice thing about the rider is to kind of figure out this dependency and add the project dependencies so oops everything now works and here from the email as well perfect oops and now we need to add the other one for the merge so it's going to be our emerge service and merge service great so now that we have these Services directly available for us again these are all dummy services all we're doing is just basically putting stuff inside the console just so we can see the different implementation but again by no means this is our like for the functioning Services only for the double so let's add one more service just thought about this let's add something called a maintenance service so I maintenance service and this is going to be an interface interface and this is going to be just void sync records so here we're gonna be mimicking that at midnight for example where you need to do some kind of a backup or syncing the hour records between different databases so and so forth again just something that we can see where a background service might come into place and I'm just going to do a quick implementation of this so I had maintenance service I'm gonna inherit from eye maintenance and implement the missing number and all I'm gonna say here console.writeline this is a sync or we can say the Sync has started or something like that full sync mechanism now but you get the idea so now I'm just gonna update my program that yes I can Tri maintenance and maintenance service so now let us see how we can actually inject this the first thing is I want to remove this uh ad hoc crunch job that I added we don't really need it and I'm going to go back to my controllers and I want to go to my driver's controller and inside my driver's controller what I want to do is whatever I add a new driver I want us to basically run this background service where actually sends a welcome email so let's see how we can do that it's going to be pretty straightforward so before we get started implementing inside our controller what we're going to be doing is we're going to look into the diagram that we had at first which is going to be this one here and we're going to be seeing the different types of implementation that we can utilize currently inside our application so we're going to start by file and forget and this is a very good scenario in order for us to for example send emails if you want us to send a welcome message to the user say or to the driver in this case saying that welcome to the application etc etc so let us see how we can implement this so this is going to be the first one I'm going to change the color for it to purple and let's go back to our Rider here and if we go down instead of having get a driver let's close this so here we're not very well adding a dropper we need to add the background service here and first of all we need to get a job ID because that's gonna be what's going to be returned to us and then we're going to utilize the background jobs and here basically the background job if we hover over it we can see it's actually getting it from Hang Fire and which means that it's a background job assembly that I'm using we're not using the default one that does not provides so once that's done then I'm gonna put dot and here you can see that these are the different options that we currently have we can a schedule schedule in queue and schedule so the one we're going to be using right now is inq and then here what I want to do is I want to specify the service that I want to utilize and for sending emails we have an interface called I email service and then once I specified the service that I want to utilize then I need to specify what is the method inside the service that I want to use and in this case I want to send send the welcome email and for the send welcome email it's kind of honest but this is on a new line so I can see it so for the sun to welcome email it's going to require us to pass the email and the name so I don't think the drivers right now in the dto has an email so I'm just going to put a random email and for the name we're going to utilize it from the driver dto so let's use string concatenation okay perfect so now that we have this that has closed it here and all I'm gonna do right now is just print out the ID to make sure that this is running so I'm just going to put console Dot rightline and here I'm just going to put the job ID perfect so now that we have this let us run the application perfect build succeeded and then all I'm gonna do here I'm gonna go back to my web browser here I have my Swagger interface so I'm just gonna go to my post request I'm gonna create a new driver so I'm gonna put addicts album driver number 23 and let's say year of birth is two thousand yeah let's put this as a date of birth so now I should be receiving so right now if I take a look at the logs we can see here that I don't have anything running I'll have my job ID and if we go to the Hang Fire jobs we can see here that currently I don't have any jobs up and running so we don't have any jobs even here running but when I click on execute first of all we got a 201 which means the driver has been created if I go back here we can see that I have one Joy one one scheduled task that needs to execute on the q1 job so here I can even see what it is so if I click on it I can see where it's being executed and what's the value and we can see here as well the worker that's going to be picking it up and if I go back to my if I go back to my code editor here so I can see that the message has been created which is going to be this will send a welcome email to Alex album using the following email and here I can see the job ID and on top of all of that if I go back is not a recurring job but if I go back here now we can see it has completed and if I click on succeeded here we can see that it has been completed successfully and we can see that job ID which is 84 matches the job ID that we have got in here so in this case we were able to actually execute a fire and forget implementation of our job so that's going to be the first one so let's make sure this is implemented fire and forget perfect so now the other one what I want to do is I want to do it inside the update functionality so what happens here is inside whenever I'm doing an update let's say I updated the driver and I want like a job which runs in like a 30 minutes later which is kind of synchronize all of my databases because I have updated one and this theoretical scenario how can I actually achieve that it's going to be pretty straightforward to do this we're going to be utilizing the same thing as we have used inside the create so we need to tap into the background services so far let me get the job ID so we can match that and then I'm gonna put background services and then I'm going to utilize the schedule because I want to run and at the third time which is going to be 30 minutes and I'm going to utilize the eye maintenance service because as we said it's going to be like a database update so on and so forth and what I'm gonna do I'm gonna utilize the sync records capabilities there and now what I want to do is I want to tell it one it should run so I'm just going to utilize for this a time span and I'm gonna say add actually from seconds we can make it let's say for 30 minutes but to make it easier I'm just gonna put in 20 seconds and let me just put this on a new line so you can see it and here all I'm gonna do is just a simple console dot right line and I'm going to print the job ID let's go back to the diagram let's convert this to purple to make sure that we have covered it so now that we have this that's it on our application and inside here what I want to do is I want to update my drivers so I'm just gonna get all the drivers for now try it out execute and as we can see here I got all the drivers so I'm just gonna update my driver information so if we go back here to put try out let's take the driver ID and let's put it here so first name I'm just gonna put um I'm gonna put Al and driver number I'm gonna put it let's say 0 23 and date of birth I'm just gonna put it as I say 19. uh let's say 75. execute driver field is required let's see so we got a 204 and now if I go back to Rider as you can see here I got the 104 number which is going to be for my background job that I'm running here we should run after 20 seconds and if I go back to my web browser and I go here if I go to jobs scheduled jobs it's already in 20 seconds but as you can see here the this was a schedule job which is basically Run for the sync records and now it's actually running so if I refresh now should be still running and you can see here the ID which actually matches the number that we have from here and then we can see that the Sync has started after 20 seconds and now that has been finished we can go to succeeded and now we can see it here and if we click on it we can see that Clips here with all of the information that it has that it needs and we can see that it actually completed successfully perfect so now that we have covered these now let's go back to my diagram so now that we have done this the delay jobs now let's see how we can create a continuous job or basically a recurring job actually so what I want to do is back inside my controller I'm going to stop this what I want to do is I want when I do delete something I want to have something written in the background for example to remove the person's merch and basically I wanted to run every day around the same time to check if there is anything that has been deleted in order for me to remove the merch again this is all theoretical you can use it anywhere but this is where I want to implement it here so okay so here again I'm gonna do the same thing as we done before so now for the recurring jobs all I need to do is just first of all I want to put recurring jobs because as you can see here from this diagram it's going to be recurring so we need to address the recurring Library and then from here I want to put other update then I want to specify the the interface or the service that I want to utilize which is going to be imerge and then what I want to do here is I want to specify the actual service which is going to be remove merge it's going to take the driver ID and then here what I want to do is I want to specify the frequency so I want it to run every half an hour for example or every hour so I'm gonna put hourly and this is it once I do an hour now I need delete it will run this hourly but just to make it simple for now instead of hourly let's make it a bit less so uh minutely and I'm gonna run my application now let's go back to my web browser and whenever I do I delete let's get a driver ID so I want to remove Alex for example so we'll remove Alex and go to the delete try it out put the driver ID execute Regatta 204 and now if I go here first of all we refresh okay sorry under recurring jobs we can see that we have one recurring job that needs to execute which is going to be the eye merge remover and if we go here we can see that has not executed yet because we said it's going to execute every single minute we need to wait one minute until this execute and right now everything else seems to be fine now we can see like there's a bit of a spike going on here because it's actually gonna start picking this up soon what I can do as well I can click on something I click trigger now which basically means that it's gonna trigger this functionality directly but I don't want to do that I just want to wait for it until it actually triggers it this is basically the servers we don't really need to worry about this right now and here directly I can see that a jobs is actually running one of them is going to be the console right client that we have executed at first the other one which I just added which is going to be the remove merge and if I click on it we can see it's actually knows where is it coming from how it's being activated and which is the driver idea that it needs to take and then basically after a while we can see it I completed successfully and if I click on succeeded we can see the imerge has been completed successfully and I got the succeeded Mark and all of this right now is basically allowing me to execute those different functionalities that currently exist so I have already tried final fante Lane job and recurring jobs for simplicity's sake I'm not gonna go delve into continuous jobs and because I don't have a paid version I'm not going to be able to do batch or batch continuous but if you're interested in having a continuous job please let me know and make sure to create a short video about it and make sure that I'm covering it so there was one last functionality that I would like us to cover before we finish this video and this is going to be how we can actually secure our dashboard so I'm gonna go back to my program.ts okay so what we want to do right now is we want to introduce a username and a password for our dashboard so nobody will be able to access well permission so whenever our application was running as soon as we went to that path which is going to be in this case localhost forward slash Hank fire we will able directly see the dashboard now we want to secure it and the way we do that is we we want to update this where it says map Hank fire dashboard I'm gonna put here a new dashboard options and then here what I want to specify is we can specify the title if I want dashboard title I'm just going to call it formula one services dash and then here which is the important part authorization I want to specify authorization section and then I'm gonna put here the main authorization options which is going to be new Hank Fire custom authorization filter and then here when I initialize this it's going to ask me for my password again I'm gonna make it simple as pass and for my user I'm just going to put it as Muhammad and by simply adding those configuration here the hangfire pass and username I'm able to actually authenticate so now this is all I need to do in order for me to secure my dashboard basically right now within my username and password whenever I go to it it will be able to run successfully so now let's do a quick recap of what we have covered today inside this video the main items that we have covered today is how does Hank fire work so if we go back here to our dashboard sorry to our drawing we are able to actually understand how a client server and tank file storage work together how this all live inside our.net core application we then discussed the different types of Hang Fire jobs that currently exist we have even implemented the three of them inside our application and we discussed the rest and then we can we saw how we can actually secure our dashboard by actually providing it with a username and a password if you have any questions please put them in the comments down below if you have any clarification or if you'd like me to cover something in more detail please also let me know I hope you like this video please like share and subscribe it will have the channel as well if you'd like to support me please consider supporting me on patreon or buying me a coffee with that said have a great day and thank you very much for watching
Info
Channel: Mohamad Lawand
Views: 8,567
Rating: undefined out of 5
Keywords: .net, api, c#, coding, entity framework c#, asp.net core tutorial, .net core, asp.net core, web api, redis cache manager, dotnet core tutorial, dotnet core web api, dotnet core, dotnet performance, background service c#, background task, background worker c#, dotnet background jobs, dotnet backgroundservice, dotnet hangfire, hangfire, background tasks, hangfire dashboard, background jobs, hangfire dependency injection, hangfire c# asp.net mvc, hangfire dotnet 7
Id: cvpSx10z5Og
Channel Id: undefined
Length: 46min 44sec (2804 seconds)
Published: Thu Sep 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.