[Music]
Fox Sports is passionate about covering
the sports that our fans care about in
developing the Fox Sports app we chose
zamer in for visual studio to develop a
crossplatform solution that allowed us
to build everything in C much quicker
than using one of the Native languages
without sacrificing any quality we're
able to use hockey app to locate crashes
fix it and get an update out we couldn't
be happier with the feedback from the
users we've seen thousands of five-star
reviews Pinter is a very visual tool to
be testing zamon makes sense in terms of
its live devices testing the physical
app just like a user would use it Zam
test Cloud allows us to push our app to
over 2,000 real devices both mobile
phones and tablets across a matrix of
operating systems and device types so
that we can get the kind of coverage we
would never be able to support in-house
working with Zam and test cloud is
giving us the confidence to get to our
next 100 million
users the fresh track is an online
grocery business the mobile applications
and the website are the only way that
our users have to place an order we use
zon test Cloud to ensure the quality of
all of our applications we have hundred
of test cases that are run on a daily
basis it really helps us identify issues
um before they go live automated testing
has allowed us to scale it's allowed us
to release features on a much quicker
cycle and empowers a high quality
seamless experience to our
users Koke is a company that is all
about their brand and Z is allow us to
present it in the best way possible
using Zaman Visual Studio allowed us to
have all of our code in one place Cloud
integration with Azure and debugging and
load testing and insights all just make
it something that it's easy to use I
would tell any developers who are asking
about how good zamaron is if it's good
enough for Coke it's probably good
enough for whatever project they're
working on
Wednesday, February 4, 2026
Connect(); 2016 - Stories Xamarin
Connect(); 2016 - Stories Stack Overflow
[Music]
stack Overflow is the world community of
software developers it's used by over 40
million people every month looking for
answers to their questions uh looking up
documentation and finding new jobs
developers love stack Overflow to the
tune of about 6 billion hits a month
stack Overflow itself only runs on two
SQL servers one for the read write
workload and one for the read workload
but we're talking about 10 and 5% CPU
one can more than easily handle the load
we're just preemptively scaling out so
we have a ton of Headroom people are
surprised when they hear that stack
Overflow can run on a single SQL Server
instance because they just don't realize
how much scaling you can get out of SQL
we trust it because it's highly
available it's highly reliable it's one
of the most Rock Solid pieces of
infrastructure we
have we always say we want to use the
best tool for the job and we'll always
choose the best tool whatever it is at
any time what amazes me is just how
Little Hardware that we need and and we
have literally saved millions and
millions of
dollars stack Overflow Enterprise is a
version of stack Overflow for large
corporations that want to allow their
own internal developers to ask questions
about their internal code privately
within the firewall rather than asking
those questions on the public internet
with SQL Server sp1 we can run the same
code entirely on both platforms and
customers that need Enterprise scale by
Enterprise and customers that don't need
that can buy standard and run just fine
from a programming point of view it's
easier for us and easier for them one of
the greatest things about the
transformation that Microsoft has
undergone is the willingness to work on
every possible platform that really
makes their offerings including SQL for
Linux including Vol offerings from the
consumer all the way up to the
professional developer and the data
center much much more compelling my
favorite thing is when a developer comes
up to me and tells me how much stack
Overflow help them that's really awesome
they usually thanking me as if I had
answered their questions but it's really
the the population of stack overflow
Containers for Existing .NET Apps Part 1
[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]
CosmosDB Serverless NoSQL for the .NET Developer
[Music]
hi and welcome back to another episode
of visuals to your toolbox I'm back
again with my guest Jeremy hey Jeremy
welcome back to toolbox thanks glad to
be here
it's awesome to have you and it's almost
like we never left the studio or we
weird the same thing all the time that's
right this is the only actually have a
closet full of hangers that have nothing
but there's your logo shirts on them
that is amazing the cats out of the bag
there you go so we were doing two
episodes today but they'll be published
separately so folks might have not even
seen the previous episode that's totally
fine so today we're gonna really focus
down on cosmos DB right absolutely
cool so what are we gonna talk about
give us give us a summary so I want to
just drill into a lot of the aspects of
cosmos TV I've gotten pretty excited
about it in the other episode we talked
about a link shortening tool that I used
yeah and I enhanced that tool to store
data into cosmos TV so I could find
insights from my application what I
found is just you know it works
incredibly it works really well as a.net
developer there are a lot of ways to
interface with it so I want to talk
about you know what cosmos TV is why
it's important to dotnet developers and
show a little bit about how to get
plugged into cosmos TV and start using
it as a service right and you know folks
didn't see a previous episode that's
fine we'll link it it's not a grindin C
or anything you know the core function
thing and that was a really good thing
to watch your folks are interested but
let's start with what cosmos DB is again
I want to make sure folks coming in may
be really not knowing what does database
technology is all about if you can give
us a quick summary that'd be great sure
so you know when we talk about functions
we talk about serverless which I talked
about flipping that last server cosmos
DB is what functions are to compute
cosmos DB is to storage right it's the
idea of sort of a hands-free ability to
host an enterprise-grade database it's a
sequel right I mean is kind of the
defining way to describe right at a
baseline and then it has a lot more
because of what's being built into it
right so it's no sequel it's it's
document based but what's neat about it
is it supports a bunch of different
interfaces to connect to it
one of those interfaces is what everyone
who has followed the history as familiar
with document DB right so that was the
previous incarnation and what's
interesting about document DB is that
supports sequel syntax so even though in
the database we're storing documents
that can have different schemas and
properties I can still go to my
comfortable select star from group by
order by and use that familiar syntax to
quarry the database if however I'm a
traditional no sequel developer and I'm
used to something like MongoDB we have a
MongoDB driver that works out of the box
in fact I can take an existing MongoDB
application update the connection string
and connect to cosmos DB and use that
yeah that's very cool and then there's
two other api's there's a table storage
API which again you update the
connection string your app that uses
table storage is completely transparent
and then there's one that I always love
to bring up this interface name because
it's called gremlin right so gremlin is
what we call a graph interface and the
idea is that you're storing nodes and
vertices that connect the nodes and the
canonical example is airports so you
have airports as nodes and then there's
flight paths that connect them and
gremlin is a a language that can
describe how to traverse those paths and
then find information things like what's
the shortest path what is aggregate
information along the path etc that's
really cool in folks that you know might
may be googling later on trying to find
some information about about this
product the rename is always like a
moment in time with Microsoft and it
changes after like that so to be clear
like that community B was what this
product was called right it's now called
cosmos DB but we still refer to document
DB interface right over the way the way
we you can interact with it
right but that that does just a historic
factor right of what it was called so
the name might be dead from the product
name perspective but it's still alive
from a interface perspective it is so
alive in fact I did a workshop that was
a node workshop based on or based
on document DB and of course it's
iterated now to cosmos TV so I created
cosmos DB and was able to migrate that
existing application without changing
code I just
they did the connection string and that
existing document DB driver worked yo
asses out of the box yeah we changed the
name because it was honestly just
causing confusion and remember the
conversation for students realize the
power of this technology and hopefully
the new name gives us a new new life and
it's a lot more fun that's yeah sure
yeah yeah I was impressed that you know
sometimes we don't pick the best names
I'm I'm in marketing so I've spent time
naming stuff you you can blame me for
code lines for example oh praise me or
blame me I was on that project but yeah
this this was a good one I I like cosmos
DB and let's jump in to see what it's
all about
sure so the first thing I'm going to
show you just from the portal is the
experience of creating a new cosmos DB
I'm not going to go all the way through
it because I have an existing one but if
you click in to add a new resource and
just pick cosmos DB it's going to ask me
for an account ID so this is just a
unique identifier to access the most as
your resources there's some URL and that
URL needs that and you can then find a
beginning you can always change it kill
it later but right so we'll do my vs
toebox DB and then you pick your API
this is what we're talking about it
supports different ways to interface the
traditional document DB the MongoDB
interface the gremlin or graph interface
and then key value storage table simple
storage so we can pick any one of these
let's just do table storage I picked my
subscription that's my billing I can
create a new resource group I pick my
location and then I can enable geo
redundancy what this is key because this
is going to give me the ability off a
map to basically click different regions
and have it automatically span those
regions for me which is a pretty cool
feature yep what what I often hear
people describe this technology of ours
as a globally distributed database you
know something they can live in lots of
data centers and I believe you mentioned
there's different kind of retention
policies right of how how many
triplication you need we kind of
concurrency you need oh that's right
exactly in fact this is one that I've
created and this is a live one that I'm
using for my link shortening tool and it
stores metadata and you can see that for
my purposes because I'm the only one
he's actually exploring the day
yeah I just have this in the Atlanta
region which is close to me the eastern
US I've got an activity log that'll show
me how it's been accessed so I can
quickly look at you know basically have
there been any errors or issues or
anything along those lines and this is
just basic you know what's available in
Azure by default you didn't configure
any of this till incorrect this is
completely out of the box what's really
nice with this is the the data Explorer
and this allows me to look at my
collections which are containers of
documents they're kind of the corollary
of tables if someone's used to
relational databases you can see I have
these URL stats and this is using a
sequel like syntax like star from from C
and it's giving me IDs so that I can
expand these on demand so if I click on
one of these you can see the actual
document that's stored in this case
there's a unique identifier it
redirected to a page has a timestamp and
this particular document was a facebook
redirect I click on another one though
this is the the power of Cosmos DB and
document databases is this one as a
property called Twitter yeah so I'm not
locked into a specific schema I'm
counting different types of items for
that yeah this is a great power I mean
as a person that's used to creating a
table you know back in the sequel world
and having that table be sort of the
definition of what you look kind of data
you can store that this is a different
way of thinking about it right right no
sequel well and here's what's really
nice I want to jump into some code and
show an example project that I created
but what I love about the way that both
the document DB and the DB
interfaces are written is developers
used to sequel are also pretty used to
object relational mapper z-- yeah so you
know entity framework is a very popular
one and the whole idea is I deal with my
code and classes the database stores
them as relational tables so I need
something to map between the two of
those
what's nice when you take a document
approach is even though the document is
schema lists and you can have open data
and you could do you know a dictionary
key value pair to set the document yeah
you can also create strongly type
classes and you don't need to go through
any intermediary to store them the
driver just accepts that classes and
stores it right into the database cool
let's see so if we we take a look and
I'm going to come back to the the link
shortener in a second but I've got a a
Visual Studio code window opened here
and in this project what I did was took
the USDA food database and imported into
cosmos TV and then stood up an
application so you can search food items
cool and if we look at these links in
the configuration I'm going to just
click on this food group link you can
see the way it's stored actually on the
website is this format of these weird
squiggly lines and arrows and whatnot so
part of what this application does that
won't spend too much time on it says a
parser and that parser is going to read
the lines in and split them up cool and
then it has an importer that actually
imports the collection the transformer
is how it maps them to this is a food
group item or something different but
the importer this this is the actual
code that I'm using to populate the
database and you can see that we have a
helper method that gets our database
connection so we're pulling in our
secrets making a connection then what I
love about this is I have git collection
so I'm getting a collection of a
particular type it might be food group
food item something like that if that
collection exists because this is the
import utility I'm going to drop it and
recreate it so I can just import fresh
this is the code that inserts an item
and that's all there is to it this item
is passed then you can see this is a
generic type of tea so the item might be
a food group class and I'm gonna show
those in a second but literally
collection insert one a sink and that
loads it into the the database for me
I've got a completely separate project
that has my models my classes so here's
food group for instance this could be a
completely poco right plain old yeah see
sharp objects ELR object if you will but
I've chosen to go ahead and add some
metadata that says okay this is a unique
identifier right so using that attribute
to to make code the
Rayo so nae and you know some people
might want to do this fluently so keep
it out of the class completely and you
can do that yeah but for the purpose of
this demo we did metadata the other
brain power and flexibility a great
responsibility exactly with great powers
great responsibility the other thing I
wanted to show and this is a nuance I
think it's important to call out because
this is what people run into when they
move from that relational model to the
document model the first time I decided
to create a food item what happens is
every food item in the database has a
set of nutrients and it can be protein
fat carbohydrate M&C whatever right the
database doesn't necessarily have all
nutrients for all foods so I may have a
food that only has three I may have a
food that has 200 right so the way we
would typically model that in a c-sharp
class is just like this right I have a
nutrient and I have an array of
nutrients which is straightforward the
problem though is when it stores that in
the document database it's just an array
that can have whatever inside of it cuz
variable is a schema schema 'less so if
I wanted to ask a question like what are
the foods with the top protein content
it would have to go into each one of
those records right scan the array find
the entry and pull that out right
becomes a very intensive operation to
come right because of the distributed
nature of the data so what I'm going to
do is search for this cosmos database
that I have pre-loaded so that I can
show you exactly what the data looks
like inside the database and once again
I have this experience that I can go
into the data Explorer I can expand my
collections and here you see I have food
groups nutrient definitions of food
items the way this is stored in the
database and we'll pull up this document
you can see that I have an array of
weights which is fine but this nutrient
doc has nutrients and then water here is
a property it's not an entry in an array
this is nutrient doc dot nutrients dot
water or nutrients dot energy so now I'm
reference
just a path on the document right and I
can do that indexing I still want to be
able to work with it as an array from
c-sharp but all I had to do for that is
just put a helper method that basically
when we pull it from the database we
look at this freeform document format
that's this nutrient doc and build up
our strongly-typed list of nutrients and
then on the flip side when we're saving
we just go through our strongly type
list of nutrients and create a more
loose form JSON type document yeah so
this makes sense I mean I've seen this
kind of pattern before like processing
the XML in some cases you wind up in
very similar because some other systems
XML data right and you're converting it
into some structured thing all right and
your database and they're the way
they've organized it doesn't make sense
for you as a as a query you know
performant thing and you have to
reorganize it right so that will
actually map in and I want show the the
simple case of accessing this data now
yeah so I showed the experience of
importing it I've got a little test
application and this is just making sure
that I have my connection set up
correctly so you can see here this is
the power of dotnet core right we've got
a very flexible configuration model I
can have my keys stored in app settings
I personally don't want to check those
in and have someone steal secrets yeah
so in this case I've set environment
variables you can see here it'll pull
from the JSON unless it's overridden by
the environment and then those secrets
come in and when we deploy this into a
website we can always set them up in the
application settings right so it's very
flexible like that this is getting the
list of groups and this is the code this
is using the MongoDB driver it's
basically getting the name of the
collection that's just a helper I have
as Cori able to a list this is link
syntax that everyone should be familiar
with yeah looks a lot like in any
framework only I don't have to add that
as an intermediary so we here doesn't
developer although this is like being
home you know nothing nothing unusual
so it just iterates the groups and write
some and then here we're gonna grab the
first food item so again it's getting
that collection as Coria Bowl first or
default and then I just pull some
information out so let's take
look at that from my terminal and run it
let me see where I'm at I'm in the
console test and of course this is
dotnet you can just do the donÃt build
release and it'll come through and in
this case I've got a helper for
connecting to cosmos DB and I share my
models
between several projects so you can see
it built the models the connector and
now built the test so let's run that
that test project really quickly so
we'll go and this is USD a console test
DLL and so it's going through the
connection string getting that list of
food items it's listed it out and then I
tapped that and it grabs that last food
item for me cool so we know it's working
the next logical step in most
applications is to build a Web API
so I've got this Web API and this is
where the scenario that I talked about
with you know give me the top nutrients
comes into play if I want to sort for
example from protein so if we look at
the controller and again what I love
about this is the dotnet developers are
going to be just very familiar with this
type of syntax so here I'm getting a
specific food group so that's my route
passes in the code I'm gonna return not
found if you pass me an empty code
that's just logical right being safe now
I come through and I grab that
collection and here we go find async
food group where code equals code just
link syntax straightforward when it
grabs that I decided to enhance this as
well and grab all the food items that
are in that food group so if you get
that group detail you can get a list of
items and drill into those right and
then it just returns an okay result
that's it that's the API endpoint so if
we come inside of this application now
let's actually expand this out and ctrl
K is the secret code to clear the screen
I did not know that yep so I think this
some right-click equivalent that I use
well go into this and again Don that
bill will go to release you can build
the debug if you want and we'll let that
spend
again models connector being reused
across projects and then we'll do dotnet
and we'll go and run this and one of the
cool things when looking at your code is
is like you said it's very familiar to
dotnet developers of the cosmos
you know client library that the cosmos
team builds gives you a lot of that link
sinks in think against this so that
meant developer you can come in here and
be like yeah in a couple of hours I'm
building against kozmo so you don't have
to really write some new thing and you
have your Explorer in the cloud to see
the data is but they usually question
like my apps malfunction is it's writing
the data is it reading that exactly you
have multiple points they're just there
well there's actually a quick start to
that I love because when you build a new
cosmos DB you can literally click a
button in the portal and it'll create a
populated list of items and give you a
download for a project to hit the ground
running so it's not building it yourself
but it's having an app that you can look
at and interact with so we're going to
just hit this food groups in point to
get the list and again what's happening
here is my API is going out grabbing
cosmos DB it just pulled back those two
food groups let's pick one of the food
groups I'm going to do 200 which is baby
products so for the actually spices and
herbs so then we got this list of foods
with spices and are your baby like
spices and herbs on that they're here to
tell you exactly so now that we have a
database and we have an API we have
everything we need to do to build a
front-end yeah the focus of this is
cosmos DB so I'm not gonna go into too
much detail with the front-end but what
I do want to show you is actually let's
keep this running and we'll open up a
new terminal and in this same project I
have a web actual web page it's a single
page application that just uses Vijay s
I'm not here to say angular react
whatever it was just a great at picking
side but that's a quick way to get up
and running yeah so what I'm gonna do is
see if I have any docker pieces running
let's actually make sure docker is good
to go that little detail yeah it is
good to have go docker spinning for that
there will give it a second what I've
done is I've just created a really tiny
application you can see it's got a bunch
of HTML that uses templates and data
binding to do things like list nutrients
and lists food items just you know one
page of information it there's no
there's no back-end code this is all
JavaScript using yes you render off the
public endpoint that you've built yes
exactly exactly and for this the the
JavaScript include is just using very
simple code to make calls out to the API
endpoints so we've got queries and and
that actually reminds me well Dockers
spinning up it might be done here I
wanted to show you this inside the web
api for the foods controller this is the
one that allows me to do things like
sort or filter by a group so I've got
from the query string I've got a group
ID I've got a from the query string a
search and so this will come through and
basically project the item so MongoDB
has something called projections where
you can say even though there's this
much data in the database this is what
I'm really going to show so subset you
subset of records exactly filters and
sorry yeah and I'm just like link that
I'm used to you know entity framework
and all that exactly it's the same thing
this should be very familiar description
contains the search and the food group
ID equals the food group and you can see
I can chain these together or basically
do one the other or both and then I go
out get the Cori order it and and list
it so again very straightforward in that
sense let's come back and see how our
Dockers doing we'll do doctor all right
there you go so I'm gonna run the image
I created there's a very simple docker
file that uses something called busybox
which is a really tiny web server
because all I'm serving is an HTML page
and there's book page basing right so
I'm gonna map for day today because port
80 is an explicit inexplicably
inexplicably taken on my laptop and we
call this USDA web so we run that I'm
just gonna do this to make
it's the running it looks good let's
come back into our browser and hit like
a foot dev is so powerful it is
undervalued sometimes and here's my
simple view J s app and I can select a
food group let's do spices and herbs
click filter boom it pulls these and
then when I click on them it's going to
give me all the nutrient information so
zinc magnesium and C and then as a
person who eats a hundred percent
plant-based diet
what I might be interested in is
breakfast cereals which one has the most
protein so I'm picking the group
breakfast cereals nutrient protein give
me the top foods look how fast that was
I just came back sorted and these when I
click on this presumably it's gonna have
a higher protein kind of well actually
that's kind of small there but it's also
a small serving size so if we change to
something that has a bigger serving size
like a cup you can see the okay well
let's do one and a half let's actually
take the maximum cup amount there we go
now we've got good good protein yeah and
then we can search with the text so this
is a fully functional app on cosmos TV
and what's really neat is for the front
end I don't even have to care I'm just
working with straight api's yeah for the
back end I can use either document DB
driver or now what I showed you in
this dotnet core app was the MongoDB
driver sure I want to take one quick
second and show you what I use for my
URL shortener and that is the document
DB and what's really nice and we talked
about this in the episode with Azure
functions is the the fact that we have
these things called bindings that make
it really easy to interact with external
sources
yeah there's triggers and bindings so if
I open up this project I'm using the
document DB interface to store all my
information and when I look at this
function host what I did was added this
attribute for document DB I gave it the
name of the database the name of the
collection created if it doesn't exist I
love that about bindings the first time
it calls it can do that
and my connection string is a secret
that I store an app settings so that no
one else sees it I notice I have this
out dynamic dock
so remember schema lists so I can create
the dock however I want using this API
at the very end of my method I create an
expander object which is just you know
key value pair basically for dynamic I'm
adding a gooood to make it unique
putting the page in the count and then
based on the custom event and this is if
it's Twitter Facebook Linkedin my blog I
add that notice that there's no other
code this is an out parameter so by
setting the value of the parameter when
this function exits automatically writes
the document into Cosmos DB formance now
even though Cosmos DB is a document
database I can plug it into power bi and
pull up rich metrics and data and
filters so what I've got here is where
my redirects are coming from I'm just
doing one day so I'm saying where are
the most click throughs what hour of the
day is popular and these are my popular
links and I can come into the filter for
example and let's look at change this
from last one day to last one month and
apply the filter and now you can see
this is Sunday Monday Tuesday so
Wednesday wins for click throughs this 4
o'clock UTC which is around noon Eastern
Time is popular for clicking during time
of day and then I've got all my links
here so I get all the information I want
pulled out that Cosmos DB cool very nice
you've got the whole story basically end
to end if you can store data your
flexibility in how you query it you've
got the ability to add power bi
dashboards the top of that data what
more can people one specially you know
just to give it a try
exactly it's working great for me and
again on on the site there's plenty of
quick starts that let you download the
project pre populate the database and
get up and running in seconds all right
sounds good anything else you wanted to
show about this today that's it and
everything I've shown today is open
source on my github we'll put the links
on the site there's the cosmos TV that
will import the data for you from the
USDA it's got that built in as well as
the URL shortening project that I have
here all right well that sounds good and
we really hope people
give cosmos to be a try and thank you so
much for coming on yet again
yeah thank you I'll have you back it's
always a pleasure and again hope folks
give our technology I try at sober we're
trying to show you all the coolest stuff
and this is definitely some of the most
cutting-edge things that we've been
working on so glad to do it
a lot of fun thanks for having me on
I'll make sure to wear my my eyes are
shirt you always gotta wear it's from
now and if you don't worry ban from the
show thank you for watching everybody
have a good one
[Music]
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
Create Reusable UI (7 of 18) Building Apps with XAML and .NET MAUI
[Music]
hey everyone welcome to another episode
of Visual Studio toolbox part of our
ongoing miniseries all about getting
started withn net Maui and zaml
applications I'm your host Leslie
Richardson and I'm your ho your co-host
Robert Green and I'm your presenter Paul
Sheriff yep we're gonna have that whole
Spiel memorized we are by the
end
so this is episode seven seven of our
multi-art yeah of our multi part Series
in the last episode we talked about how
easy it is to route from one page to the
next in your application and this time
around we're going to talk about some
good old reusability practices when it
comes to creating UI so Paul hand in the
rins to you let's dive in so you know a
lot of times we need to have like a
header across multiple Pages or maybe we
have
address and we need addresses on
customers employees things like that so
the way we can do that we can create
reusable content and I'm going to create
another folder here so let's add a new
folder I'm going to call it uh partial
views wait a minut I create it views
partial that way everything kind of
sorts the way I want it and then we're
going to go ahead and add another new
item but instead of doing a content page
I'm going to do a Content view content
views are made to be reused and placed
on content Pages I'm going to call this
one header View and we'll go ahead and
add this and then we'll just add a grid
where this vertical stack layout is and
if we take a look at this grid this
might look kind of familiar to you if
you remember our user detail these were
the first like three lines that we built
it has the title it then has you know a
kind of a description and then that box
view if you remember that box view that
we have so all that stuff looks pretty
much the same I have the grid I have the
road definitions I have the label I have
the box view where he's still using the
grid. rows and column spans and all of
that but I got a little extra little
thing now we haven't talked about data
binding yet but what I want to do is I
want to able to pass in from the main
content page the title and the
description that I want to display on
this reusable header so I'm going to
create a binding down here to what's
called The View Title and the view
description now I put the path equals in
there just because a lot of WPF
programmers are used to that in Maui we
don't use that very often okay so you
don't really need to use that so the
question then is how do I get a View
Title and a view description on this
page that I can bind to well the answer
is with what's called bindable
properties and we do this in the code
behind so I'm going to come here and I'm
going to add a little bit of
code so let's kind of expand this out a
little bit so I'm adding a public string
View Title it's got a typical get a set
so that part looks familiar but then we
have this thing down here public static
readon bindable property and then it's
View Title property equals bindable
property. create sorry did not mean to
double click on that and then View Title
so type of string this is going to be a
string value so I change that we're on
this header view so we're using that
type and then I give it a default value
which is string.empty I could of course
give it whatever I want but this creates
what's called a bindable property and
then since it's on this particular uh
class right here I can then use it and
bind to it here in the zaml once I've
done a couple of things okay well
actually one thing I have to do is set
The Binding context equal to this class
that's the main thing that we have to do
there now if I want to give it some
default values I could actually
initialize those here
like
so there we go so now I've initialized
the properties and I have bound those
properties by doing this binding context
equal to this so that means this has it
contains View Title and view description
we're going to be covering more about
data binding later on but I wanted to
show you this because it's kind of
important for these reusable uis where
you're going to want to be able to p
pass things in so let's now go back to
our user detail view because this is the
one where I had the label the two labels
that have kind of the title and then the
description and the Box view now what I
want to do is I want to get rid of this
right so I'm going to get rid of these
three put one back so now I only need to
remove two of these Autos I know need to
remove two rows now what I want to is I
want to use that header view right here
you'll notice it doesn't show up Okay
the reason why is because it's actually
underneath as views partial so that
means it's in a different name space
right so you can see the name space here
so that means I need to reference that
namespace so I have to come up here and
do an XML
namespace okay and I'm going to call it
partial and I'm going to do Adventure
Works views ui. views partial there we
go and now I can do partial there it is
look at that header view so if I hit
tap okay now I can do grid. row is equal
to
zero and grid. column span is
two and then look at
this there they are there's those two
properties because I Define them in the
code right it gives them to me as
properties so can set the View Title to
user
information and I can set the view
description equal to use
this screen to modify user information
so whatever kind of description of this
I want okay and then we'll close that
tag and there we go so now the only
thing I have to do is I actually have to
since this is grid row zero I now need
to rumber these unfortunately I haven't
found a way
to renumber these all right in uh WPF it
was really easy to do it through the
editor here inet Maui at least so far I
haven't found a way to do it I'm hoping
they're going to add
this um in uh sure no that should have
been five sorry uh hopefully they're
going to add it in the next version
where they'll have some mechanism for us
to do this all right so now I should
have 0 1 two 3 4 five for all of these 0
1 two 3 four five six is that right yeah
six there we go all right so if I've
done everything correctly right should
be able to run it and we should still
see everything like it did before and
maybe it's a little might look a little
different just because I think I changed
a couple of things there but this is one
way that we now have a reusable piece
that I can now take and I can put it on
the other Pages as well right so if we
go here to the users and we navigate to
that detail there it is now I've
centered it okay the box view is going
across that way so it looks a little
different but it's still the same
information so now all I got to do is do
the same thing over here on each of
these others right so if I go to the
product detail view I'd have to do the
same thing XML Nam space partial and now
it's not going to give me the
intelligence because I gotta
stop I always got to stop stop stop and
but obviously it makes sense right I
mean we can't do everything so all right
let's go ahead and do this one so I'm
going to add a lot more stuff though
into the product detail
here take all this out and look at this
I'm going to give us a nice big lots of
labels and entries and then there is our
reusable header view again but I changed
the View Title and the view
description okay so that's kind of nice
let's do one more let's do our login
view so again I would do the XML name
space
partial
works. Muse uh M partial that's the one
great make sure you get the right one
there are a lot of name spaces that will
come up there all right and then let's
go ahead and change this guy here as
well so it looks more like a login page
but again using our reusable code and
we'll build more a couple more of these
as we go throughout this series here
let's go ahead and try this out and make
sure they're all working up to this
point
but you can see the power of this right
there's
reusability so there's our product
information screen and now you can see
I've got a lot more here I didn't do
anything on customers I did login so
there's our login
screen and of course our detail screen
so we're reusing that code instead of
duplicating
it very
nice now like I said I mean there's a
lot of things that I think you'll find
that you can do with this um like I said
like you you'll have addresses for
everybody right customers employees
whatever so that might be a great
reusable thing I think we're going to
build that one coming up as well I think
you're going to find a whole series of
things that you do with this um use it
for help for instance that might be
another thing you do put a help little
help button on every page and that help
button and all the all the code behind
can be Consolidated into that one place
too right so yeah you can do your own
cancel your save cancel you can do small
things you can do large things
absolutely yeah yeah so a really good
use I think um is to keep trying to use
these reusable uh you know widgets if
you want to call them and again the key
here I like keeping them separated into
a separate folder uh that may be just me
I don't know but I personally like them
so I know which ones are the reusable
ones which ones aren't um so I'm really
big on keeping my folder structure big
uh nice and separated okay and when
you're doing the ad new item make sure
you're using the content view zaml all
right as opposed to the content page the
content page is for a whole new page
that you want to develop content views
are the ones that you wish to reuse over
and over again cool so this kind of like
um if you're familiar with blazer
applications having different components
that you can Define and then reuse
across
whatever Pages you you're interested in
in the web context absolutely and you
know in U you know in uh what is it MBC
you'd have like you know the little
partial guys that you bring in it's a
partial tag and in WPF it's a user
control right and we had those in
Windows forms too if you remember back
then so yep so we've always had this
concept of reusability you know you just
have to take advantage of it and make
sure you're really thinking ahead to
can I use this again don't go overboard
with them but you know really think
about and you know you might start
building a couple of pages and realize
oh wait a minute those things I just if
you're copy and pasting from one place
to another stop yourself right and
refactor just like you would do a c or
any you know VB doesn't matter what
you're writing if you find yourself
copying and pasting stop and refactor
put it into something that's reusable so
it's the same thing with UI I think
right what's up next well next we're
going to start looking at some borders
and frames and we're going to use that
in a couple of places plus we're going
to build that reusable address uh
control right cool all right so tune in
and then till then Happy
[Music]
coding
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]
