LIVE CODING - WordPress Migration to Blazor - PART 5
November 20, 2024
• 207 views
It's time! WordPress on AWS LightSail has been non-stop problems for nearly 2 years now.
Time for a change.
I'll be looking into using LinkDotNet.Blog by Steven Giesel as my blog engine of choice. But migrations are never easy, so this will be the first of many sessions trying to figure out how I can get my blog setup before going live.
Remember -- I need to keep as many links active as possible so I don't ruin my SEO!
View Transcript
all right just check in the Stream it's coming through think we're good to go awesome stuff guess my chat is still from from last night um awesome okay so we're going to be doing more on the Blazer migration uh from WordPress to Blazer it's uh spoiler alert it's actually it's done uh at least it's live now so uh for folks that are just joining the stream if you want to do me a favor uh test out if the chat is working please so I know across platforms that stuff's coming through otherwise I have to go watch on the individual platforms and it's streaming to six platforms right now so it's a bit of a pain in the butt if people are talking and I have to like go look on uh like LinkedIn directly or look on YouTube directly your Twitch so if you're joining
the chat please just say hey let me know it's working I appreciate it um but yeah like I just said we're going to be going through the WordPress to Blazer migration on previous streams regarding this where I was kind of leaving off was uh this process that I wrote so a little program that would essentially connect to my old WordPress posts so I had basically dumped those posts into a database and we wrote a program that would go ask that database for the post and then I needed to apply transforms so we were spending all of the time together looking at the transforms for that and then basically it would go dump those into the new data base which is what the Blazer uh blog engine is going to be looking at for posts so um that's an iterative process um and I basically what
over the weekend um spent a little bit more time and I said okay I think it's good enough like let's go live with it so it is actually live uh there are a couple of glitches uh I'm trying to sort through them so I think we're going to spend some time today um it's a the title of this is still labeled WordPress to Blazer migration but at this point it's more like diagnosing Blazer things in Azure uh so it'll be interesting uh the glitch that I'm encountering right now and it only happens in prod uh so kind of interesting if I run it locally I don't run into this but I'm observing that I have uh Blazer suggesting that there's uh like the connection is being terminated and if you're not familiar like I don't know ex like all the details for how Blazer operates
but I am aware that it uses signal R in websockets and it seems like what's happening is it's losing the websocket connection uh and we can see that in the browser uh but it doesn't happen Loc Al so couple of interesting things um I am wondering if going through Cloud flare is causing some issues especially because um it's proxied and I am very uh very curious to know if that's the reason um like that would be one very big difference between running locally or not um otherwise like the fact that it's in Azure like I don't I don't see that necessarily being an issue um but I mean that is another difference right like the environment is technically different than what I'm running locally so that's something to consider but the the real challenge right now is I don't have a lot of visibility um
when I like there is no logging active in Azure right now so I think that's what we're going to do is like I have application insights enabled in Azure but when I look there it's just like hey there's nothing so um I think we're going to try configuring that uh at the beginning of this stream seeing if we can catch a break and see if there's anything interesting going on um so that'll be the first step if we get through that um I would like to uh try getting Google analytics enabled again hey Maria uh thanks for thanks for joining now I know the LinkedIn chat's working uh doing well this morning a little tired I'm definitely going to take a nap after this before I start work so um yeah I think between yesterday and today just like a pretty rough start for feeling
like I'm not uh well rested so it's part of life I guess but uh yeah otherwise doing pretty good so we'll try doing application insights in Blazer making sure that's all working uh hopefully we get through that and then otherwise um I want to see if I can get Google analytics working I did talk to to Steph gel about the uh the Google analytics stuff he was saying he's kind of avoided it um I think for me I've just had like a heavy Reliance on it because that's the only thing I know um but I think the well we'll see once we have uh application insights enabled like I was under the impression it was the Google analytics change that was uh breaking the functionality for me and now I'm not so sure I think it was actually broken before I tried that um Patrick
hello good to see you thanks for joining on YouTube um Maria how do I manage everything I don't know I barely do um I I would say that it's probably not being managed it's just uh it's getting by so yeah I think let's dive into it um I am going to be going back and forth between like my Azure portal um I'm a little I'm still a little hesitant to do this kind of stuff live because I don't want stuff in the portal to like show that's like secret um so I just want to kind of have that disclaimer that there might be some periods where I'm not showing my Azure portal um because this stuff is live and like I said I'm just a little bit nervous because it would be really dumb if I like accident showed a secret and this is like
a live stream and it's recorded and I'm like okay like I have to stop the stream and go take care of this uh so I will probably do the Azure portal stuff off the screen but I'll explain what I'm doing so I just want to apologize for that in advance because I understand the experience for that probably feels pretty dumb um but I'd rather just be safe about it so that's what I'll be doing okay um let me pull up this article um and I got to get my screen shared so one sec I got got to move a couple Windows around here so we'll pull that up we'll pull this up and then let me switch over to the full screen view so this is the new uh website technically so I know some of it's hidden behind my my chat one sec let
me just undock that move this over um so there is like this post page right so this is like the archive so all these posts are migrated over from my old blog you can see back to uh 2013 right so this one doesn't have an actual picture so this is the uh default picture when I did migration but this is like one of the first blog post I ever wrote um so pretty short one but like you know things evolve over time uh if I pick a random one here right so this is actually another little change I made uh I did this yesterday um the the Blazer blog post that that Steven gizel had put together they they have the picture and they're used as like the preview but I wanted the actual blog post to show the picture at the top um so
it's like a like a oneline change but I added that in um resizes and everything and feels kind of nice to me uh but here's like another blog post that actually has like a YouTube video it's got the code integrated by the way all of this stuff uh I just like again I want to shout out stepen like all of this stuff just worked like I didn't have to go refor at this stuff uh I had to reformat things like some of the headings because if we want the U table of contents to work uh it doesn't work with HTML tags so if you were to look at the actual and we can we can pull this up if we look at the actual um contents it's a bit of a hybrid of like HTML tags and then like markdown which is a little bit
ridiculous but uh it works so um not going to complain about that uh it made it really easy obviously going forward I will just write my stuff and markdown but I wanted to migrate all of the stuff that I had written before I didn't want to lose like years of blogs um and then something else to call out too like I'm using the short codes from Steven that he added support for so at the bottom of my articles there's like a short code that I add and it will put in my newsletter sign up it will put in like an affiliate section so these are affiliate products I upgraded uh my upgraded updated I guess it would be an upgrade to uh I updated my my affiliate section to have like a link to Brand ghost which is the uh the social media platform uh
that I'm building for for helping content creators post content I have my FAQ section so this was if you were on one of the previous streams this section was getting really mangled um so it's no longer getting mangled but I will have some work in the future to do so um there's there's a reason for these FAQ sections and it's not just for extra content it's uh it's so that search engines can actually uh properly Index this it's extra metadata and if you're on Google you've probably seen this before um let me even just try like a app insights laser if I search for this see how there's like this people also ask thing so if you expand this this is be and this is to the best of my knowledge if you want to be picked up for potentially being uh like in the
people also ask thing uh there's like an a Json structure that you can tack onto your web page and essentially it tells the search engine like hey look there's FAQ content here so if I jump back this is supposed to be to help enable that functionality the challenge right now is that there's a lot of I was using Wordpress plugins to generate all of the the actual Json structure for me uh that's all gone now so I will have to follow up with that um I don't know yet how I want to do that and just to briefly explain I don't just think it's a migration thing because when I go forward writing more blog posts I want that functionality to exist it's not just hey like Port the blog post over from WordPress translate it once to make sure it has this Json structure
somewhere like I will probably need to write something um that will parse the content because it has a at least in my blog post I follow the same structure uh there's actually additional um like metadata tags that we can use so for example um there is one for people there is one for services so when I have my newsletter post I actually have a like a Json structure for services um you they have them for books for recipes and I'm just mentioning these because if you want to run a recipe blog or something like this is something that is helpful to know for getting picked up in search so I will probably write something that will look for patterns in my in my blog post and then create that Json structure um and then maybe even write like a checker or something on if I
scroll back up if I go back to this like admin page for the Post itself right I maybe I can write something that's like a checklist for SEO that's like hey like this is parsing out an FAQ section or this has like blah blah blah but I I think that that's probably something I'll be building going forward um I don't know how much of it will make sense to be like backported into Steven's blog engine if he even wants to use it but maybe some of the concepts he can take um I don't know how much time I'll spend making them generic to be honest but um if there's way like if Steven's looking at he's like hey that's cool I wonder if we could and come up with something generic then I'd be happy to like spend a little bit of extra time doing
that but otherwise uh it just it might not happen just because I don't have capacity for it but anyway um it's mostly working um I don't think we've seen yet the glitch where it'll show up at the bottom and it'll say that there's a connection issue um but we haven't seen that yet these ones that have a gold uh outline on them are members only so if I log out actually this is busted to um not a huge deal but uh it has to do with this return to it's uh it's not handled properly in O zero so anyway um if I log out now oh it put me my to Local Host amazing um don't use the logo button cuz you'll you're not going to be there we go so see at the bottom actually you can't because it's see here at the bottom
so this is what we're going to try to diagnose uh but my my logs uh aren't coming through so what I wanted to show you is that if I log out though um oh it's cached crazy that's not good um so maybe I have to go look at this but this is technically not supposed to show up because this is a members only post and you can see that I'm I'm logged out um so there might be something really fishy going on I still think that it has to do with um uh with Cloud flare um and maybe I just have to turn off my proxying through Cloud flare I was technically just using using that with WordPress so that I could reduce um the load on the server um and then have a better response time because it's all cached in Cloud flare so
basically as soon as someone hits the site if cloudflare has everything cached right there it's like here you go like immediately it doesn't have to do any processing on the server but I have a feeling to be honest my gut feel is that that's busting all of the stuff including the fact that we can see this and we shouldn't like if I can I hard yeah I just did a hard refresh and now see how it says the content's only available for members so I don't know and I could probably have debugged that like was it trying to pull from cloud flare and now this bypassed the cash was it local cash I don't know um so I guess probably that would have been local cash let me oh I want an incognito window one sec so obviously logged out let's pick a different one
so I don't know maybe maybe Cloud flare isn't the issue for the caching maybe that was just a local browser thing I'm not exactly sure uh but you can see again this error is coming up at the bottom if I pull out the debug tools um I'm seeing this I'm assuming that's what the problem is doesn't look good uh because it's losing the the web socket connection with the Blazer server side so what's really weird though is everything still seems to function from what I can tell so I'm just clicking around to show you but like as I click it's loading the post well sorry these ones are all member only let me pick an an older one that's not uh my newsletter so here you go right like it's loading everything oh this actually doesn't have the The Styling that might be completely unrelated
though I should take a note of this one um so the the migration tool that I wrote is item potent so I can run it again and it will just like it's not going to add like all the blog posts again and it doesn't delete them and read them it will update them if they exist because it's maintaining this post ID so uh with that said it's actually safe for me to um to just keep rerunning it and what I've been doing is every time I find a post that didn't have the formatting done properly so this one could be because the server uh stuff isn't working kind of doubt it because I think this is just styled in the front end but every time it's not working what I do is I take the post ID I take the raw HTML that's in the
database from the WordPress side I put a snapshot of that let me just show you why am I talking about it um give me one sec it's still early here um so you can see in the left nav here uh I have these migration scenarios so I would take like this is a huge blog post I have and it was really busted because I was using some fancier features so basically I have an input and an output file and every time I'm changing the conversion process I rerun these tests and uh if any of them break I just update the output file and then I use uh git extensions to go look at the diff so it's really cool I have this colored view there's probably other tools like snapshotting test tools that to do this but uh I'm just using git and I can
see like did it make this blog post better and in fact when I was doing a bit more migration there was I was noticing some of the previous migrations were air quotes breaking but when I would look at the diff they actually were approved so then I would just update the snapshot so this has been kind of nice for going through that process um but maybe one thing we can try doing if I alt tap back to um here so this one's 5748 right let's go take this sorry I realized I said I was going to go down One path and we're going down another but whatever it's fun right um I still want to get application insights working but I'm derailing myself already if I go run this now uh obviously this is like a kind of a hack way to do this but
just hold on and we're going to copy and paste this one we'll have a Blog six input and I will change that and then I'm going to make another copy and call it blog six output uh are there better ways to do this um probably absolutely yes but like this works uh the migration stuff is supposed to be shortlived once I have it working it works uh I'm going to keep the code around though because if I'm ever in the future at a point where I'm like oh man I found an old blog post it's a little bit you know busted up because of how I wrote this I can just rerun it again and I don't have to worry uh for the most part I shouldn't have to worry so um let's go run this and what I'm going to do is I'm going
to take the input okay I'm going to take the uh so basically this line here line 132 has the pre migrated content and we're going to stuff that HTML into this text file and then we're going to look at what it what it output so let me go run it I realize this part's not very exciting I'm sorry should go pretty quick though there we go so if I look inside of content here it's ridiculous or this is a whole like HTML file um and this is what it looked like before it was migrated okay so all the HTML this is literally what was on the WordPress blog and so for just to give you an example like I'm stripping all of this out with uh parsing uh like regular Expressions um a little bit above here this is being pulled out so we will
see that in just a moment but this code here was what I was using to put um a table of contents on every post and Steph has that built into the blog engine now so um I am pulling this out or else we just get left with like a bunch of you know bull crap on the page uh this here is a short code the short code syntax from WordPress is different than what we're using in the Blazer blog engine very very similar uh it's using two square brackets and then uh and then like a name so these get migrated I'm just calling out a couple of things to show you and then we'll see them in just a second but um I suspect something's going pretty weird with um with uh this pre-formatted code sections so I don't exactly know why but it seems
like those are kind of breaking on this particular page so I just wanted to have a snapshot of this one so put that on my clipboard um I will close that out and I'm just going to go put it over here so now I have it saved um let's go do a check sorry I jumped around too far let's go do a check on the migrated content I'm not going to look through all of it I just wanted to call out like if you notice up at the top here that whole really big section that says that's actually what's supposed to be right here uh it's all pulled out so the table of contents code is ripped out and then this uh short code has been converted so it might not be fresh in your memory because you weren't paying close attention and I don't
blame you um but it used to be one square bracket and then the ID was in quotes So this has been migrated same with this one down here uh it's off the screen for you sorry uh this one has been migrated so that works all of the HT m l titles are now um markdown titles so it's all working but uh it seems like this stuff down here sorry it's off the screen seems like these code blocks are a little bit dinged up uh I'm not sure why um but now we have a snapshot of it right so the thing will be that I can go you know fix these up and then I can write a parser that's going to correct these and I using I should use air quotes on parser um I'm using a regular expression to do a replacement so we'll
patch those up as needed uh but for now uh I'll leave it and just to illustrate if I I should probably make this better too and just scan for all the files so that's another little enhancement but if I go run these tests let me build it first we should see that there is another test added here so this last test should fail now right so um I can take the output of that and dump it into this text file and now I have like a baseline to compare against but if I change any of the article conversion logic then I have a bunch of other baselines that I can go compare against as well so anyway I'll tackle that off stream because it's probably um not super exciting but that's that so getting back to this our goal is that we want to go
address this guy down here but I'm not exactly sure where that's coming from so that's the incognito window let's pull up um this I'm going to get rid of my my email inbox so that doesn't accidentally show up uh but we weren't seeing maybe I can get it to repeat like it's not showing up on this one if I hard refresh does it no so it's not like it's not a guaranteed consistent problem uh I was curious if it had to do with www out the front still no um so like yeah it's not always happening and you can see in the console I'm not getting connection issues so it's weird because I don't know what the criteria is for it um I just tried to refresh there we go and right now it just seems like it's corrected I am logged in if I
log out does that change anything it's kind of weird like I don't know how to reproduce it so I'm logged out if I do another hard refresh still no so look I I fixed it um not really happy with that so let's let's continue on though what I want to do is add application insights so I'm going to make sure that we have this n get package added I'm just going to copy and paste the name uh bring it over to this is running locally so let me stop that we'll go to manage Nate packages here uh application insights is one of those things like I've set up before but it's so infrequent that I do it that anytime I do it I feel like I'm uh relearning absolutely everything so um we'll add that in great um now that that's there I think we
need to go to program.cs why is this not scrolling there we go so if I jump back to this article uh on logging we should be able to do this kind of thing I don't think I need this part sorry this is I don't know why this right panel is like I wish I could collapse that anyway um I don't think I need the filter part I think that's to create a category that you can filter on so I'm not super concerned about that but I'm just going to cut and paste or copy paste I can't cut off the internet can we do oh it's not on a service one sec uh I'm also uh sensing that my my USB hub buffer is overflowing because my keyboard is uh sticky if that makes sense so some of the buttons I'm pressing are delayed and you're
probably going to see something like like that happen um as I'm typing so just a heads up if you see me type ridiculous things it's because uh My Hub is uh having some issues okay so here is the thing really doesn't have Okay so this should be what we need which is great but I need to configure it in uh in Azure um I don't know what other options we have on here can I see options yeah sorry it's uh if it seems like I'm going super slow my keyboard is is having a lot of fun um there's not a lot of options this one's interesting track exceptions as exception Telemetry get or set a value indicating whether to track exceptions as exception to lry default I think that's what I want anyway so that's probably good um I don't think we have any options
we're configuring on this um which is cool yeah maybe I'll leave it there um it does mean that we have to get the uh connection string set up uh and I will do that in the Azure portal so what I'm doing on the side you can't see it because like I said I don't want to necessarily share my portal I just want to make sure that I have this connection string set up so what I'm doing is I'm navigating to the web app um maybe maybe what I'll do is I'll navigate there and just make sure that it looks okay before I show anything because it's it's literally like all of the settings um so this actually does look okay one sec ah okay so you you can see application insights connection string right so I'm going to be changing that value uh I don't
actually know if there's anything private in there so I'm just like I said I'm not taking any chances so if I show it I do have something set there so maybe this will just work immediately um otherwise I need to go double check the connection string and application insights uh which I should probably just do to be safe so uh I'm going to navigate there on uh on Azure portal as well so if I go to the web app itself application insights is a tab I'll pull it over if it makes sense um I don't see the it says it's connected already but I feel like the logging's not going through anyway I think it's probably be okay so I'm going to push this change we should get a build that goes out um and maybe I probably want to put this in an ify
buug not debuff um we don't want to debuff anyone but I think like I don't necessarily want to run application insights when I'm just debugging locally I don't think um or maybe if I do I can have a way to configure it so that I can tell it's debug only uh but let's go ahead and oh if not debug sorry there I only want this running in production is what I was trying to say um but maybe just to to try it locally I want to make sure it doesn't crash on start because that's no fun I don't think I have this set locally so maybe it will okay yeah so value can't be null that's okay um I'm I'm good to try this we can always revert it um that's a nice thing so I will push this there's my git history nothing too
exciting there um I just wanted to double check it so yeah uh props file you can see that I'm adding application insights and then just this block of code so nice commit message and then we wait and that'll go deploy automatically which is super nice um on that note I set it up in Azure it's a it's called a in Azure it's called a web app um I feel like that's actually not what I want and the reason I think that is like so when we're deploying brand ghost brand ghost is also done through Azure it's a container app and one of the it's actually having or it's had negative side effects for brand ghost the container app stuff scales automatically which is like obviously that's like a helpful thing like it kind of feels like magic except I designed a bunch of stuff to
be like monolithic and not to be run in parallel like it assumes only one instance ever so that has been problematic for brand ghost but like long term that's absolutely what we want like I should design that code to be run in parallel and that kind of stuff and I've converted some of it um however like what would be really helpful for this blog is like if I had uh replicas right so with brand ghost when we push up and it's deploying like the site just stays active because there's replicas and it's all just done completely automatically for us which is super cool so I don't know why and I don't I feel like I misclicked or something when I was setting this up but I made it a web app and now I feel like I'm being super silly and I missed something because
technically what happens is like when this is deploying my website goes down because I'm not paying for like these deployment slots and stuff and to be honest I don't think I want to do that I think I I haven't like read enough into this but I think I just want a container app in Azure and that way it just does it because it just does it for brand ghost and it's uh I think it would be so much more convenient here um that way there's a replica that's running for a little bit of some older version of the site whatever um it's probably only really an issue if there's like schema changes or something and then like it it breaks it but like I think that's going to be such a rare thing that I would rather just have the up time um so anyway
I might look at that later add that to the list um but I'm hoping that what we'll be able to see with this is that we get uh the logging taking place um in application insights so let's see if I can go back here uh application insights oh the connection string is is on this page I don't know if the connection String's private they don't automatically hide it from the UI um so I don't know feels kind of weird um but what I want to do is look through some of the logs and maybe it was was already here and I was just being dumb uh I didn't see any of these tables before Chris Blazing so Chris is actually a new C convert um welcome to the club uh you'll never go back to using anything else um I'm just kidding it's uh it's
only the best language ever but um there are other languages out there I understand but yeah I think Chris is enjoying c um which is great to see uh I know like Pro probably for a lot of people that you know they've been doing either front end development this isn't my Dev account though oh this is the um this is the uh what do they call it uh guess it's like your is it like your posting account kind of thing blazing yeah it's uh it's cool stuff okay so I didn't realize I didn't see this before I think I went to maybe the wrong spot maybe we didn't have to do any of that um but there is this exceptions section and I think what I did was I went to the the applications log itself and there was no tables so I didn't see
this which is cool so um can I just ask I hate this I hate the UI for for this stuff in Azure it's like the most I don't know it's not intuitive to me at all like do I just click run I don't have a query like I don't even know what query language this is type your query here click one of the queries to start okay queries reports and failures can I run that no no query was selected oh if if you double click it it adds it okay now I can see the syntax no results found okay um that sounds made up failed operations okay nothing um we know something's wrong so nothing okay Patrick says it's AQ Azure query language it's interesting this looks like um we I I don't I don't think it's only internal we use something called custo uh
and it looks very much the same um but maybe this the synta I thought that was called kql like cous so query language but it it looks almost identical um I don't know if there are actually differences but I don't know why like we don't see any errors here like that just seems wrong to me and maybe it's because uh we actually did need to make that change and we were just waiting for it oh Patrick I'm just kidding I have no idea what come on man you're throwing me off here yeah I think like I don't know if this is officially like kql like custo query language but um like when I'm doing stuff at work so I work in uh in Office 365 on like the routing plane so when we're like looking into traffic patterns and stuff like we use like custo
query language when we're looking at uh failures or just insights across the board we use it in like deployment like we use custo uh a lot for different things but we use a lot of different data sources as well so uh custo is I'm saying custo and I'm like I wonder if people listening to this are like what the hell is custo um I'm pretty sure custo is a thing outside of Microsoft though custo query language yeah here we go I'm not I promise I'm not making it up I've I talked to my friends about custo before and they were like what the heck are you talking about but you can see like this syntax here I think so I think it's the same thing it kind of looks like SQL but it's not SQL um it's custo so there we go um okay I'm
just checking to see if my deployment went and I think it did so maybe my site will come back oh application error very nice that's what we want to see okay is that going to show up in application insights now see all of these are like requests I don't want requests I want exceptions can I just do like limit 10 there's there's just nothing um and now my S's down so excellent that's really cool um you can access Diagnostic Resources show me them I have it on my other screen so I'm not I don't I'm not prepared to show you what's on the screen because I don't know what it's going to be it's probably going to take me to this I bet I'm going to cry if it does oh resource not found oh man okay um so that's a bummer so we don't
have log information there uh let me go back to get rid of that tap sorry I'm doing it off screen just because again I don't know what I'm about to click on to and I'm nervous that it'll be something we don't want to see um maybe I will double check again that my um my application insights connection string is actually as expected I'm not not totally sold there was one there so want to assume it's the right one but like do we actually know that no we don't so let's see application insights let me click that I will get the connection string from somewhere I saw it before now I can't see it change your resource no I think that's all right um again sorry I'm doing this on the other screen yeah I can't like oh there it is that connection string so I'm
just going to do this comparison quickly on the other screen but so far it is looking the exact same I'm just double-checking the application ID now because I think that's the only thing that could be different so I don't know it's there um and I'm double-checking this this application insights connection string is literally what I have in the user interface in the setting so it just it's just not working and it's crashing on Startup and I have no um visibility so that's super annoying um cuz this is saying like this is all we got to do I know it says this filter I'm pretty confident with don't have to do that um now it just goes on to like use it right like in this example it's just like and now you can start logging stuff which is great but like I can't um so
I don't know why but that's uh that's super annoying so if I go to yeah the whole site's just down it's just like running on AWS that's not throwing too much Shade that's where I was running before and having issues so um okay next thing I want to check is the log stream on the app to see uh if there is stuff breaking here okay I do actually have perfect we have logs okay so a stack Trace now can I actually understand what's going on here different story let's see does it tell us anything get service what service is it trying to get if you see something that I don't please let me know didn't respond to like so it's it's not responding to like a health check so that's fine I mean it's not fine but that's not the exception um um logging is
not Ena for this container that's at the container level so maybe not a big deal um do I have to go pull like this log file see like this is weird like I don't understand why this isn't working the Chris is saying uh container Port mismatch it shouldn't be it shouldn't be because this is all handled like automatically for us so like at no point Have I Ever Had to configure anything on the container um I wonder though maybe what I'll do to maybe we can debug this locally uh and I took a bit of a shortcut so let me pull this back up um let me do this I'm going to put the application insights connection string into uh the actual app settings here so let me do that so I don't think I have anything private in my app settings uh I don't
okay so just to show you um connection string there isn't even a connection strings section uh this one is different I think there's supposed to be connection strings as a top level so like this and then I can go add um yeah basically this kind of syntax and I'm just going to go copy and paste our connection string into here and run it and we'll see uh what we get so let me go do that briefly sorry I'm doing it off the screen that's the top of my car okay it's running it's not exploding okay um wo it works locally um it works on my machine right ship it okay so if I navigate there locally sorry my computer is going slow so this is the local instance it's running so this is like obviously a pretty annoying thing because um I have it configured
it's running locally no errors the same thing like I was running the site locally no errors and I'm not getting connection uh interrupts so I don't know I don't even know if I want to spend time like just trying to debug this on stream because it's a pain in the ass um but yeah like it does work locally and you can see like this is not great out now it's actually doing this um I wonder hold on um this is interesting the let me explain this uh let me stop this sorry it's all it's all coming together right now I'm just going to remove the connection string because again I don't know I don't know if any of it's actually private and okay so let me explain this briefly you see how there some of these have a hierarchy to them I'm just collapsing the
ones with the hierarchy so there's a little arrow when we can expand it right so connection strings is one of these okay when we're configuring them in the Azure portal if you want to have connection strings with a sub item like this the way that you need to do that is you would say connection strings double UND oh see the keyboard buffer awesome okay so you would do connection strings like this and then you would have a double underscore and double underscore tells it that you want to Nest it within so basically this type of thing um would give you the same setup now there's an interesting little thing that I want to see if I can show you and it's not there uh give me one sec I want to pull it up on the screen because I don't know if this is the
issue but we'll find out pretty quick and if it's not it's not whatever um but if I go to uh the application sorry I'm navigating there give me one moment uh environment variables I just need a sanity check that everything's hidden to start with great okay um let me try to get this all on screen at the same time there's got to be a better way to do this okay one more second here okay notice when I said I need connection strings double underscore application insights see how these ones don't have it there's actually a whole connection strings tab I it should check this because um basically what I'm getting at is if we look at some of the other ones like authentication double underscore domain um that's going to be like this block here authentication double underscore gives you this nested property um so
I wonder if my connection strings tab let me make sure it's all hidden to start with my connection strings tab doesn't have it um so that's interesting now maybe I am being kind of dumb here oh no it is using connection string so just to give you an example if we just did this why does that not work oh whatever but basically um can I just index into it sorry my keyboard Ward doing the lagging thing I think if we did this I bet you this works and I just want to repeat it one more time in case you're like Nick what the hell are you talking about um doing configuration indexing into it would give us um basically like one of these top level items okay but when you use connection string so let me put that on my clipboard oh my God the
keyboard buffer struck while I was doing control Z and basically um undid a bunch of stuff amazing I got to get that fixed I don't know what's going on maybe my computer just needs to restart okay so see the difference between these two lines when we use connection string it is literally a builtin thing that's looking for connection strings and then an like an indented sub item so so I I think that I need to go set my connection string uh for application insights in the portal and it will create the nested one for us so hopefully that's not too confusing so what I'm going to do is uh pull this screen back up right I'm going to go add a connection string off the screen for us um I have it over here somewhere once SEC and this actually should redeploy it I think
so the value is going to be that and then it needs to be whatever's in the code so this guy I am going to put that in apply it apply and now it's saying your service May restart that's what we want so hopefully hopefully this works um but again another solution um based on how this was done like I it might not have been obvious because I'm jumping around and I apologize um because this already existed in here this application insights connection string because it already existed not nested underneath a connection strings element in the Json I bet you if I go back to the code I bet you I could have just done this because it's not like this is looking for at the top level and uh that's just not what it was expecting to do so the basically the tutorial code is
saying yeah should be a connection string but the default I didn't make the default one it was already an Azure is not put it under connection strings so uh Chris is saying so here you're indexing directly but the method you were using before is a getter with the uh it's not it's not quite a fallback value um it's just that get connection string this um it it literally and typing on this keyboard right now is brutal um it's literally looking for see how crazy that is it's a stream programming okay so not quite it's uh it literally wants this Json structure So when you say connection string it's it's looking for this and if you don't use connection string and you just index directly into it um then it would allow a top level item like this and the J B on so hopefully that
makes more sense I realize it's a little bit weird um but hopefully this keyboard buffer man it's something else uh hopefully the deployment happens soon let me jump back and see where things are at here uh we should be able to see it here I think when did I do that maybe not well does it work now we fixed it we fixed it connection strings wo um now we didn't fix the actual original issue uh but it's not reproducing consistently which is a pain in the butt uh but now we should be getting logs to application insights which is really cool so if it does repeat itself I'm just clicking around to see if I can make it do something um I don't want to type my login on this screen in front of everyone stuff like that makes me nervous even at work I'm
like I don't feel comfortable doing that and it's like it's obviously masked but something about it makes me feel uneasy not that I don't don't trust all of you obviously I trust all of you but it still makes me feel a little uneasy so um you know I can log in that's all working if I refresh the page basically I'm trying to see if I can reproduce the the socket issue that we were seeing and so far no so I don't really know to be honest so if we go back to application insights I mean is it working so Adrian saying not true get connection string get the config connect connection string and not connection strings uh I don't know like we literally just fixed it doing doing this right and it won't work if you already have one connection string for your DB yeah
I sorry Adrian I'm not sure I'm following um so maybe you're responding to Chris I don't know this it fixed it what we did so uh sorry and Top Cat I didn't realize your comment on on Tik Tok when you do it like that I have a hard time to call it I don't actually know what that means so I'm sorry um and then Patrick kind of like you run a delete statement in production database yes exactly um except the good news is I can migrate all of my data back again so as long as I don't run delete statement on the wrong database we good uh and funny enough uh just to show you this is kind of kind of good okay look at this speaking of running deletes in production uh if I uncomment that and run it it'll blow away all my
blog posts but it's on the destination which is the Blazer blog so that's okay as long as I don't do it on the source one we're we're all set so fingers cross that never accidentally happens and I lose all the originals the connect so top cat saying the connection string I have to create a class then call it I I still don't really understand like I'm the connection strings are being loaded from the the app settings so we're not creating a class so sorry I just might be misunderstanding but um this is how you load application settings in in C so I I apologize if I'm misunderstanding the point that you were trying to get across um but interesting I don't really know if we're getting anything useful um like can I go to logs now and we see uh page views like can we
see anything or we got to go to queries that's right browsing data Pages like I don't actually think any of this stuff just works but no query was selected I don't no results found okay um can we get anything to work I don't know man so it's not crashing which means it's at least sending data somewhere uh apparently not not here or at least I can't see anything uh and I don't think we have any failed operations yet so so this table's on the requests right and I tried earlier doing exceptions and then I did a limit of P right if I go looking there's no exceptions yet or it's just not actually sending things properly but uh we saw it go from crashing on start which is why it said application error to now it's uh it's started and it's doing something okay I'm
going to jump back to the code uh topcat on Tik Tok is saying how do you call the connection string say in some method we have created uh you could do this um the this is probably going to look brutal because my keyboard buffer is like uh totally screwed up so I apologize you're going to see like like that kind of thing happened but public seal class NYX class we can even use a primary Constructor use I configuration config and then we could say uh public void XXX whatever the method is and then you want the config if you want the connection string there you go so that gets you the connection string the alternative is you can paste it right into here but like I'm not going to put for I don't want to put connection strings hardcoded into my application so um that's
how you do it or instead of like I was saying if you don't have it nested under connection strings uh you could just say get it at the top level this would also get you your connection string so hopefully that helps cool uh thanks for asking I'm glad that cleared things up for you um again the reason like this works really nicely is with dependency injection so if Nick's class was registered on the dependency container um if you're not familiar with dependency injection like highly recommend you look into it it's like it's like lifechanging for software development um instead of having to say like new thing and then pass and the dependencies and the passing the dependencies for that uh dependency injection just allows you to have that wired up in a what feels like uh an automatic magical way um I literally cannot write
code anymore without dependency injection um so when you go to ask the dependency container hey give me NX Class it will give you nck class and it goes hey to make an instance of nx's class I need an ie configuration let me go see if someone's registered an eye configuration and by default for th for us this one is registered so simply asking for this from the dependency container will give you one with this inside of it um and then yeah uh Chris is saying dependency injection makes testing 10 times better too yeah so um and then Patrick saying in Blazer it Force it's forc di yeah so um it's uh it's just so convenient uh if you're building an asp net core you you get that too it's like built in um you can just go new things up but like it it just
makes no sense to do it when all of it's on the container for you um it's it's truly like the first time that you like use it and it starts to click for you because I think even for me in the beginning I was like I don't understand why you would ever do this but uh once I started using it I was like oh man like cannot cannot go back um and yeah so Chris was saying it makes testing 10 times better uh what I have found so I I do actually like having unit tests for code but um I write unit tests in a way that will mock out all dependencies so they become very brittle the tests do um but that's how I write unit tests my unit tests are testing like they will literally go over implementation details and I isolate my
My Method from everything else or my class at least from everything else Now using dependency injection and functional tests especially if you're using things like test containers is like like again like a life-changing thing from a testing perspective I can create my container and it represents what I would have essentially in production except I might override some things for like a local testing environment like the database I want to access and I can say hey container give me this service and it will go pulling in everything that it needs to do just like it would in production so that way I'm dealing with like as close to real things as possible and then I can just go run methods on it so um it's a it's it's awesome uh so topcat saying you should do a vid on it says Unity test I don't know
if you mean unit testing or like truly in unity some of my first YouTube videos are on Unity uh which is kind of funny one sec um can I can I see that easily it's a bit of a throwback it's funny too because like the quality of them is obviously terrible and because they were around for a while I remember like looking and I was like holy crap people are actually watching these um let me I got a lot of YouTube videos holy crap one sec says I have 340 YouTube videos and I got to go to the beginning and I can only go one page at a time oh my goodness we're almost there I promise final page coming up okay what do we got my first YouTube videos um yeah look at these I even got oh we should watch this this would
be cool um when I say cool I mean probably not um so one sec let's see can I how long are these videos they're they're pretty short so yeah like here's a YouTube video it had a thousand views that's cool um that's better than most of my videos do these days so yeah some of my earlier ones are for making games in unity so um that was pretty fun Justin saying uh very interesting on the keyboard buffer I've been getting the same thing lately I go to pay something and it pays three times in succession yeah I think um from what I've heard it's like an overloaded USB hub but the really bizarre thing is that I use a KVM switch to go between this computer and my what I use for development and it's the same Hub and the same device as plug in
and I don't have this buffer issue on the other computer and it just started happening on this one so I I think I think what's happening is I just need to restart this computer and it's actually an issue with the computer um that's my guess so it's uh it's super annoying though um but let's see let's um I want to pull this up can we just watch it look at this look at this in all of of its Glory so this is a a role playing game I was making um it looks like crap obviously um but you it's like a turnbas game it's super dark because it's nighttime and you can walk around and stuff casting spells it's really hard to see sorry but there's skeletons walking over to attack and you can look at look how cool that is I miss making games
if I if I could retire like right now and like never have to worry about money ever again I would absolutely make video games like 100% um I think it's so much fun so anyway that's that's the game that's the game actually that I rebuilt many times over 20 years and uh I actually used that for my first internship to get a job um and it probably did more and looked better like like 15 years ago so kind of funny how that works um wow yeah some of these are super old you want to see what I look like when I was a kid and by a kid I mean only four years ago one sec look at this that's when I had hair look at that that's me my my youthful days yeah early YouTube videos um they're all terrible but it's uh it's
a journey right so um I made a couple back in like 2021 2020 and then I was like I don't know what I'm doing why am I doing this um actually we should watch one more okay sorry I'm I'm wrapping up the stream basically but I think this is this is a funny one so this is totally unrelated to anything else okay but I want to explain this because this is some some Nick Lore okay this is security camera footage from 2016 this man came to my condo and stole my Roomba and you heard that right this man stole my Roomba okay so the story the story is that I was having uh a buddy over for New Years he was visiting from out of town so one of my high school friends and we said we're going to go out on the town tonight
and we're going to celebrate New Years so we went out and the place that we plann to go was actually closed for New Year's and because we had no other plans and it was last minute we were basically forced to go stand in line in uptown waterl in Kitchener Kitchener waterl area this is back in Ontario and we were just stuck in line with everyone else trying to go celebrate New Year's and in typical New Year's fashion like everything's overhyped it's terrible and I said you know what we're just going to go back to my place and it'll be fun and there's a couple people that we were standing in line with and they were like that sounds fun like we don't want to wait in line either so we said no problem had a couple people back over to the condo to hang out
now I know that sounds kind of suspect because like yeah they're strangers but whatever we were already hanging out together for like two hours in so we go back and this guy is completely wasted and he decides that it's time to go home and he also decides it's time to go home with my Roomba so let's watch and I want you to pay very close attention to this man's angles which sounds like a really weird thing to call out but he's got my Roomba and watch his ankles okay see that's literally my Roomba his name is peral this guy thinks he's brilliant okay watch his ankles watch his man's ankles get ready for it not yet it's coming though see he's this thief it's a neighbor actually I think that's his girlfriend so he or his friend or something I don't know if it's his
girlfriend he's trying to escape with my Roomba there it is see that look at that ankle roll look at this ankle roll that is a sprain there is no way that man is not spraining his ankle and that's Karma and to add insult to injury this man steals my Roomba and he leaves the charging dock so not only do I not have a Roomba and I only have a charging dock that I can't do anything with this absolute idiot has a Roomba that he can't do anything with either because it can't be charged and he's probably got to go to the doctor for this stupid ankle look at that absolute idiot anyway the police didn't do anything about it as you might expect because it's just a Roomba but that is um that's the story of persal going missing so um there you go that's
what you get for staying to the end of the stream so thanks folks I'm going to wrap up uh unfortunately there's no um helpful log information I don't think it's a good use of time if we're all just sitting on the stream uh watching me try to diagnose uh not having exceptions but we got uh application insights wired up I realized that wasn't too much too much progress so I apologize for that um so we do have that going I am probably going to take some time today and try to drop in the uh Google analytics stuff um maybe maybe I can see now if I drop it in it will not actually be an issue because um now that I've seen it crashing on Startup I thought that when I was getting that uh that socket exception we saw it earlier on the stream
I thought that was being caused by the Google analytics thing that I dropped in because I had only seen it once I had put that code in however now that it's been removed we're still seeing it and I've seen an example of it crashing on Startup I don't think the Google analytics stuff was actually an issue so I'm going to go ahead and put that back see if it actually is reporting stuff to Google Analytics so that's one step um which is good and then um yeah I'll have to diagnose what's going on with um the uh the socket stuff um again it's really bizarre because the whole site Works snow but um I have not yet seen what functionality is busted because of the socket stuff but I don't want people visiting and it's like got this bar that's like hey this site's not
working that's not a good experience for anyone so um I hope you enjoy en that a little bit uh again um don't steal people's roombas I think that's not a nice thing to do they're expensive man like don't do that plus I invited you over like how how rude what kind of guest steal someone's rooma right unheard of okay thanks folks I will see you next time uh it'll be Monday evening next week for the software General software engineering career advice live stream and then uh next Tuesday Morning same time we'll um probably switch gears away from this specifically and um start building some stuff with AI so uh I'm going to be doing a mix of YouTube videos where I um I'll have them edited so they're a little bit more polished but I'll try to build things with AI like specifically so hey
chat gbt go make this go make this next and we'll try it out but I'm going to try it on live stream too um just to see like how how painful um so for the stream stuff it is on I'm going to type it into both chats Monday 7 PM Pacific is um Pacific can't spell sorry career I really can't type today let General course keyboard buffer and um and then Tuesday at 7 AM Pacific is live coding uh Pacific here we go so sorry I typed that on Tik Tok um if you're on the other platforms hopefully you heard me say it but Monday 7 p.m. Pacific is General software engineering stuff and career advice uh that's also like an AMA by the way all of these are amas if you just want me to talk about stuff just ask um so that one
I try to gear more towards General software engineering 700 p.m. Pacific and then 7 a.m. Pacific on Tuesday so the next morning I try to do live coding so um another reminder if you're watching this on a platform and you're like I just happen to stumble upon it here if you prefer a different platform it goes to YouTube it goes to LinkedIn it goes to Twitch it goes to kick it goes to Twitter uh it goes to Facebook and it will go to Instagram as well uh when I'm doing the career one cuz watching me code on a vertical video is probably the most painful thing aside from that guy's ankle roll but um with that said thanks for tuning in folks and I will hopefully see you next week so take care
Frequently Asked Questions
What is the main focus of this live coding session?
In this session, I'm focusing on the migration process from WordPress to Blazor. I've already completed the migration, and now I'm diagnosing some glitches that have appeared in the production environment.
Why am I experiencing connection issues with Blazor in production but not locally?
The connection issues seem to be related to the WebSocket connection being terminated, which I'm suspecting might be caused by the way Cloudflare is set up. It doesn't occur when I run the application locally, indicating that the production environment has some differences that need to be addressed.
How do I handle logging and diagnostics in Azure for my Blazor application?
I've enabled Application Insights in Azure to help with logging, but I initially faced issues with it not capturing any logs. I had to ensure that the connection string was set up correctly in the Azure portal, and now I'm working on verifying that it's capturing the necessary data.
These FAQs were generated by AI from the video transcript.