on this week's visual studio toolboxes
dd-do gar is going to finish our
two-part look at how you can
containerize your existing dotnet
applications hi welcome to visual studio
toolbox I'm your host Robert Greene and
joining me today is a dd-do guy hey
DeeDee hey this is part 2 of our chat
about containers in part 1 we looked at
adding container support by a docker to
an existing web forms up we used and the
whole idea is that we've talked quite a
bit about containers in the show lately
in the context of Micra services and the
smart hotel 360 app but this is our
opportunity to kind of step back and do
again two things one is kind of do a
more gentle introduction to containers
to the extent that's possible step back
and we talked quite a bit about what
they are and why and then focus on
existing apps you've got an existing web
forms app or MVC app you've got an
existing WCF service write all the code
that that we've that people built
earlier and are still maintaining and
how does containers fit into that story
exactly so that's what we're doing we in
episode 1 of this we created a container
we got it running locally which is great
but now the question is what do you do
with it right how do you get that
container out so that it can be used in
production one way of course is to run
it in Windows servers yes so you don't
need the cloud to run containers you can
run it on Windows server or of course
you can get these things up and running
in Azure and that's what we're gonna
talk about today right sounds great
excellent Ozzie um so I think the first
thing we're going to talk about is
orchestrators okay so the first thing
you want to think about when you're
deploying to the cloud is what
Orchestrator I'm going to choose and an
Orchestrator is basically a platform
that's going to help you manage all
aspects of deploying and setting up your
containerized application ok so there's
a lot of different orchestrators out
there there's
Nettie's there's service fabric there's
docker swarm there's all sorts of
options and all of them have their
different pros and cons but today I'm
gonna highlight a couple and those are
managed kubernetes and as your container
services and as your service fabric okay
and the main difference right now
between those that we're gonna highlight
is just that as your container services
it's a little bit more mature for Linux
containers versus service fabric as it's
part of the Microsoft ecosystem is a
little bit much R and Windows but really
it doesn't matter which one you choose
both of them will work just fine right
so I think we we talked about this last
time if you're kind of new to containers
if you're doing dotnet core so it's a
brand new app net cork and run a Windows
can run on Linux you might choose Linux
containers exactly if you're using
kubernetes they're smaller they're I
don't know performance wise if they're
faster but they're certainly smaller and
smaller to create so your dev work is a
little bit faster and then if your
dotnet core app is running on both then
you know that's then you've got the
flexibility there obviously if you get
an existing web forms app you don't want
to have to rewrite it as a core app yes
so that you can run it in a Linux
container so that you can use kubernetes
yeah exactly and we're building on the
scenarios that we talked about in the
last show which we're really your
existing write net applications so
windows containers so we do have windows
support for kubernetes which is there
and improving and will continue to
improve quickly exactly and so today for
the demo purposes I'm going to talk
about kubernetes and Roger container
services and focus on that in the demo
but we have both walkthroughs
highlighted online so you can follow
them step-by-step so on to kubernetes is
an Orchestrator and as your service
fabric is an Orchestrator what's as your
container services container services
outer container services is basically
the in Azure environment in which
kubernetes is going to work so you
basically will setup your resource group
and Azure and you'll set up your
kubernetes cluster and connect that into
as your container services but
kubernetes is the actual Orchestrator
that you
okay it's confusing I know so I want to
talk quickly about just the benefits of
orchestration and why you would want to
use it yes it's especially important
when you have things like microservices
in your application but even for smaller
applications it can be really convenient
you can have automated deployment and of
your end replication of your containers
you can easily scale in or scale out
just online which is makes things really
easy in terms of deployment load
balancing so you can load balance
between all of the containers and pods
that you have internet is pretty easily
you can have rolling upgrades it's a lot
more resilience because you can
automatically reschedule failed
containers so you don't have to worry
about all my container failed and
there's gonna be a break you can
automatically make sure that there's no
breaks in your service and then lastly
you can have controlled exposure of your
network ports so that people outside of
your cluster you can kind of control
that exposure so it really turns out
that containers is very much is really
DevOps yeah yeah everything you just
said I know like me is the developer I'm
like yeah it's great that's all
happening but I'm the dev right I write
the app right I hand it over to the Ops
guys to do that and I know DevOps whole
concept is to you know shrink that
barrier and merge those two were exactly
but in our you know demo we're doing
here and we did previously we didn't
touch the app nope we just got the app
up and running in a container added the
docker support which made the container
out of that app and then you go and
manage it mm-hmm exactly yeah that's a
great point I mean if you remember in
the first episode actually the first
picture that we showed was really
calling this sector cloud DevOps already
and it's really focused on highlighting
the fact that this is just really really
helpful
your DevOps you look at a lot of surveys
people why you know what they're
interested in containers and you find
that they're really interested in the
DevOps side exactly I want to use
containers for DevOps yes as a way of
more easily packaging up an application
yep exactly
cool um so we're gonna get into the demo
now but just a reminder of where we were
at when we ended last time so we had
a application with a WinForms front end
a WCF service in your middle tier and a
sequel server on the back end and we
went through and we containerize the WCF
service and the sequel server and got
those running locally on our machine
okay so let's go into basically if you
want to deploy the kubernetes there's
two really high-level steps the first is
setting up in Azure and making sure your
kubernetes cluster is set up and
deployed to Azure and then the second
part is deploying your application and
all of the resources needed into the
kubernetes cluster so today I'm gonna
focus on kind of that second half of
deploying your application actually into
kubernetes okay but that assumes that
you've gone through and in your Azure
portal you've created that kubernetes
cluster and you have that all set up
already so you can do in Azure now you
can also do that in kubernetes
kubernetes has a whole web-based UI for
setting up clusters and whatnot all of
this do a sure you can do all this
through a sure and set up the ACS that
you need as well and if you want
step-by-step instructions again we have
all of that yes lay it out on our shop
on containers repo so I'm not going to
go through it today cuz it would take
too much time but you can definitely
follow this through and be able to walk
through step-by-step okay cool and so
there's a few terms I want to bring up
in kubernetes before we dive deep into
it just so we're all on the same page so
the first is pods yes
so pods are kind of the basic unit in
kubernetes and that's really the pod
posterior container and so you could
have multiple containers in a pod or you
could have one container in a pod
but it's really the environment for your
container and then there is a service
and the service is really helping you
network between the different pods
mm-hmm and then what you have if you
have two services and two different
containers they need to be able to talk
to each other really just like we have
you know our sequel container and our
WCS retainer and we want to make sure
all of those services are set up
correctly and then lastly
there's a deployment so the deployment
is really going to help you automate
that setting up the replication the
deletion the creation of your pods okay
so those are the three key terms that
you kind of have to know going forward
so if we the first step in that second
part of the process would be to create
our kubernetes deployment files and this
is kind of similar to what we did with
our docker files so there's a couple of
files that we have to create again text
base so super easy to create but these
are really just describing the
step-by-step instructions for kubernetes
to make sure the deployment goes
smoothly so I've created this folder
here in the root of my project so this
is where my project is and I've created
this new folder and the folder hosts a
couple different files one for the
sequel container and one for the WCF
container on our yellow file there yet
another markup language that's literally
yes exactly
hilarious so let's go into both of these
and I can walk through what's going on
here so first here we're specifying that
its deployment we're giving it a name
and then everything under spec here is
just describing this deployment so we
have it labeled as a sequel data so
we're working on the sequel one first
and then here you're gonna see this
looks really similar to what we did in
our dr file
so you're just specifying what image you
want to use again so that same sequel
server windows image and then you're
defining some environmental variables
and then lastly this part is important
so this is saying that you want your pod
to be attached to a kubernetes node and
you want the kubernetes note to have
Windows running as the operating system
so that's where I'm specifying this is
kind of a one of the many tips and
tricks is that when you create
containers you need to be clear if it's
a Windows container you need to tell the
environment hosting it that it is right
exactly if you get this running up in
like an azure container instance it's
very easy to tell the ACI
that it's a Linux container when it's
really a Windows container hmm and then
Oh what do you know it doesn't work it
takes a long time to copy the file up so
you learn a long time after that it
didn't work because you told the thing
hosting the container that it was a
different OS right yes exactly so key to
put Windows I'll help you a lot but I've
heard of people who after they did that
a couple times learn to never to do it
again
yes exactly at all
and so then we've specified that this is
the end of the service here and we can
define another one right in the same
file and then the second service is
actually a load balancer and the load
balancer is going to do a couple of
things one it's allowing us to specify
this external IP here so that we can
understand where people need to go to
access this and then secondly it's
exposing this port here 1433 and this is
the default port that sequel listens on
so I'm just making sure that when
traffic goes there it's listening in on
that same port that your sequel
container is listening in on so
theoretically you could leave the sequel
server on Prem if you have the container
and Azure talked through it through the
hybrid connector right you could yes
theoretically if you wanted to do that
for sure so that's actually the extent
of this sequel file so not too much in
here I'm gonna take a brief look at the
WCF file and just highlight the one
difference in here so it's basically the
same as the sequel one but we've
specified a strategy here and this
strategy is a rolling update strategy
and all that's saying is really that we
want to make sure new pods are created
before the old ones go offline so
there's no break in your service so
that's that's really the main difference
here and you can go to the kubernetes
Docs and and find documentation on how
to build these files and what this all
means exactly yeah yeah we specified a
lot of that again in our wiki too as we
take you through that kubernetes has
more extensive
documentation sees some day and Visual
Studio right-click and publish using
kubernetes where these things are just
dialog maybe it's just like we have for
a docker how would be great okay cool um
so that's actually those are the only
two things we have the add docker
support that writes the docker file for
me and the docker compose file yep
so this could be this this would be nice
okay these are the only two files
actually that I need okay
now deploying into Azure so I'm gonna do
this through vs yes you can do this
through the command line if that's your
preferred method whichever way you want
to choose is fine but let's go into VST
yes so here in bsts I've created a new
release definition and this is really
first I'm adding an artifact which is
just specifying where I'm getting my
files and my code from so all of my code
is up in github so I'm just accessing
this repo where the code lies here okay
I'm specifying there and then here in
this environment I've added three
different tasks and that's to deploy the
sequel container deploy wucf container
and refresh the WCF pod
okay so here's actually where I'm
referencing those Hamel files that we
just created so that looks a lot easier
than having to learn the command line
prompts to do this yeah it depends if
you're familiar with Visual Studio teen
services I think it's easier in that
sense but there can be a learning curve
to just understand there's a lot of
different things in bsts so whatever is
easier for you it's not that many
commands as well in the command line so
I think a lot of people start with that
yeah that's easier so here in the
configuration file I've specified that
we're pointing at that sequel container
deployment file that we just created and
that was in the root directory that's
why I created it you know in that same
folder that we were working in for our
project and then down here you also have
to make sure that you had your images
pushed to a container registry so we had
them up in a docker registry
to use ACR yeah exactly so they have
options for container registry or
container registry whichever one you
want to choose WCF container same thing
except you're referring to this WCF yan
will file that we created and then
refreshing the WCF pod is pretty easy as
well
and what does that do that's really just
making sure that the pot is refreshed so
it's a step by step process right so
you're gonna deploy your sequel
container and then you're gonna deploy
or WCF container but things kind of
don't go in sync necessarily so you want
to make sure at the end that you refresh
because your WCF pod is really relying
on the data from your cereal container
you just want to refresh it at the end
make sure it's all kind of in sync
together so now I could go to the
releases and we will see that I was
looking at this one here
just now and I could create a new
release and this can obviously be part
of your usual flow you make changes you
build you release exactly or you could
just use the release here because it's
easier yep okay specifying that
environment that I just defined with
those three tasks mhm and then I can
choose if I want you know the latest
build from getting up or which kind of
version I wanted shoes here mm-hmm and
say create
so release 10 has been created so if I
go to release 10 it's not automatically
deployed so I'll just go here press
deploy and it's just telling me that
release 10 is the same as release 9
because that's what I created this
morning and if I go to the logs here's
where you can see the step by step
process so this will actually take you
through the entire process of those
running through all those tasks that I
just showed you but we're not going to
go through this right time place exactly
The Container which is we large yeah so
it'll take a little bit of time so I've
actually already done a deployment
earlier today and so we can go and take
a look at that in my career Nettie's
dashboard so - now you you're now over
in kubernetes you're you're into
kubernetes yeah and that's where I can
really discover all my pods and
deployments and services and to pull
that up all you do is type cube CTL
proxy into your command line and what do
you have to do to get cube Cuddalore
however you want to call it on your
computer in the first place you do have
to install it before that ok so if you
type cube CTL you can find instructions
on how to install that it's like any
other CLI that you have to install on
your computer yeah but that will allow
you to access this IP here so thank you
cuddle proxy and that connects mm-hmm
I give you the ability then to go into
the browser and see the dashboard right
so it's at some point you have to login
presumably I'd know so you've actually
when you set up that whole first step
when you actually set up a CS and
kubernetes you connect cube CTL there to
make sure that those two are connected
so you've already done the login there
all right and that connection so here
because I've already logged in it knows
what dashboard I want to access ok so if
I look here at my deployments you can
see that
had a sequel data for WCF I have a shot
modernize WCF and those are this WCF
service and the sequel server container
like we talked about and those are
containers those are deployments though
so that was in deployments so remember I
talked about pods which is the
containers so we have one pod for each
of them right now because we've only
just done one for each of them and then
we have services and so here's actually
where you can see the external endpoints
so this page is really useful so
actually for my WCF service I can go
visit this endpoint and I can say hey
this is that catalog service that I was
trying to reference before you can see
that is WCF service running in Azure
mm-hmm orchestrated by kubernetes
correct all right exactly so I can take
this IP just like we did before and head
back to visual studio yeah and remember
our app config file is where that
endpoint address was before specifying
where your the services you can plug in
this new service and restart this
WinForms application and when this
starts this is actually going to be the
WinForms application talking to the WCF
service and the sequel server that are
running in the cloud so we've gone from
making it from local containers on your
machine to actually running it in the
club cool now I think we might have
talked about this last time but it's
always worth revisiting I've done
similar demos of modernizing you know
take a wind former WPF app talking to
WCF talking to sequel server and I've
taken the sequel server database and
migrated it to sequel Azure yes that
sequel server running in Azure which is
yes and then I took the WCF service and
I plugged published it to a web app
mm-hmm or slash website running in Azure
and then the clients still sitting on
the desktop is talking to the server's
talking to this to the server to the
data up in the cloud
mm-hm
which is exactly the same thing we're
doing here although we've done it
through containers of orchestrators so
when how when do I do which because the
first yeah the easier route is easier
these are is easier I think I mean the
key is dependencies same so a lot of the
times you have dependencies that are you
need to kind of bake into running your
application and the container is gonna
host all of that for you which makes it
really easy so you don't have to think
about like oh is my like is it updated
do I have all the right things installed
here things worked in development but is
it gonna work in production all those
worries about whether it's gonna work or
not or whether you have all the right
things installed right it's taken care
of with containers because that's like a
full environment in itself
the other cool thing is scaling yeah
right so it's super easy to scale now
and I can scale out these containers
with just a couple clicks so if I
actually go back to the kubernetes
dashboard here and go back to my
deployments and say I want to scale out
this WCF service right now I only have
that one pod running what I have to do
is click say scale and say okay now I
want five pots and say okay and now you
can see one out of five pods have been
created so if I go to my pods here it's
working on creating those other four
pods okay that was super easy yeah all
right so all I had to do is go to my
kubernetes dashboard and say scale it
out right easy so I think that's a big
benefit of using an Orchestrator as well
right okay so I think that's kind of
kind of good answer to the question is
if you're just gonna stick it in a
container and just run it you know you
could do it either way but if it's gonna
stick in any container just run it
you're really not necessarily taking
advantage of all the stuff that
containers does right the when you get
the orchestrators and have the
flexibility to manage them and have
failover and you've got five pods
running if one goes down there's four
others run
yep not miss a beat or you could easily
increase so if you're doing like ticket
sales or something right tickets go on
sale at 10:00 a.m. so you know that
between 955 and 1030 there's a gigantic
spike I trap the house when you saw the
bulk of your tickets you don't want to
go down yeah that's a great situation
and there's 1030 when the concert sold
out right you can just scale it back to
you know maybe two three because they're
stragglers and by 11 o'clock scale it
back to long yeah really easily okay
yeah I mean it was just a couple clicks
and it does automatically for you um
which is really nice cool and then it's
also really important if you have my
courses like we were talking about
before and you have so many different
things to manage and you can load
balanced kubernetes will take care of
all the load balancing for you so that
you have to so it's running in as you're
so obviously we're charging for Azure
use kubernetes charging for any of this
no it's free open source kubernetes is
actually pretty awesome like that so
it's from Google okay I mean it's an
open source project okay yes cool all
right
so asher is the only thing that's
charging you here writing there
excellent and that's actually about it
all right
we've taken you from your existing dinah
application running on Prem locally to
adding containers running that locally
and now we actually have it running in
the cloud cool and then the repo you
showed that you shop contains yes
there's exactly khaliv walkthroughs on
how to do a lot of this stuff we will
write people to those please do yeah
exactly so the dotnet architecture repo
on github has this a shotgun containers
and this really has so many samples and
walkthroughs on how to do this step by
step and if you want more detailed if
you prefer ebooks you can actually visit
our architecture page on the dotnet site
and this will tell you give you books
that you can download it will refer you
to those same samples and you can
explore kind of micro services or
modernizing dotnet apps is really what
we talked about in this demo cool or
other things all right excellent
awesome
like I said early we've done a fair
amount of containers stuff on the show
we'll probably put it aside for a while
and go do some other stuff but I
hopefully these last couple episodes if
you weren't that familiar with it before
I've given you some good ideas on how to
get started doing this we've really
again focused on the existing
applications yeah they're the smart
hotel 360 is cool but it's kind of a the
new modern thing you've got dotnet core
services and Java services and again if
you've got existing web forms and wind
forms and WPF apps and WCF services
containers is also for you
exactly thanks so much thank you all
right we will see you next time on
visual studio toolbox
[Music]
you
Wednesday, February 4, 2026
Containers and Existing .NET Apps (Part 2)
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment