[Music]
hi welcome to visual studio tool box I'm
your host Robert Greene and today we're
gonna talk about containers and joining
me to do that is a dd-do guard hey
everyone how are you good thanks for
coming on thank you we've done
containers a few times in the show we've
had episodes on docker we just did as
part of the smart hotel 360 series dive
on the back-end services which are all
containerized micro services but what I
wanted to do is kind of start from
scratch right go back to the beginning
if you will and talk about what
containers are and what some of the
tooling is in visual studio to help
because there is quite a bit of tooling
that helps and then approach it from a
different angle not so much the fancy
modern micro services you know where
some are in.net core and others are in
Java and they're orchestrated in
kubernetes and all that which is you
know good stuff to know but what if I'm
just somebody who's building and
maintaining his built and is maintaining
all right classic dotnet applications
days is p.net web forms or MVC or a wind
forms or WPF app that talks to WCF to
talks to a sequel server right what a
containers have to do with me because it
turns out the answer is a lot yep for
sure um yeah that's a great point so
let's take a look here at what the term
modernization actually means and where
containers really fits into that so
really we're talking about here existing
absent services we're talking about so
applications built with net framework
usually on Prem and we want to make sure
that we can move those to the cloud
right without necessarily having to
rewrite it as a dotnet core app exactly
can do if you do decide a requirement no
and there's much easier ways to move it
to the cloud if you don't want to spend
the time rewriting it in dotnet core so
the first option you could do would be
to migrate it so this really means
making it cloud infrastructure ready
which is really just Rijo stting in VMs
so here you have don't code changes
really easy but you use VM
which is kind of the more traditional
route right when we're talking about
modernizing you can do this in a couple
different ways one is making a cloud
DevOps ready and this is where
containers come in so containers really
make it more portable lightweight easy
to deploy and more DevOps ready and here
again minimal very minimal code changes
so you don't really have to reaaargh
attacked your app at all it's really
just adding some extra few lines for
container support okay which is pretty
easy to do and I'll go through that in a
little bit and or you could cloud
optimize your app and that's kind of
what you were talking about before with
rewriting your app we are connecting
your app into dotnet core may be
utilizing micro services but obviously
that will require a lot more work so
containers can be more of an easy step
in between though it's a first step it
may be the only step you need to take
yeah exactly you don't have to go fully
to micro services if you don't want to
okay and let's take a second for and
talk a little bit about VMs versus
containers just so people can get a
sense of what the differences are
between the two so in a container what's
different is that you're sharing an
operating system kernel and you're
really deploying the containers with the
binaries libraries and the application
and that's what makes it so lightweight
and so portable versus a VM you actually
have the operating system that for each
one right it's called a virtual machine
for a reason an entire machine
virtualized so it's everything from the
base operating system on up so they're
huge they require huge amounts of disk
space
there's certainly scenarios where that's
good
they're not exactly portable not exactly
lightweight the container is you take
the application and all of its
dependencies and that's what's in the
container and then it runs on the
operating system which already exists
exactly Windows server or of course no
server in the cloud
yeah yes yes so you could have Linux and
Windows so today we're focusing on
Windows that's just because we're
talking about dotnet framework
locations so you'll have to use windows
containers but yeah you can also have
yet to use meniscus yes to use Windows
containers exactly but if you wrote a
dotnet core application and wanted to
containerize that you could pick if you
want to choose Windows containers Linux
containers whatever you actually want to
use yep Linux containers a little bit
more lightweight that can be faster at
the moment a little bit where they work
a little bit better with kubernetes
although great windows support is coming
on the other hand I don't know nothing
about Linux I know a lot about windows
so you know there's a benefit to
choosing the container that's the
operating system you know about very
true right so let's go into talking a
little bit about docker just too many
people are familiar with docker so
docker is basically a container platform
provider and it helps you automate your
containerization so you can easily
deploy your app season containers and so
Microsoft actually has a set of images
hosted on docker that makes this really
easy for you
so if you go to docker hub here you can
see that Microsoft has published all
sorts of images so you have your Windows
server core image your dotnet images you
have your asp.net images so here's where
you can find kind of all of the images
that these are starting points exactly
take that image and then you add things
to it like your application or
additional functionality that you want
to added you can start out with a
stripped-down container and then add
more things to it you could just choose
the the asp net or the ASP core image
which already has asp.net core running
and then you can just do nothing more
than put your app into it and then of
course you can make any other changes
you need to it to add functionality or
restrict functionality right you don't
have to start from scratch no you don't
have to start from scratch which is
great and all of these have
documentation associated with them which
is even better because it makes it even
easier to get up and running on a very
regular basis correct definitely um so
let's talk first before we go into the
demos about why you want to containerize
your app because it's the cool thing
doing it exactly that's the only reason
you should do it so modernization in
general can be useful for improving
agility growing your applications
lowering your IT costs say you have an
on-prem database that you want to move
to the cloud really modernization in
general is about lowering your total
cost of ownership containers in
particular are useful because as I
mentioned before you don't have to re
are katuk to your code so that makes
things a little bit easier for you
there's less of a learning curve
less code required lower deployment
costs improved productivity improved
DevOps ability and portability which is
what we talked about with containers
versus VMs I also give you some
act as kind of a I know it's rightward
almost l-like a firewall between you and
the rest of the machine right so you
could have a web app running on a
machine that you wrote on dotnet 3:5 and
you're leaving it there because it works
fine but then people keep making changes
to that machine and new versions come on
or new libraries come in and now your
app is subject to whatever's going on on
that machine so right you know how many
times is your app broken because
somebody fiddled with the server you
stick it in a container it's fixed that
container runs on that machine then
people can do whatever they want to that
machine as long as they don't you know
take away the ability to run a container
and your app will never be affected by
that and if you need to make changes to
your app in the container then you go
ahead and do that
whether it's update to new version of
the framework or apply different patches
or whatever but you get this isolation
that's the what I was looking for you
get an isolation and the ability to move
it around right oh this machine's going
down for three weeks we're gonna replace
it with a new machine can you get your
app up and running on this new machine
yeah right if you have to then go and
install on that machine you know that
can be a bit of a nightmare oh you say
yeah here's the container run it done
easy yeah yeah I mean another point
there is really dev test environments as
well so you hear a lot of people who are
like I worked in testing on my machine
weird on my machine but somehow this
just yeah doesn't work in production
right so that's also solved we use this
app twice a year right because we have
our annual poll or we have our annual
raffle twice a year so you just want to
you know necessarily want that up having
to run all year you spin it up when you
need it and you take it down containers
make it really easy to do that as well
so there's a lot of things agreed um so
let's get into some demos so I can
actually show how this works in visual
studio so let's take a look at this
first scenario here so a common scenario
might be to have a web application and
this could be an MVC F this could be a
web forms up and you could containerize
this you could have it talk to a
sequel server also in a container for
the purposes of the first demo we're
just going to stick with container izing
just the MVC portion of the app okay you
have to put in some additional
dependencies in to talk to the sequel
server which I'll show you in the second
demo which is a little bit more complex
but let's start with the basics alright
so if we go to our legacy MVC app and
move the word legacy legacy means
existing apps that are running the
business today
exactly existing business applications
yeah so I've started this up already and
this is basically an eShop which has a
bunch of different catalog items and you
can manage the catalog from this web app
here so you could create new items you
could edit delete do whatever you need
to see meta log framework three five
four four probably four something
probably four seven it's cooked how was
that recent okay yeah we just made these
recently I think oh yeah we update them
pretty regularly but it could be older
if it needed okay
doesn't matter what right what framework
version per se so as you can see this is
running locally just on my machine here
so if we go back to the application in
Visual Studio and I want to add docker
support all I need to do is right click
here and say add now before you click
that mm-hmm not that this is hasn't
happened to me like every day first of
all you need docker installed on your
local train yep and you need it running
yes that's a great point yeah
so I had a dollar for every time I
either built this project or tried to
add doctors support before I had
actually started docker yeah I could
retire yeah that's a really good point I
automatically have it up and running at
the time so I forget that that's a
critical step in the process you can see
by this little icon down here it's up
and running another point there is that
you see here it says switch to Linux
containers so right now I'm running
Windows containers and you have to make
sure you're running Windows or Linux
containers whichever one you want to
choose okay so if we go into here and
say add darker support it's going to
auto generate a few files for us and we
can walk through each of them talk a
little bit about what they're doing so
this first is the dockerfile and this is
basically describing the environment
that your app is running in so the
important point here is that it's using
this Microsoft asp net image yeah so
this is basically the recipe for how you
build this container it says if you
haven't already downloaded it to your
computer which can take a while go to
docker hub and get this particular image
window server core version 1709 with
asp.net 4.7 not one that's pretty new
right right so go get that file which is
large it is pretty large so the first
time you run this it actually takes a
little bit of time to download that
image and make sure it's on your machine
once it's already there and unless you
delete it and it's pretty quick to
startup right but yeah the first time
it'll be a little bit yep lengthy you
also have this docker compose node that
was created and this really has all of
the assets to build and configure your
containers when you actually run it okay
so you have this docker compose file
here and this is really just saying get
that image that eShop legacy embassy
image and it uses that docker file that
I just showed you for context ok and you
also have an override file and this is
just defining some additional
environmental variables to help it run
so it's for example exposing important
so the cool thing you know studio is it
wraps all the plumbing for me you can do
this from the command prompt many many
people do yeah or you can right-click
and have Visual Studio do it for you
yeah and the other cool thing is these
are all text files yeah so instead of
having to install a bunch of things on
your VM you can just go and make some
changes in these text files and it's
pretty easy to add dependencies add new
things or configure how you need to
which is very cool and you haven't
touched the app nope haven't touched the
apps app is exactly the same all I did
was add docker support mhm
so now if I start up with adding docker
oops I wanted to start without debugging
so you can debug into your container if
you need to but for a faster startup I
just started without debugging here and
you can see down here it's getting these
images it's making sure all the
containers are ready and it'll start up
the same web app now at an IP address
so this is the IP address of the
container itself and if that's something
that you want to find out later you can
even go to your command prompt say and
say first you'd have to find out what
the name of the container is right so
docker PS is a good way to do that so
that'll give you all the containers that
are currently running on your machine so
once you have that container ID you can
say docker inspect and this is going to
give you all that information about the
container including what that IP address
is if you now have this app running in a
docker container locally on your Windows
10 machine correct exactly cool and it's
running at this IP as you can see it's
the same exact catalog as I showed
before yep talking to sequel server not
yet not yet
for this one we didn't implement so if
you see the docker PS only brings up
your one container for this each shop
legacy MVC but if this app was talking
to a sequel server then the container
can talk to that machine - exactly it's
essentially when it's equivalent of a
Windows machine running on your network
yep right exactly and we'll show that in
the next examples you don't have to do
anything with the sequel server no no
it'll be in its own container
it'll just a Janee in a container though
you could contain it you can't leave it
where it is you could okay exactly it
could be either way right okay cool
easy yeah and then another thing you can
do is type docker images and this is
going to show you that you have that
image on your machine so we have that
asp.net core image right here mhm and we
also have that you shop like a CNBC ok
right which is so the the basic image is
peanut running on core seven and a half
gigs this asp net one is today they take
a bit of space they do take a windows
can
sandurz take a bit of space of you yeah
are sitting there with like 12 gig left
on your hard drive then you're gonna
have a hard time yeah running on that
machine if you wanted to delete these
images those you could also do that and
you wouldn't affect things on your
mission so there's also a way to there's
a dr. command to take the image and put
it in a tar file but you could then move
to a different computer wipe all the
images off if you needed the disk space
great we're just playing around with it
and then take the tar file and rehydrate
it as images I discovered that when a
while ago yeah pretty cool that's a good
one too huh yeah I have quite a few
images on here just because I play
around with this a lot but yeah I'll
probably have to clean them out at some
point cool so let's get into the second
scenario which is a little bit more
complex but pretty similar so in this
one so you have a three-tier scenario
and for for this you have a WinForms
front end you have a WCF middle tier and
a sequel server back-end okay so this
might be a little bit more traditional
three-tier and to your app that you
might have in your mind of business
application so this is based on the same
a shop example again we go back to
visual studio I have this up and running
just so we can show you and in four
seven one you at the high DPI support
isn't at all it doesn't get all crazy
yes so this isn't a high DPI monitor
itself okay which is why it looks a
little funky here but what if you had a
high if you had a hundred would
automatically adjust exactly so we can
do the same thing here and right click
on this WCF service and say add docker
support
and again it's going to auto-generate
some files here but we're gonna have to
make some modifications this time and
that's because this is only generating
files just for the WCF service since
that's what I right clicked on and not a
docker support for it so now I want to
put that sequel server in a container -
okay and say ok now we have two
containers and I want to make the
service actually talk to the e sequel
server ok so if you're gonna leave it
that the WCF service talks to the same
sequel server mm-hmm
sitting somewhere else then you wouldn't
need to yeah additional changes right
there's a few changes in this base file
that you need to make which is
documented on the site yeah what WCF
services does this have does it have all
of them right no WS transport WS this
that the other thing exactly you might
need to add some additional things yep
so first we're gonna add those
additional things just for the WCF
portion and
all we're doing here is adding some
additional things to make the
environment full and this is all
documented online and something you have
to do when you advertising port 83
that's what that is
and then if we go to the compose file
here's where we're going to add the
dependency on the sequel server so we
will take this
and this now depends on sequel data and
this year is referring to the sequel
server image so now it's gonna pull both
that WCF image and the sequel image onto
your machine so again the first time you
run this it's gonna take quite a bit of
time because you have to pull both of
these images and on that container
you've got sequel server but you'd have
to put your database on and then setup
your users and your security the same
way you do any sequel server because
again that's it is a sequel server
exactly yeah
the last step is to actually put that
connection string info and your override
files cool yes so I thought you know a
lot sequel management's do you know
actually I can just put in the text so I
have my connection string I have my
password here I have all the credentials
here and I'm talking to that port 83
that I exposed okay and that's really
just these in additional environmental
variables right here and that's actually
it so even to add support and dependency
for the sequel server container there
was a little bit of work but it wasn't
we architected my code didn't go into my
app and change it at all now it's
running and now it's all set up to run
in docker
okay so let's start
docker and this one will take a little
bit more time just based on the fact
that you have these two containers that
need to start up so you started without
the debugging which is faster but if you
start with the debugging then you
actually can set the breakpoints and
debug the app all that's running it yes
yeah you can do that as well if that's
something that you need to look into
right
I mean presumably the apps been tested
locally and works just fine but
hopefully you never know it's always
useful to have that option right exactly
and so you can see here we've created
it's creating this equal container now
and now it's moving on to the WCF
container you can see in the output here
so if I go back here and I type in
docker yes you'll see that I have I
still have that container from before
because I didn't do anything with it but
now I have this new sequel container and
when the WCF container is done that will
show up here as well now in the WinForms
app you need to point it to see to the
WCF service running somewhere else no so
that I didn't have to make any changes
to the one for his front end so the wind
farms was already talking to the WCF
service just locally and you just had to
containerize the WCF service and it can
still talk isn't it running on a
different yeah oh yes yes okay that's
what you're saying yeah yes exactly
point in the web not the app config
current is to a different server yes
exactly so again the I P address right
exactly so now we have this starting up
here and we have the service so this is
the service itself and exactly we're
going to take this IP address and we're
going to put this into the app config
file here
and so right now it had the endpoint as
localhost that's what we were talking to
you before so this is what you'll
replace with the IP address and do you
get to assign names or do you always
have to use IP address I have to use IP
address unfortunately I don't know if
there's a way to do it with the ID of
the container or not I haven't looked
into that at all but IP is definitely
the easiest way to go so now if we start
yep it's so sterile not impersonal it's
true you can't name your container
something something interesting so now
I've started up an instance of the
WinForms front-end again and that's
going to be talking to the IP address
I'll take a few seconds
you
this is so cool because you didn't have
to change any of the app you just had to
basically change the where the sir the
pointer to the sir exactly and you
Visual Studio menu obviously you need to
you need to learn more about docker
right but that's it's not that hard to
learn how to yeah yeah exactly
where the image is what does it mean how
do you start and stop a container you
this is really good documentation on the
docker site there's you know inexpensive
books you can get but you've taken this
application and containerized it in 20
well we talked to 16 minutes right yeah
not counting the time it takes to
download the images right yeah so that
would take a little bit more time sure
listen now so a question I have we
talked about some of the benefits of
containers there's to modernize to cloud
enable these things you could have taken
that NBC app and published it to an
azure web app you could take this WCF
service and publish it to an azure web
app so talk about when you might do one
versus the other yeah I think there's a
couple of key points so the first is
about deployment so as we were talking
about before you don't know what
framework version this is running in and
so you publish this to app service and
this is running in the latest framework
version but app service doesn't yet
support the latest done at framework
version so sometimes a gap there okay so
with containers that's not an issue
because your frameworks gonna come with
your container and all those
dependencies are kind of baked in in
addition to framework it could be
another third-party dependency so a lot
of existing line of business
applications have things like complex
components or other dependencies and so
all of those dependencies are really
packaged in for you and you don't have
to worry about installing them
separately or worrying about them the
second is really to improve DevOps and
improve dev test environments so you can
start up a test environment really
easily like
talked about before so you can set up
your dev test environment using the
container you don't in this case you
don't have to even install sequel server
on your right because you have it in the
container the containers gonna come down
to your machine and that's much easier
than say installing all of that from the
ground up yeah
so should really help if this app was
using sequel server 2010 for example and
we weren't going to touch it but I've
got 2017 on my machine exactly and in
addition you could test it into your dev
your test environment and you could be a
lot more certain that it's actually
gonna work in production so I think
those are kind of the key things I would
point out I guess also you can run
containers locally you don't need a
server just fine so yep you can run them
locally you can deploy them to the cloud
if you want to right we obviously when
we DS when we talk about containers were
typically you know deploying them into
Azure you know for a couple reasons one
because we also want to talk about Azure
none of us are lugging around Windows
Server machine so it's just a heck of a
lot easier to put it in a jar right
exactly yeah that's actually what we can
talk about the next time okay that we
chat so I think in the next session we
can talk a little bit more about okay
now we have them running in containers
locally but right how do we get this to
the cloud what are all the different
ways you can get there how do you scale
out your application we can talk about
orchestrators okay which you may have
talked about in your microservices
episode as well a little bit yeah yeah
so I think those are kind of the next
steps in this scenario yeah but this is
really the basics and the first part of
getting towards they're cool so this is
a good stopping point and we will pick
this up again and the next one see you
next time on visual studio toolbox bye
picture
[Music]
Wednesday, February 4, 2026
Containers for Existing .NET Apps Part 1
Containers and Existing .NET Apps (Part 2)
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
Create Objects and Bind to Your UI (12 of 18) Building Apps with XAML and .NET MAUI
[Music]
hi welcome to visual studio toolbox I'm
your host Robert Green and I'm your
presenter Paul sheriff and we are
continuing our miniseries on building
apps with zaml andet Maui and in the
previous episode we saw how to bind
controls to other controls today we're
going to go a little step further than
that right Paul what are we going to do
yeah we're going to take a look at now
creating things in C uh which is you
know what most have we have a bunch of
classes and stuff and we want to bind
those classes up because that's what's
going to fill in the data for our
screens right yeah all right before we
do that however I did want to kind of
because a lot of people ask they say you
know having this hardcoded down here if
I wanted to have that same picker and
use it on a few other screens I had to
copy all of that man that's not
something we generally want to do so
let's go ahead and cut it out of here
let's go over to our app doz example
right so if you remember this is where
we're able to put in things like in our
app Styles right we did all of that so
what I want to do is I going to add this
as a resource here now to be a good
resource we need to make sure it's has a
key to it I'm going to call it phone
types so this is just another resource
just like in that app Styles if you
remember the app styles that we
created app style sorry there we go we
created like a string resource and a
double resource all we're doing now is
creating an array that is now a resource
so that means down here what I can do is
I can eliminate the item Source part
here I can then set the item Source
property to that static resource called
phone types
nice so that you know does a couple of
things number one it kind of simplifies
the code here but it also makes it so
that's a reusable ible array of strings
that you could use on other places
throughout your application so if you're
just going to use it once in one place
you can just leave it in line but the
second you need to use it twice right
second you the second you copy and paste
it there you go tells you there's got to
be a better way absolutely absolutely
it's kind of just like in C right I mean
if you're refactoring code you know you
know you're GNA use something you want
to just make a little tweak to it then
you you basically cut it out and you put
it in a new class or something right
that's all we're doing cool all right so
now let's go ahead and start really
start building this up I'm going to add
a new project now into our solution this
will be a class
library and I'm going to call it
adventureworks do entity
layer and I'll make sure we're using Net
7 or if net 8 is out feel free to use
that none of this should be changing
okay I'm going to go ahead and delete
this class one
I'm going to add a new folder called
entity classes here and then into this
I'm going to add a
class so we're kind of classy people
over here so we like to use classes well
I am I don't know about
Robert J's been out on that for a
while all
right so I'm going to create this user
class here all right and it's just got a
simple little Constructor that just
initializes things and if we look at all
of these properties here what do those
look like those look like exactly what
we're seeing on that user details screen
that we've been creating right y okay
yep so now if we go over here and I've
got this in this entity classes over
here make sure it builds of course so
hopefully everything will build and once
it's built you can now come over here
and right Mouse click on the
dependencies and add a project reference
over to that entity layer so that we're
then able to use any of the classes
within that
project then we're going to go to our
user detail view now I want to do some
binding up so if I need to get over to
there what do I have to do you got to
add another Nam space that's right so
now I'm gonna just simply call this one
okay this one's actually going to be my
view model so even right click add
namespace here don't you think pardon
there should be a rightclick add name
space little dialogue that comes up yeah
yeah need put somebody needs to put that
in
uh in
um that's the word I'm looking for where
do you go to to make featur one of our
yeah put that in GitHub so they can add
that there as a little say hey here's a
new feature we'd like feature
request so all right so I've added this
XML namespace and I'm calling it View
model then here's what we're going to do
we're going to add an xon data type here
and I'm going to type in user and you'll
see user and then in parentheses it
tells me the name space that's that that
class is within so if I just hit tab
there it puts it into the right format
what this is doing is this is
identifying to this content page the
overall class that you're going to be
using to bind here and why we do that so
we can get intell sense within visual
studio all right now within this content
resources here's what I'm going to do
view model user and then I'm going to
give it a key name and I'm going to
Simply call it view model and then look
at
this all of our properties now show up
here isn't this cool M all right so all
we have to do is start filling in the
data and I've already got it here so we
don't want to have to watch me type all
of that so there we go I have now
created an instance of the user class
this right here when this runs it
creates an instance of the user class
and assigns the properties to these
values so if I have a real instance of
something I can now start binding these
properties to each of those entry
controls but here's the thing this
border is the kind of the parent now
right of all the other
controls so what I can do is I can set
the binding context one time
here right so I'll do the static
resource Q model OKAY by doing this it
means that I don't have to do The
Binding context on each individual entry
control all right so now what I can do
is for the text I can now do a binding
and look at that it gives me my list
here so this is the login ID okay if I
didn't do the binding context up here I
would actually have to put this on every
single entry control but Microsoft said
well you shouldn't have to do that that
would be just silly so they say if you
put it at the parent level so and all
these other children underneath it hey
we'll go ahead and assume that you're
you're good do you do it at the can you
do it at the content page level at the
highest highest level or does it have to
be at the first okay contain question is
can we put it up here right can you do
this binding context up here so again if
we come down here and we take a
look Okay cool so really it's fine even
though you know you kind of think that
well this is coming before where we're
actually defining it but it does seem to
actually because it all just getting
compiled down right right so yeah now
Community was the words that were
escaping me by the way ah yes
oh so you could make that feature
request there we go developer Community
all
right I digress now you digress so but
personally I do like putting it here at
my kind of my parent level because
that's the place that I'm looking most
often but that's that's just me I mean
you know again there's absolutely
nothing wrong with putting it up there
either so right so what we would do is
we would simply go through and we do the
bindings on each one of these like so
right I mean it's really simp simp
Le try to do these as quick as I can
here by finding
email right so then we get down here we
got the check boxes now the check boxes
obviously are not on a text property
they're on the is checked property okay
so this one is the is enrolled in
401k and then this next one is checked
would be a buy name to the is enrolled
in Flex time so we just keep doing this
little by little we just build this
up is enrolled in
healthcare and then our last one here on
the radio buttons is is enrolled in
HSA all right the switch right so we do
actually have you know switch control as
well this one is is toggled so it's not
a you know checked or anything it's
actually a toggled and I actually have
an isactive property in there that we
can use for that so that's at still
employed
okay now down here we start getting into
the radio buttons so again it's on the
is check isn't it so it's The Binding is
fulltime and then on the radio button
here this is checked okay let's set this
one here is
checked this one is a binding
on uh ouch sorry just hit my thing I'm
still going to bind on the is fulltime
because I don't have an is part-time
but what am I going to use my converter
yeah if you remember I had that nice
little inverted Boolean converter that
nice so beautiful that's a really good
example of using a converter like that
where you've got a single value but you
got two radio buttons that's where
you're probably going to use this most
often so on the date picker we're going
to bind to the date property there and
we're going to bind the birth date and
here in the time picker we're going to
bind up to the uh what is it the uh
start time yep remember what my names
are
there now okay on this one let's see so
is this
one right so this one we're not going to
do our binding context here anymore okay
uh because we want our binding context
actually go to The Binding context of
the parent so we're going to change this
to back to what it really should be
so instead of actually binding to the is
check we're going to actually still bind
it to the is full time right so if we're
not full time I'm converting it then
this will become enabled right and also
that start time will be set right so
I've got two different kind of bindings
there all right now the Picker so we're
down here on the Picker and we've got
the items Source but what about what
about the selected item okay well the
selected item would be a binding to oops
sorry Dean there it is to the phone type
so in that user class there is a phone
type and that's Home Mobile right or
other so does the entry need to be bound
to something the phone
number uh oh yes thank you forgot about
that one good eye so that would be a
text again right MH and then that would
just simply go to the phone okay thank
you I would have missed that all right
well so let's go ahead and run
this and let's make sure everything is
working as we'd expect so and then I
guess we'll talk about the address view
in a
bit um actually I'm not going to even
worry about the address at this point
that's a little bit more to add on so
okay really feel like doing that at this
point okay okay but there you go look at
that there's all our data now being
bound
from awesome this instance right here
so so if I start changing this you'll
notice that it's not changing over here
okay and you also notice right here that
this uh part-time and full time is not
toggling the is enabled on the start oh
yeah boy what's wrong with that
huh well actually I'm not going to talk
about that quite yet okay that'll be
actually be in the next section we're
going to talk about why these things are
not updating okay obviously if I make
the changes here uh maybe I change
another one here to false then we stop
and restart those values will now be
reflected but changing them on the fly
like this doesn't work because we're not
informing the UI through any mechanism
and that's what we're going to have to
do and that's what're okay okay but you
can see that things did change here you
see the values here did change okay so
we will talk about that in the next
section but one thing is I've created
this instance of this user class here
right is there any way that I can get at
it from the code behind right so if I
wanted to get access to that created
component can I do that yeah actually we
can I would need to do a using on the
adventure works and layer right that's
the first step then I can
create a property here that's of the
type user that's the one that we created
I'll call it user object here and then
here's how we can access it in the key
the Constructor here after you've done
the initialized component I can go after
the
resources right these are the resources
and I can look for the key called view
model and I can convert that to uh user
class and there we go it'll Now set that
okay so to prove that out what we can do
is we can come all the way back down
here and we can to add a clicked event
here I'll call it save
buttonclicked I'll hit F12 to have it
create this down here and I'll just
simply do this I'll do a
system. Diagnostics debugger. break like
so let's go ahead and run on this all
right so when this comes
up we'll come in here I'm going to
change a lot of this here let's call
Paul Sheriff 234 Paul
sheriff sheriff psa.com
all right I'm gonna go ahead and hit
save
now okay and if I look at this user
object and I hover over this okay sorry
hover over it there is look at that okay
so the values are going one way they're
going from the UI back to the object but
we saw earlier that when I made the
changes in the xamel to the object it
wasn't going back to the UI right so
obviously we need to do something to do
that and that's what we're going to
cover in the next section but there we
go we've got a little bit start of
binding up objects to our
zaml excellent okay so we're stopping
here with the application a little bit
broken y but we'll fix it in the next
episode so stick around and we will see
you next time on Visual Studio
[Music]
toolbox
Creating a Visual Studio Code Extension
[Music]
hi welcome to visual studio toolbox I'm
your host Robert Green and joining me
today is Hassan saan hello
Hassan
hi thank you in a previous episode we
looked at the cosmo DB SQL Studio
extension that Hassan wrote for visual
studio code which was awesome and if
you're working with Cosmo DB it's a
great extension to get makes it much
much easier to work with that back end
and we've done episodes before on
building extensions uh for visual studio
we did a multi-part series on the new
extension model and you can also
obviously build extensions for visual
studio code so Hassan I thought we'd
have you on the show and give us a quick
overview on how you do
that yeah thank you Robert thank you for
me again uh we are going to try to I
guess live coding today and I'm going to
show you how to create the there are
like two types you can create extension
in vs code one of them is with Native
apis and the other one is the web view
so we are going to focus on the web View
today and I'm going to try to show you
what you need to start with so we can
create new tabs in the vs code and if
you will have sometime maybe we can even
I can even show you how to publish them
to Marketplace today cool right now I
open the vs code here and we are
starting from the scratch and if you see
kind of like errors like that this is
usually like a warning error so you can
get rid of it uh for this uh session you
know I just use a set execution policy I
just don't want to see all that warning
messages so that's can actually take
care of it uh so as I said before you
know to I guess uh have a web view or
the native uh API view you're going to
need some kind of uh like references for
example you're going to need not Js it
needs to get installed uh if you need
any kind of source
control we use usually most of the git
in the vs code and rather than that we
are going to use Yen and the vs code
extension generator so those are the two
items you need to actually install
before you do anything so let's actually
start with that first so what I'm going
to do here is I am just going to write
uh npm
install G yo and the other one is the
generator hold which
is is so and what is again uh U is kind
of like a framework it just kind of you
know start from the scratch like uh for
example v c extension it just puts the
all the files together unit it's almost
like a framework puts everything
together like what vs code is actually
expecting okay so as you can see just
install it it shouldn't take that much
time I will say probably 30 to 45
seconds we should be good to go uh it
will be installed I already have them
I'm just doing this you know so you will
actually see so as you can see we are
good to go the first thing we are going
to do right now we need to create well
let's actually create a new folder here
for this let's call that
toolbox and let's go in toolbox now we
ready to run the Yen and the generator
so I'm going to Sayo code here which is
going to actually create that whatever
the vs code extension is going to need
so when you run that it's going to
actually give you some options here so
as you can see you can create all kind
of stuff here uh so I'm going to focus
on on the extension but as you can see
there are all kind of other stuff that
you can create for the vs code uh and
I'm going to go and pick the JavaScript
here I'm not really I guess that good
with the typ script so you can pick one
or the other so I'm going to go to types
JavaScript so it's going to ask you
questions so let's call this one
toolbox uh identifier let's keep it
toolbox you can have some kind of
description you can always change those
in the Json file it's going to create so
let's say this is an
aim
extension and do you want to keep the
type checking so I'm just going to keep
it nor for for now if you have you know
Source sa with the git uh the source
control you can do it from here since we
don't have that much time I'm just going
to keep this no here and I'm going to
use npm for any kind of references in
future if I want to add okay as you can
see it created all the
files and it's ready to go so I have all
the code I need to start with so I'm
going to start with open with code this
should open a whole new vs code with all
the files I need and I createit from the
yo and the vs code
generator so so far so what we are doing
good and let me see here find my cursor
and close all this stuff and let's look
at what we have so far so the I guess
the main file you want to uh look at is
the extension JS this is the area that
you know whenever you write the comment
on the vs code the activate is going to
get triggered and it's going to actually
do whatever it says so right now it says
it's going to give you know console or
congratulations and it's going to send
information to us h word from the
toolbox so it's not doing that much but
it's doing something so that's most of
your code is going to go here so we can
call that as a back end so for example
if you're WR an extension and you are
trying to create like a databases or
anything like that this is the code that
you need to add functions here and add
all the that code
into uh another one which is the packet
Json so as you can see you can overwrite
those those are items actually here
right uh version is pretty important
here and the vs code is pretty important
here especially if you want to debug so
sometimes the you know whenever you
create the framework uh the framework
might give you the wrong number here so
you want to be sure that you're going to
go in here help and check the about so
this number as you can see this is the
vscot engine should match to this number
if you want to debug locally
successfully if you don't if it doesn't
sometimes you know whenever you start
debugging uh it cannot find the comment
and it cannot even you know start the
new vs code so that's something I guess
that's the minimum version that this
extension will work in right so corre
there's no you don't have to change that
every time somebody updates their Visual
Studio code which happens about
monthly correct so you don't have to
change it but whenever initially it
should match to what you have so
whenever you debugging you know yeah it
it will work uh and rather than that
another important one here this is the
activation event so as you can see it
says title so whenever you uh press
control shift p when you start to type
this this function is going to get
trigger which I just show you on the
extension
JS so and also you know we had all the
dependencies and all kind of stuff we
will kind of look at them later but
that's really the main functionality
here we have so I'm not going to change
anything here all I'm going to do is
let's let's try this so you know it
should work so what I'm going to do here
is I'm going to go and start debugging
with F5 and I click on it it should open
a whole new vs code and as you can see
it says extension develop and host okay
so now all I'm going to do here is I am
just going to press contrl shift p and
as you can see Hello word is already
there okay so I'm going to select that
and as you can see I get a message it
doesn't that much but it's working so
yeah so far so good right promising yeah
so far so
very uh so let's close this one so
actually let's do something more uh I
guess useful so maybe try to create a
tab at least let's create a new tab when
we actually register this one now so
question is this now installed in code
forever so if you launch code is it in
separately is it installed no it's not
installed at all it's just whenever you
start debugging it just creates a new vs
code and it's available only there so
it's not install anyway yet
okay so next one uh I guess let's try to
create a new tab to create a new tab
what we have to do here is since this is
the register comment here I'm going to
create a panel so my
panel oh look co-pilot is front of me so
this is going to be nice uh so I'm going
to create a web view panel and as you
can see copile is already giving me all
kind of information so I'm just gonna
let's see I'm going to take it as it is
so let's explain first the first one is
going to be the ID so you can we can
just change that to toolbox
and this will be the title uh so let's
say uh visual
cudio toolbox
extension that will be on the Tad and
I'm just going to leave those alone
that's going to be it's going to open on
one column and well let's take this out
from here first so this is going to open
one panel empty panel so let's actually
run this one here quickly
so that's going to open a near Rees code
and I am going to go here hello word
again and Bam I have a tab okay you can
see empty there's nothing in it but it's
a good start so let's close this one and
try to put something here so as I said
before we are not doing the native API
we are doing the web view so web view is
almost like a if frame you can put all
kind of HTML uh stuff here I picked the
web view because you know my extension
is all kind of custom stuff like I have
map and all kind of stuff and those are
not really available in the native API
so that's why I put the web View and H
the web View kind of is easier
especially if you know how to write web
application HTML JavaScript you know you
can do all kind of stuff so what we need
right now is we need some
HTML so let's do that uh let's create a
function which actually returns some
HTML so let's see
if uh coil is going to do well there we
go co-pilot is good nice use co-pilot
anytime you like only time you won't
want to you know use the co-pilot when
you interview I have all kind of stories
with that so let's see uh let's see what
we have here so this is I don't really
need that much so what I'm going to do
here is I'm going to take this out from
here let's say H1 Visual Studio
code and let's do
p Visual
Studio toolbox
extension by how about that okay so
right now what we did is we just create
simple uh HTML I don't really need all
this stuff here so let's take this out
too and let's take title out so it's
pretty simple and this function returns
this HTML and it just puts on the panel
so let's run this
again and let's run our hello
word back so we have the HTML uh working
uh you know everything looks good so
what else we can do what we can do here
right now it's very simple there's
nothing going on here so probably next
what you want to do here is you want to
introduce some JavaScript here so you
can do some kind of you know uh features
so for that let's maybe try to
change uh the color of this how about
that so I'm going to go here put my
script right here I mean everything is
you know right now
hardcoded but you know you can make this
uh much better uh so as you can see here
uh the first thing you are going to need
is let me take this let me accept this
here I'm going to need the vs code acire
vs code API that is the like almost like
the native API of vs code so that by
that I can do all kind of stuff and I
can kind of send messages uh to the
extension JS extension JS can go back
and send messages back to HTML so we are
not there yet but uh that is the idea so
I just take that uh let's say rather
than doing that let's make this very
simple so what I'm doing here is I'm
getting the vs code then I have the P1
let's just change the p1's color style
color is yellow
so it's prettyy
simple uh let's see here as you can see
I can just click here this will just
refresh it and it will have the latest
one so let's PR sure everything is
working fine here let's click
refresh and well I guess this is easier
yeah so I'm going to go back here run my
hello
word and
well the color didn't change that is
interesting what might happen I have an
idea by default uh vscode will not let
you run any script so you have to Define
it in this function here as you can see
we are creating the panel here you are
going to tell you have to enable the
scripts without that it doesn't matter
how much JavaScript you have out there
it's not going to run it so let's do
this one here by you know enabling the
script here then the script should be uh
okay to go so let's run this
again and cross the fingers we are going
to actually have a yellow text this
time don't like it let's
see oh I kind of know right now so I
think what we need here is we need
the uh onload when the body is loaded I
think that is what we are going to need
here so let's
see right we are going to need document
at event listener and we are going to
look
at
D
content
loed
okay uh
from here we are going to have function
and this function should run this one
all right okay that looks better let's
try
again I'm optimistic now
make so let's run
this yay there we go all right so now we
have JavaScript maybe it's not doing Dam
much it's just changing color but at
least it's running so everything is
good uh the next thing I'm going to
actually show you here so this is might
not be that much useful because your
control is right now only in this HTML
page so what really we want is we want
to be able to send messages from here to
the our uh extension uh CS file so we
can actually do things like for example
if you say create a new database you
click a button you're going to send the
database name to extension JS and can
credit for you for example so to do that
actually vs code uses uh the web
messaging so to use that uh we are going
to actually add that in here so for that
I guess we need at least a one button so
let's put a simple button
here and let's
say all
extension Js
and
[Music]
uh actually this one has all the feature
all the stuff I need as you can see I am
using the vs code the post message is
the uh you know the web messaging post
messages comes with the HTML so I am
just sending the alert and I'm passing
this hell lab to you uh from my HTML
file so this should send a message now
we have to catch the message to catch
the message we are going to go back
here and we are going to
say as you can see my co-pilot is
working great so from here on it receive
the
message let see here they're going to
say
message uh let's
[Music]
see yep we are going to do that
and from here we can actually say show
the information text that is
great and that's it so as you can see
all we are doing here let's see what we
are missing
here
so there we go so whenever we receive
the message this is going to run look at
the C we have the alert for alert we are
going to take the same message coming
from HTML and we're going to return it
back to the HTML page page so it should
display it there so that is the idea and
let's run it and let's see how this is
going to
work
so here we go hello word we have our
button we going to click the button as
you can see this already came from the
beginning so I can just take this out
and uh
as you can see we got hello from the web
view so it looks like I did a mistake
here I make this text box this should be
I guess a button but hey it works so
every time I clean as you can see I get
the message so I'm going extension JS
and extension JS comes back to me and no
in this way you know it just gives me
the some text to display
cool
so really I think this is most the B
phics that I can that's a lot easier
than I expected it to be yeah I can
share you know I mean web view API is
pretty simple especially if you know
HTML JavaScript and you know some you
know web application kind of background
is pretty easy it's pretty easy okay so
now how do I install how do you install
this for
yourself and then you want to share it
with others what happens correct so the
next part when you are happy with what
you you want to publish this to
Marketplace so you can actually you know
share with others and people can you
just write it for yourself do you have
to publish it in the
marketplace uh you can just write it and
you can put it somewhere your vsix file
but it's much better in the kind of you
know it's central place Marketplace and
you can have all kind of information out
there you can see how many people comes
how many how many of them is downloading
it so it gives you all kind of
information you need and it's use a
devops believe it or not so and also Al
if you put the marketplace it will be
available here right so it will be much
easier for people to you know like find
your
extension so to be able to do that first
you need to actually go to the Azure
devops in here in dev. azure.com and you
have to create a new
organization uh so for example my
organization is s web and that is a my
extensions uh organization here mhm
after you create this one uh as you can
see when you click here it's going to
ask you I'm not going to go there but
it's just going to ask you Comm some
common questions about the names and you
know all kind of information so that
that part is not really tricky uh after
you create this one you are going to
actually need a personal
token uh so to create a personal token
you are going to go and click right here
user settings and as you can see you
have the personal access tokens here MH
so when you click on
it my token is here no worries the value
nobody can see even me I cannot see it
so it's here but you know uh you can
just right click here as a new token
you're going to give a name for your
token let's say new token this is my
organization the one that you know we
just this uh created in the devops you
can put an
experation uh usually I keep it 30 or 60
days and the tricky part here is you
have to actually go and click here to
show all Scopes here and find the
marketplace see right here and you have
to click the manage so this token is
going to you know manage the marketplace
uh for you so really devop is going to
be uh the I guess the pipeline out there
for
us so when you click the create here
which I'm not going to do it but it's
going to display a new token for you and
the value of the token you have to keep
it somewhere safe because you are not
going to be able to see that again in
here so wherever you feel safe I guess
you can keep it out there and if you
forget it you have to come back here and
create a new token uh for your the I
guess the area for you so that is the
first part uh you have to
accomplish the second one is after
creating the organiz a and the personal
access token you need to create a
publisher in
Marketplace so for that you go to Market
Place uh Visual Studio manage so let me
take this out from
here and when you come here this one
should be empty for me I already have
mine uh but all you have to do is you're
going to create a publisher here and
when you log in here you want to be sure
that you are picking the exactly the
same account how you create create this
organization so they can kind of match
and the token will work so it has to be
the same account so in here really there
are two uh values very important ID is
unique and this will be actually in your
url uh when you actually pass on the
marketplace and you cannot change that
so I guess pick it wisely that's uh the
ID of your extension okay and the name
uh is the you can makebe company name
brand name it will get this played it on
the marketplace page right under uh you
know the ID so those are the two
required fields that you have to do and
rather than that you can kind of add all
kind of information about you you can
put logos and other stuff and after you
know you click create here and you're
going to end up with a new you know
publisher so for example this is mine so
those are the two things you have to do
first before uh we go back to visual
studio now you have the token you have
the uh publisher now we are in here this
is our extension and I'm going to go
back to the terminal here let's
see and what I'm going to do right now
I'm going to need the visual studio code
extension and to install that you just
go npm
install Global and it's going to be vs
code VSC this is going to give me an
error because I already have that so
it's going to say that you already have
that I cannot install it but for you it
should install uh and work fine as you
can see it say it already there so the
first thing you going to do you want to
be sure that the token that you just
created works and to actually do that
you can easily write V see here
vce I believe it's login and you're
going to put your publisher name uh that
you created in the marketplace so mine
is s web and I credit it's going to say
oh I already know your token are you
sure you want to overwrite it I say no
I'm not going to do that but for you it
should ask the token and you actually
paste the token here then it's going to
remember your login for the other uh
comments that we are going to write so
I'm just going to say no here just to be
safe and this is going to work so the
next we want to publish it so put
publish it there are a couple of ways
you can publish and the most common is
really the b c
publish so when you actually enter
that which I don't want to do that
because it's going to you know the
publish in the wrong place but it's
going to ask you all kind of information
uh the biggest I guess the thing you
need to watch here is if you look at
your file so if you you can just publish
it just like that but that means that
it's going to use a package that Chason
and you want to be sure that the version
number is larger than what you have in
Marketplace if it's not larger it will
fail okay so or you can actually go here
in the publish you can actually you know
say that
1.1.1 that will take it as a version so
it will overwrite whatever you have in
the package Chase okay uh as soon
package.json it doesn't it doesn't okay
no it doesn't so from here uh when you
click the publish it's going to ask you
a couple of questions uh it's going to
check for example it's not going to find
a source control it's going to ask you
are you sure it's not going to find
license it's going to say are you sure
you want to still publish this you know
you don't have a license so it's going
to ask you some kind of you know couple
of questions you can say yes or no and
after that it's going to publish it uh
to Marketplace now a big I
guess a tip for from me because I've
been doing that for a couple of times
and sometimes you know you run it
locally you know many times it happens
every day it works for me but it doesn't
work for others right so and the main
reason for that is usually when you go
and look at the packet Chason you have
this Dev dependencies so you want to be
sure that those dependen is in you know
production too and usually that is the
problem you know maybe you just add this
typescript for example and it's
available only in death I in prod so you
might be you know missing
uh references and it might work locally
you might say that oh you know this is
great it's working you publish it it
will publish the market place but if
another user kind of downloads it and if
they don't have that reference then that
means it's gonna fail and your uh thing
is not going to work so the best I guess
the uh what I how I handle that is
usually even I know that reference is
there what you can do here is you can go
and
say here you can say V uh
scce
package so this will package it locally
and it will create uh the okay see says
the read me so you have to kind of
change something here so this is your
read me this going to be available for
everyone so I'm just going to just
change it right now say this extension
right
for visual studio toolbox so let's save
this one let's try
again so now it's going to create that
vsix file which means that you can take
that file and install it locally to your
machine there we go and after that be
sure that it's running you know in
production in your machine then try to
uh I guess publish it all perhaps you're
just writing the extension for
yourself and that's how you can get it
running always in Visual Studio code and
install it without putting it in the
marketplace and then eventually you may
or may not put it in the marketplace for
others to use correct I'm the biggest
problem is if there is something wrong
with it and you don't catch it and after
you put the marketplace you cannot roll
it back right so that is the biggest
problem that's why I kind of create that
you know I use a package and run it
locally be sure is working in my machine
uh as a you know production then I try
to publish it because if you are going
to publish something broken then you're
gonna try to fix it as soon as possible
yeah that might get ugly okay
cool
awesome yeah so I think yeah I think we
cover most of the stuff really uh
there's good documentation on the
extents on what you can do with this yes
uh if you actually look at the we cot's
uh web weite it's kind of displays it
has all the native API web view how to
do it there are some videos out there
you can watch so there's a great uh
documentation and other thing actually
maybe I can show you so this was a you
know uh just a simple one if you want to
actually
see the real one that I have and how
complex that can get I can show you
right here so as you can see my
extension JS here I have all those
functions you know this one executes the
query for example takes all of these
options here and if I want to for
example maybe show you this is the
activate so you know as I said before
when we create HTML it was pretty
hardcoded so you might have CSS files JS
files you can use this uh to actually
get the local file and I pass those to
the HTML I create uh so as you can see I
all kind of messages
here and this is the one see I pass my
JavaScript CSS and all kind of stuff
here nice dynamically and you know I
have my CSS file JS file so you can I
mean you can do all kind of stuff here
since it's you are really creating a web
application here which is going to get
display on one t or
VC awesome that is cool that is cool all
right so thanks thanks for showing us
that it's uh definitely definitely not
as complicated as I was expecting it to
be yeah I tried to make it simple I
guess good job all right thanks again
yeah hope you guys enjoyed that and we
will see you next time on Visual Studio
toolbox
[Music]
Debugging GUI Applications in a GitHub Codespace
hi I'm Michael price I'm a product
manager on the visual C++ team you may
know that you can debug uh an
application in a codespace from from vs
code uh just fine but uh guey
applications on Linux which all codes SP
all GitHub codes spaces are Linux based
uh if you have a guey application there
it's usually written in um a framework
called X or X11 and in order for those
things to show up on a Linux desktop uh
you have to have what's called an X
server and it has to be connected to
some display that is a video device but
in a GitHub codes space um those are
headless VMS running out in the cloud
and so there is no video device or
display for uh X applications to to
connect to to display all of their guey
so this talk is going to show you how
you can make that work uh on your
Windows system
so this is a very simple diagram that
sort of explains the components and
parts uh that will make this work so you
you can see in this diagram that we have
a Windows system and we have a GitHub
code space and that we have an instance
of vs code either running in a web
browser or on the desktop uh that will
connect to the VSS code uh that is
running inside the code
space um and so whenever you run the
application you want to debug in vs code
um it doesn't know where to send that
that uh gooey information to so the
other pieces that you need to be running
here um is you need to actually set up
an X foring SSH connection between the
windows subsystem for Linux that's
running on your Windows system and the
uh the the SSH Damon that's in the code
space um the other little piece of magic
that just automatically happens here is
that um WSL has a feature called WSL G
and that just uh forwards any of the
gooey elements that show up in your
local WSL instance to your Windows
desktop so whenever you have those
pieces in place uh and you launch your
application to debug it um all of the
X11 commands all the things that do the
rendering on the screen will get
forwarded through the SSH connection and
then through WSL um back to your Windows
desktop uh where you can actually drive
your guy application uh for your
debuging
purposes you can roughly break down the
steps that you're going to need to do
into you know four four parts so first
you're going to create a code space I'll
show you how to do that um then you're
going to need to set up local SSH ke key
authentication uh that you would set up
and it'll work through the GitHub CLI
the GH uh
application um and then you need to
actually adjust your codespace some so
that the X1 forwarding works and then uh
you can uh go off and do your debugging
work and I'll demonstrate that as
well so to show an example of what uh
what we need to do here I'm going to use
this repository go- CPP this is is an
implementation of the go board game that
I use often and I have only ever had a
console UI for this but I'm in the
process of adding a a guey front end for
this thing so I have this Branch
multiple front ends that's already got
some basic code there I'm going to make
a codespace by going to the code
dropdown and select create codes space
on multiple front
ends this is going to create a code
space in the background uh as you can
see here I've have bed this up so we
don't have to wait a long time uh this
is going to make a code space on the
back end and then get a vs code instance
in my browser that is connected to it
and there it goes it's uh it's connected
up uh you know I like to pick a color
theme for each project that I'm working
on uh way I can distinguish between them
and I prefer darker colors so let's pick
uh let's pick this one here excellent
it'll install that extension and I have
my dark color theme uh I'm going to do
some cleanup of some of the windows are
going to pop up and configuration is
going to happen I'm going to speed up
through
that and all right configuration is done
I've closed all the windows that came up
uh needed to make it a little bit bigger
it was a little hard to see so it's
bigger now we can we can uh read it a
little bit more easily I'm going to do a
build now this is going to go and do the
build just like it normally
would it's not a very big project so it
doesn't take very
long okay build's done uh I'm going to
go set some break points uh let's set a
break point in one of the error
conditions and we'll set a break point
uh on the quit the Clos window event uh
the quit event as well let's click debug
uh we'll select the guey and off and the
debugger is
running so we see that the debugger
stopped in our air condition so let's
just go ahead and step through this and
uh figure out what it is that the error
what what error it's telling us so it's
saying no available video device this is
what we expected right like this is a
headless machine it doesn't have a video
device connected to it uh so I did not
expect this to work and that's the error
that I was
expecting so what we need to do first um
in the Second Step uh in the list that I
laid out is set up S SSH uh key
authentication so we're going to run SSH
keyin inside our WSL uh shell now an
important part here is you want to give
this a very this key pair a very
particular name of codes spaces. Auto
there's a reason why that you'll see
later so I'm going to copy the contents
of the public key that was generated um
you can see it generated both the public
and the private key we're going to
select the cont ents of the public keyy
I'm going to have it blured out here uh
and I'm going to I'm going to copy that
and we're going to then use that in the
next part of this
step okay so what we need to do is you
need to go to your github.com uh profile
should just be github.com and then your
username you'll click on the little icon
in the upper right uh it's going to pull
down a drop down list and you're going
to find settings and click settings
okay go to SSH Keys SSH and gpg keys and
add a new SSH key give it a title
whatever you want to name it and then
you'll paste the key that you copied
that public key into that key
field there we go and then click add SSH
key your SSH key is now added so let's
go back to the
console uh and make sure that that
actually
worked okay back in the console uh we're
going to use the GH uh application this
is a command line utility you can use to
interact with GitHub uh there's this
codespace command you can see all the
interesting stuff you can do with code
spaces we're just going to list the code
spaces that are in my account uh you can
see my code space that I made is there
uh you can view more details about a
code space um if you have multiple will
give you an option to choose but for now
what we're going to do is we're going to
use the GH codespace SSH command to
actually establish an SSH connection to
that code
space okay it looks like it connected so
just you know as an attempt to see we're
going to try to run the the the guey
here and see what it tells us okay it
tells us the same thing that was also
expected now we're going to f fix that
in a minute uh but first I wanted to
show you an additional little um uh tip
on how you can make sshing into your
codes spaces a little easier there's a--
config option to SSH that will actually
print out to standard out the stuff that
you would put in your SSH config file uh
so that you can more easily connect to
it when you do this if you if you
redirect it and append it to your SSH
config file this lets you then um use
tab completion and such uh for your code
spaces you don't have to go through the
GitHub uh user interface you can just do
it directly from your standard SSH
client okay now that we've got that set
let's go back to the codes
space so what we need to do now is we
need to actually go set up the X11
forwarding in your code space so in
order to do that uh you're going to want
to make sure that your codespace has the
X off package installed so I'm going to
let co-pilot kind of give me some hints
it did kind of the same thing it was
supposed to did above but that's okay it
got me most of the way and I'm going to
replace that with xof I'm not going to
accept its suggestion for X11 apps uh
cuz I don't need them for this uh but
those are some pretty cool apps if you
just want to test out X forting on your
own you can use those when you do this
uh you now need to rebuild your
container um so if you go up and um find
the re uh code spaces rebuild container
setting uh our option you can rebuild
this container we'll fast forward
through this because it takes a couple
of
minutes okay the container has been
rebuilt excellent
but there's still a few more things we
need to do let's go back to our console
uh our WSL console this time we're going
to pass the -
XY uh switch to SSH this is the thing
that actually establishes the X11 ter uh
forwarding so now we're going to run our
guy and now when we run the GUI on our
local Windows system we're going to see
the GUI app that we tried to run there
the the forwarding is now working
correctly from this uh session that I
established over
SSH but that doesn't quite get us what
we want because it works inside this
session and it works because of the um
display environment variable is set to
that so we'll need to know that piece of
information to make this also work in vs
code so if we try the same thing in vs
code you can see that the display
environment variable is not set we need
to have it set to the same thing that
our forwarding session has it set to so
if you go into your Dev container Json
you can add a remote M field with
display and you set it to the same value
that was in your SSH forwarding session
now when you rebuild the container this
time it will cancel or it will close out
your SSH forwarding connection because
the machine goes away so you will have
to reestablish that connection after you
do this reset and the display shouldn't
be changing between different sessions
um but just to make sure we're going to
go back and establish that forwarding
connection again in our SSH
client and we're just going to double
check and make sure that the value of
the display environment variable didn't
change between these
sessions okay it's the the same in both
places so now we're going to go over to
the vs code instance and we're going to
click
debug and you can see this time the
application came up and it's running I
can see the guey in my windows client
but the application is running on the
codespace and I'm debugging it through
my browser vs code
instance so you can see um we'll to the
terminal you can see as I move my mouse
around and press keystrokes different
events are getting sent to
it and then when I go over and I hit the
close window button I should get that
break point over in vs
code aha it's been told to quit so the
breakpoint fired and now I can just
continue through that and the app should
close and we successfully debugged our
guy application running inside a GitHub
code space while we're on our Windows
system so just to recap you know I
showed you how to create a code space
it's pretty easy um setting up SSH key
authentication is a little bit more
complicated but not too much there were
a couple of tricks with the GH tool that
lets you SSH into your GitHub code
space um then we set up the code space
to do X11 forwarding the the two parts
of that were making sure that the X off
package is installed and also making
sure that you set the display
environment variable
correctly um and then once you have
those things done uh and you've
established at SSH forwarding connection
from your local machine to the GitHub
Cod space uh then you're off to the
races and you can debug all your guey
apps and make the most beautiful
applications uh that run in the Linux
desktop uh that anyone would ever
want uh thanks for watching the talk and
I hope you enjoy the rest of pure
virtual C++ this year and if you want to
get in touch with the Microsoft C++ team
you can reach us at visual CPP
microsoft.com
