Publish/Deploy Blazor WebAssembly ASP.NET Core Hosted on a Windows Server with IIS & Web Deploy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to another blazer web assembly tutorial this time about publishing or deployment and i gotta say i've got this content from my blazer webassembly full stack boot camp so if you want to have a deeper look already check out the info card here or check out the link in the video description but of course you can just watch this video if you already have a blazer web assembly application to be more precise in this course we used a blazer web assembly asp.net core hosted app so a solution where you got the client project the server project and also a shared project so the client is using blazer webassembly of course and regarding the server we are using a web api with entity framework code first migration and also a sql server express so this is the complete stack if you're using this as well then i think you might find the information you're looking for in this video we are deploying this whole thing together with the database the server and the client of course on a windows server manually kinda because we're using the web deploy feature of internet information services or in short iis and we will use a profile for that so i think this is the most convenient way to deploy your blazer web assembly application together with the server on your own windows server machine yeah i think that's it with all this information and if this is the stack you're using then i can only say enjoy the video but first please click the like button and maybe even subscribe to my channel thank you very much for that thank you very much if you subscribe to my newsletter where you get information and discounts and maybe even free access to courses like this blazer full stack boot camp and also thank you so much to all my supporters buying me a coffee i really need this stuff as you can see here because otherwise i wouldn't be able to make all these videos okay now enough with that enjoy the video and if any information i'm missing please tell me that in the comments now the very first thing you would need if you want to deploy your blazer web assembly asp.net core hosted web application on your own windows server with iis is of course the asp net core runtime and as you can see here i'm on the website.net microsoft com slash download slash.net and then slash 5.0 and here it says on windows we recommend installing the hosting bundle which includes the dotnet runtime and iis support so i would say we download exactly that the hosted the hosting bundle for windows and when the download is done currently version 506 we simply install it maybe you have to do it manually maybe not let's run this anyways click run and of course we agree and then simply hit install not very exciting but this is what we need of course now additionally if you want to use sql server of course you have to install sql server and also i'd recommend to install sql server management studio it's exactly the same thing the same process we did on the client already so please if necessary go back to the lecture download secret server and management studio for your windows server install that and then of course you would need iis or internet information services and this is how the internet information services manager looks like but i assume that if you want to publish your application to your own windows server manually then again i assume that you know what you're doing here so if you have any questions about all this publishing about this publishing or deployment process please ask your questions in the q a section of this course but again i think you you know what you're doing here so with internet information services there's one more thing i recommend here if you want to use web deploy which might make deployment a whole lot easier because in that case you can deploy your application your changes from your development machine in visual studio directly to your service and to install or make web deployment available you see this thing here the web platform installer and you can go there and then look for web deploy and as you can see here i've got web deploy version 3.6 installed already if this is not the case for you then i recommend installing this thing because then we are able to again deploy or publish our application from our local machine from our development machine to our remote server okay so we've got the net runtime internet information services secret server and web deploy and the very next thing we need now is a database all right now i have opened the secret server management studio and this is actually an old one as you can see now it's secret server 2014 but this even works with this old version and in your case maybe you have a newer version so this should work as well anyways you see similar to our local machine or development machine we've got the databases security and so on and what we can do now is instead of using this trusted connection part in our in our connection string we can say for our blazer battles database we want to use a specific user and for that we create a new login under security logins and here we say secret server authentication and let's call this guy simply blazer battles admin for instance and give it a top secret password as always and then we uncheck enforce password policy or you can leave it of course again that's up to you as many things here with deployment and publishing but to make things easier let's just use the blazer battles dash admin with the password one two three four five and six so really really secret okay so with that we've got our user and now under logins you see there are a couple of users already we see the blazer battles admin and now we create a new database so under databases you see there already are a bunch of databases but let's just create a new one we call this now blazer battles again and here now we set the owner to blazer battles dash admin and hit return and there is our database now but the problem is we've got no tables now to get all our tables we go to our development machine real quick now as always we got a couple of options here but i think the easiest one is to create a script that we can run manually just one time on our remote database and when we make migrations we can generate this script again and then make these changes again another option would be to do this by code but when we do it with code then these migrations would be executed or run on the database every single time the app starts and maybe you don't want to do this you know there are situations especially in production when we run migrations automatically on startup it's it's enough it's sufficient when you just restart iis and then the migrations will run again maybe you don't want to do this and it's hardcoded it's not a good idea in my in in my opinion so let's do this really manually and what we can do here now let's first check we are in blazer battles maybe go to blazer battles and then a server and then we can use the net ef migrations and then script command as you can see there was some stuff actually printed here in the console and really the easiest thing here is to simply copy all this and then go back to our server right click the database new query and then we paste this whole script and execute it you see a couple of rows have been affected and this simply means that our tables have been generated we refresh the database and now we see them here battles units and so on there's one more thing we can do because our units are empty and this is something we edit manually in our application so let's go back to our development machine one more time and in here now we've got our units table and we can really just copy them the units maybe the first three in this case go back to our server select the first row right click and paste them and now we've got our units all our tables we need for registration logins and so on and now there's one more thing left to be able to connect to this database we have to change our app settings file so again back to the development machine and now here in the server project there's our app settings json and you see it here i already expanded this we've got the app settings json here and also an app settings development json file and now we don't want to change the connection string every single time we develop or we publish our application because in both cases the the string is different of course the connection string so what we can do now is actually copy everything from the app settings json and put it to the development json and then change the actual app settings json here because this then will be used on our server since the application is running on the same server as the database in well in this case we can leave the server at localhost sql express because it's still a sql express database the database is also blazer battles but now we have to add a user id which was blazer battles dash admin and a password which was one two three four five and six and now when we run the application locally the development json would be used the app settings development json and otherwise when this thing is deployed this string would be used and we can test this of course real quick everything is saved run this now locally with dotnet watch run there we are and when we want to build units you see that the barbarian is still here so we access our local database and in the next lectures you will see this is different with the deployed application now the very first information i want to give you is that we use the server project to publish our application when we right click the server project and then hit publish the client project and the shared project will be built and published as well so hit publish here you see that i've got some configurations here i played around with that stuff and publishing or deployment failed as well but if you did the same you could simply click new or if you do not have any configuration yet then you might see this dialog directly and then we have a bunch of options here and the last one is an option i prefer but in your case of course it could be different but in this case you would manually prepare your web application or website on your server and i would say we do exactly that first as well so back to the iis we right click sites and add a new website and here we can say for instance blazer battles and choose a physical path here create maybe a new folder call it blazer battles hit ok and for the host name this of course depends on the domains you have available but maybe we can say something like blazerbattles.patrickgod.com simply hit okay and as you can see i've got a bunch of websites already but now the interesting part is of course the blazer battles app or website and now we right click and then say deploy and then configure web deploy publishing we can choose a user for deployment and then the sql server connection string is not necessary because we choose the connection string from our app settings json file but then you would need a correct url and this would not work in my case so i changed that to patrick.com and then this is the port of web deploy or ms deploy and then we can change of course the file name and maybe we just call it blazer battles publish settings and then you just hit setup now we've got our file and then i copy this file to my local development machine and when this thing is copied we simply again select import profile then next and then of course we need this file now and we find it here in my case in the development folder hit open finish and now we've got our configurations here already for us we can double check the connection and it works you see this is the server now with the site name the user and so on the other way would be to choose web deploy directly without a profile file and in this case you would have to enter all this by yourself so this works and now we could simply hit publish again we have to enter the password you see that all the projects are built and now all the files all the necessary files will be uploaded to our server and when all this is done visual studio will open chrome or your preferred browser for us and already open the application and there we are you've seen it prepared to fight and this is our application and it runs on blazer battled batterygod.com in my case we can go to register of course and this takes a while now for the very first time but now we see knight archer and mage reload this and then it should be a lot faster as you can see let's register with i don't know let's use frodo again blazerbattles.com proto is the username again top secret password of course we don't need bio maybe we start with an archer and a thousand bananas register perfect yeah yeah of course and now let's login and here is our application and we can build the knight an archer a mage we see our army we can revive it if you want we see the leaderboard well we only got one user the history and so on but you get the drill this works now congrats your application is online and when we have a quick look again just to double check in our database we have a look at our users and there is frodo now and also the user units of course frodo has his user units all right i would say have fun playing around with your browser game or any other kind of blazer web assembly asp.net core hosted application well there you have it guys i hope this was everything you're looking for now you should be able to deploy your blazer web assembly asp.net core hosted full stack application on a windows server again thank you very much for your likes for your subscriptions for clicking the bell icon subscribing to my newsletter maybe i promise i won't spam you and again thank you so much to all my supporters to everyone buying me a coffee i really appreciate that i love you for that really okay thanks a lot for the time thank you very much for watching and i see you next time take care
Info
Channel: Patrick God
Views: 3,758
Rating: undefined out of 5
Keywords:
Id: IkveZO9TZtU
Channel Id: undefined
Length: 19min 41sec (1181 seconds)
Published: Tue Jul 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.