Wednesday, February 4, 2026

Cortana attracts developers to build skills

AI is not the future anymore,
it's here.
We can use it.
"Hi Ariel, you have two urgent
messages."
"It will take you two minutes to
complete."
We developers need to follow the
stream.
We need to develop what people
need.
You push a button and
publish that skill on
Cortana's skill store, and
it's boom available.
It's phenomenal.
Cortana has the kind of reach
that no other platform has.
You've got millions of devices
and user that are leveraging
Cortana to do their day-to-day
job.
Technology-wise and support-wise
it is really amazing right now.
By partnering with Microsoft,
there's nothing more which a
small company can dream about.
Cortana is unique in the way
that it's a hybrid platform.
You get a visual experience and
it engages all the senses.
When using Bot Framework you are
writing the code once.
You can now publish it to many
different channels.
Microsoft understand developers
and technology.
If they're happy building on
your platform they can focus on
the things that they're really
good at.
It's very easy to go from
an idea,
to building a Cortana skill
very, very quickly.
Voice recognition, natural
language processing,
this is all on the cutting edge.
It's good to be here early
learning about it together
with our partners.
What really excited me about
this partnership is the ability
to take this dream and make it a
reality.
It's all just a new space that
we're all learning and growing
in, and Cortana skills will
continue to evolve and I'm
really excited to see where it's
going to go.

Copy and paste with correct indentation

one of my favorite new quality of life
features is one that I didn't even know
I needed
we've all copied some code to share in
Outlook on teams or in a document just
to see that the indentation ended up
being all wrong
but a new feature in Visual Studio can
help get this right I can copy the
method just like before but when I paste
it
it gets the indentation right
a small feature perhaps but one that's
going to remove a lot of frustration
happy coding

Cool features in Visual Studio 2022

Hello everybody and welcome to this video where I 
want to go through some of my favorite things in  
Visual Studio 2022. My name is Mads Kristensen and 
I work on Visual Studio and I have for the past 12  
years and I just want to share some of my favorite 
things, because I think that there's something  
here that you might not be aware of that will make 
you more productive and more happy as a developer  
I want to go through a bunch of new features 
some updates some tweaks to existing features  
that kind of just makes it all feel a lot 
better to be a developer when we're using 
Visual Studio. But before we dive in where I 
want to begin is with the new kind of reality  
in the way we work right. A lot of people have 
gone back to the offices but a lot of people  
have not and then there are people that are 
sometimes in the office and sometimes at home  
And when we have environments like this 
we tend to move between different screen  
resolutions and different monitor setups. 
So, for instance even though when I'm at  
home sometimes I take my laptop out of the 
docking station here and I sit in the couch  
and I do a little work from there. In that 
situation, I just have a small little screen  
but when I'm up at my desk like I am here 
I have a one of these ultra-wide monitors,  
so that's a completely different layout right 
and when I go to the office I will I might  
have multi-monitors and, so I want to make sure 
that no matter where I am where I'm plugged in  
what screen setup I've got Visual Studio is 
always in an optimal condition to allow me  
to do my best work and so let's take a look at 
some of the cool things that we can do with that  
So, here I have visual studio and you know and 
I have my various different windows like the  
Toolbox and I have the Solution Explorer out on 
the right side here and this works well for this  
particular monitor with this resolution that 
I'm using right now when I'm sitting with my  
laptop I want more of a kind of a minimal layout 
like this so in this situation I have a small  
screen so I don't want all these tool windows 
to show up I need that extra space to code  
and I actually also have a kind of a 
separate thing is when I work on extensions
I like my layout to be a little bit different 
so I write extensions for Visual Studio and  
when I do that, I always want like the errorless 
to be visible like you see here, and I show a third  
tool window over here by the Solution Explorer  
but that's only relevant for when I do that 
if I work with websites I might have other  
requirements different tool windows like the 
Task Runner Explorer or other things that I  
want to have shown that I otherwise don't 
need and then when I'm at my ultra-wide  
I really like to spread out horizontally over 
that big area and so it will look something  
like this now this doesn't look very good 
on this monitor and this screen resolution  
that I'm using right here but maybe you can get 
the idea how I can like spread out horizontally
Let's go back here so let's say you have dual 
monitors you could actually take the different  
tool windows in Visual Studio and spread 
out on these various different monitors  
so I don't have that here for this 
video so we'll have to pretend  
So, let's open a window here. A 
tool window - the Test Explorer  
and let's imagine that I take this and I drag 
that onto my secondary monitor okay and maybe  
I'll make it full screen or make it really 
big so I can easily see all my unit tests
All I have to do to save that windows layout 
so I can easily come back and forth to it  
is to go to window it's a save window layout and 
then we give it a name let's call it "testing"  
and that's it so now I saved this layout 
if I go back up to window you can see that  
I have all of my saved window layouts 
right here and I can apply any of them  
For instance, we can go to this one and 
then back to the one we just created  
"Testing". And I can do that with keyboard 
shortcuts to make that very very easy and fast  
So, this is super helpful I use this every day all 
the time as I move between different development  
scenarios but also different monitor setups so I 
can't recommend this high enough go check that out  
it was a feature we were introducing 
in Visual Studio 2019 and we've been  
improving it uh as time has gone by so 
super life saver for this new world a new  
situation with dual monitors and oh sorry 
multi-monitors for different locations
All right, so here's another thing. I have my 
code base here I got a bunch of files open  
but I can't really see how many how many 
files do I have open and it you know I don't  
really know I can only see what whatever my screen 
resolution allows me to see how wide the screen is  
and that's why we always have had this 
little thing up here you can click next to the  
the tabs and if you click that, now notice how 
you can see the list of open files  
There are some that are grayed out and italics.
Those are the ones that are not visible right now  
And then we have the ones that just look 
kind of normal. Those are the ones you see  
on the screen. And the one in bold 
is the one that's currently active  
So, that makes it really easy for me to get a 
picture of what's open and where can I find things  
But you know, sometimes I kind of just want to see 
everything all the time all the open documents  
So, if I go to the settings icon I can 
now click "Show tabs in multiple rows" 
and what's really nice here is that if you have 
the screen real-estate - if you have the vertical  
space, you can now stack all these tabs so you 
can see everything that's open. Very very handy
But there are some monitors that are you know 
have you know that are extra wide for instance  
and in those it would be kind 
of nice if we can take our  
tabs and instead of having them on top then 
move them to the side where we have more space  
So again, go into the settings and 
click on "Place tabs on the left"
So, it's really nice I can resize 
this to whatever. I want to make it fit exactly  
my monitor here right so what I'm doing here is 
I'm getting that extra vertical space. I can now  
see maybe a couple lines more of code in the 
editor because I moved the tabs to the side
But let's see what else we can do here because I 
have all these open documents and you can see by  
default, it's actually kind of nice they are sorted 
by the project they belong to, so my solution has  
multiple projects and they're all listed under 
each of those projects. That's very nice I don't  
have to sort that or, sorry, group by project. I 
don't have to do any grouping at all, but I really  
like that so now it's just alphabetically sorted. 
But I want it to be group by project like here
And if we
take it one step further here what if 
we colorize these documents per project  
So, now each tab has the same color if 
it belongs to the same project and that  
makes it even easier for me to kind of 
at a glance see where these files belong  
If we don't want it per project because 
I already group my tabs for project here  
Instead, we could do it by file extension so 
that's also very handy, so I can see all my Razor  
files, all my C# files, all my JavaScript 
files. They all have a separate color so  
it makes it easier for me to get that overview and 
that might be exactly what you'd like to do here  
And as a new thing we can also go in and 
say, let's do it by regular expression and  
let's configure the regular expressions. So, it's 
a file here that opens up and I can start typing  
I'm just going to copy that line up 
from above and let's say we want to do  
CSS and as soon as I save the file we can see 
the CSS file has now got updated with a color  
we have Razor I want to have something specific 
here and we can even take it further we can say  
you know everything that contains the 
word um you know category let's say  
so like something like this foreign so not all 
everything that has the word or c-a-t-e-g will  
be colorized so you can do that by folder 
you can do that by file name and all these  
things so you can really customize how you 
colorize these tabs it's pretty phenomenal
And, of course, if you move uh back up and use 
the tabs on the top they maintain their colors  
so that's really really nice so let's go back 
to per project I kind of like to do per project  
when I have the tabs up top and that um because in 
this case they're not grouped by a project and so  
having them colorized by project is my preference 
yours might be different but I really enjoy this
So, colors can be very very helpful to us when 
it helps us kind of identify the different files  
and so on but there's another thing where 
I feel a color is a big deal and it has  
to do with us sitting in Visual Studio using 
visual studio for you know eight hours a day  
10 hours a day sometimes five days a week 
right. This is this is home away from home  
and just like you do with your regular home you 
want to have a certain furniture you put in your  
house right you have uh what colors do you want 
your walls and so on you want to make it yours you  
want to make it feel like a place where you're 
comfortable and visual studio is no different  
so what's really cool now in in Visual Studio 
2022 is that we have made it such that you can  
take any visuals any Visual Studio Code, VS Code 
color theme and convert that to a Visual Studio  
color theme very easily and there's a bunch of 
these available out on the extension Marketplace  
and I want to just show you a few right here so go 
to tools theme and you can choose from any of the  
themes that you've got installed of course you 
get some out of the box with Visual Studio you  
can choose from and you can always go 
and say click for get more themes and  
that will get you to the Marketplace where 
you can install all these different themes  
and they're fantastic there's so many great 
ones in here and they really help us if we  
want a nice dark theme if we're sitting in a 
dark room for instance and we can even have  
Visual Studio changed the theme automatically 
when Windows changes its theme there is this  
thing here called use system setting and when we 
do that if Windows is running in a dark theme at  
night for instance after sunset Visual Studio 
will automatically switch to the dark theme at  
that point in time and back to the light theme at 
Sunrise if that's your Windows settings right so  
that's really really cool so a whole lot of colors 
that makes our lives better in Visual Studio 2022
but let's change that back 
to the blue theme for now
and I'm gonna change to a different  
project here so here's a just a very simple 
.NET console app and I want to show you some  
cool things and improvements we've done to the 
AI-based coding assistant in in Visual Studio
so I'm gonna type a new line here oh  
and notice how Visual Studio automatically 
will suggest that I put in a last name which is  
exactly what I want in this case I want the last 
name property to be inserted for me right here  
I also want the full name so let's hit 
enter again and this time it suggests age  
which is could be could be the accurate one but 
I want full name so I'm just going to pretend  
it's not showing me anything and just start 
typing public string full name and notice here  
I can just hit tab and I get my full name and 
it understands that full name is a product of  
first name and last name this is really really 
fantastic so the AI engine here in Visual Studio  
understands the context I'm in it understands 
that I'm right under the first name property  
chances are that I might want another property is 
relatively big and based on the name it also then  
first name it then also suggests hey the last 
name is usually what other people will add when  
they you know as the next logical property but 
what I was really impressed by was the full name  
that it understands what a full name is right 
it understands that when people have a first  
name and a last name and they need a full name 
this is what they want absolutely fantastic here
Let's scroll down and you can see here 
I have a method here called remove data  
and all it does it removes some data from 
the list that I have defined above it  
so what's missing here is a method for adding 
data so again I'm going to hit enter and  
Visual Studio already knows what I'm gonna do 
here. I'm going to create an "AddData" method  
so notice that based on the name remove data you 
know it understands what remove means and add  
and so it suggests that I created a method 
called "Add" but what was crazy was that it  
knew what that would do inside the method 
right so it knew that it should not take  
the list and remove something it should add to 
that list so this is just absolutely fantastic  
here I'm just coding by tapping enter and hit 
hitting the tab key here it's absolutely great  
and we can take it a step further so let's say 
that I want to create a new method or I want  
some code but I'm not entirely sure how I should 
write it what I can do is that I can express it  
in a code comment like this one so here I have 
a comment it says take the two arguments and add  
them together so the args refers to the args 
that come into the to the main method up here  
so I'm just writing here in plain English what it  
is that I would like to have 
happen and now I can hit enter
and Visual Studio will automatically 
suggest what that code might look like  
so it understands what I'm saying in English 
in the code comment and can translate that  
into something that is might be what I 
want so this is absolutely fantastic so  
this is the AI engine that is built upon a huge 
data set and using machine learning it's able to  
take the context that the AI engine is aware of 
and pair that up with the big machine learning  
model of what do people do in situations like 
this that's basically what the machine learning  
model knows and when we pair those up together 
Visual Studio can do amazing things like this
so um a big step forward for the AI 
engine here in Visual Studio 2022  
now let's call our new method here the "AddData"
"AddData" and we're just going to give it
some string what are we going to call 
it we're going to call it just one  
here and I'm gonna just duplicate the 
line Ctrl+D duplicates the line like this
and then we can I'm using an extension here called 
Shifter that lets me change integers and other  
things by keyboard shortcut here Ctrl+Alt+Up/Down 
and so now I can fill my list here with data  
now let's set a breakpoint and I'm going to 
set a specific type of breakpoint this is a  
new type of breakpoint temporary breakpoint so 
what's really nice about a temporary breakpoint  
is that it disappears as soon as the debugger 
hits the breakpoint so let's run this console up
so here it runs and it comes down here and you 
see the breakpoint is now gone right the break  
point is gone because it was temporary it only 
hits once so let's stop debugging here and um  
let's scroll up so here on line 18 I'm making 
a method call into a nougat package called  
Newtonsoft JSON and I don't really know what's 
going on inside the method called serialize object  
I might be able to find the source code 
somewhere on GitHub and then go figure it out  
but it would be really nice if there's a way for 
me to just go straight to the definition hit F12  
and go to definition so let's try that and it 
takes me straight to the source so this is not  
um disassembly or anything like that this is the 
actual source code using something called Source  
Link all NuGet packages can opt in to Source Link 
and that will allow Visual Studio to understand  
how to get to the actual source code that made 
up this particular version of this NuGet package  
and even when you're inside these files you 
can keep hitting F12 you know go definition  
until we come down here and it's a serialized 
object internal and this is a private string  
so I'm F12 and I'm going to definition 
through a file that made up the NuGet  
packets that I'm working on and I can see 
everything that's happening super helpful
all right I want to switch over to uh  
different project and I'm going to open it 
here it's the one I had opened just before  
notice how how when I open it up here all the 
files that were opened before are now open again  
and in my Solution Explorer I can see 
that all my folders and projects have  
all been expanded to the same levels that 
they were last time I used this project  
and that's all good that means that I 
can get right back into where I left off  
but very often this is not what I want very often 
I come in I open the project in the morning to  
start working on something and I don't want sort 
of yesterday's state to be expanded into Visual  
Studio I want something clean I want something 
fresh I want that fresh car smell in the morning  
right I come in I just want none of this open 
but I want to be able to open my app and work  
with it so I'm going to show you a couple 
of settings that are really really helpful  
so if you go to Tools > Options and then go to 
Projects and Solutions there are two check boxes  
that are really good to uncheck here if you're 
if you're someone like me that likes that fresh  
car smell so "Reopen documents on solution 
load" I'm going to uncheck that and "Restore  
Solution Explorer project hierarchy state on 
solution load" I'm going to uncheck that as well  
so now let's go back to the previous 
console lab here we can see that
the document was not open and the demo console 
project over here is collapsed it's not expanded  
so now let's open this project again that 
we had before I'm going to switch again  
and first of all I don't know if you notice this 
but it's instant the loading of these projects  
are now instant because no other files have to 
be opened no state had to be read from disk and  
hydrated into memory and applied on the UI thread 
in Visual Studio to expand all the tree notes  
in Solution Explorer none of that was necessary 
when you open a file let's say you open a C# file  
if it's the first time you open a C# file in 
that instance of Visual Studio that you've got  
open then it has to boot up all of Roslyn and 
everything to get IntelliSense and colorization  
and all of that working and that's called a 
language service and a language service can  
sometimes take a little while to load 
now it's not necessarily a long time  
but it's not instant like it is if we don't 
need it and we do like I do here so this is  
my default this is what I always do just a little 
performance trick if you like the fresh car smell  
come on all right I'm going to show you a 
one of my favorite new features that we are  
putting into Visual Studio this one started its 
life as a an extension and it's now coming into  
visual studio so let me let me demonstrate 
that so let's say I want to add a file to  
my project you know I can right click go down to 
add and new item and that gives me this dialogue  
but what if I go in to Tools > Options 
here and click a preview feature flag here
and what I want to search for is here enable 
quick add okay so now when I right click and  
say add new item or kick Ctrl+Shift+A is the 
same thing I get this little dialog up instead  
so I can still click on this link that's shown 
as well that says show all templates which gives  
me that experience that I'm used to but I want to 
get the simplified view we call it the quick add  
dialog and so in here I can just 
type a file name so a name .cs  
and that's what it does it just gives 
me the internal class and this actually  
respects if I have how I how my namespace 
rules are in my editor config or in my  
settings and it will do the right thing 
it uses the templates behind the scenes
but it's a little bit more clever than that so 
control shift a again for add new item to bring  
it back up let's type something a little bit 
more interesting let's what if we create two  
files what if I create a Client.cs and IClient.cs 
now let's try that I just comma separated them  
and I now have those two files but check this 
out IClient is an interface whereas Client is a  
class so the quick add method or dialog is able 
to understand that I client that pattern naming  
pattern should match an interface template and 
then give me that so that's really really handy
but I can also click create folders so 
I'm going to create a folder here called  
"folder" and you can name it whatever you want 
and just end it with a forward slash hit enter  
and now you have an empty folder I could 
also have gone in and said okay let's do  
what if I do some sub directories here 
and then end with a file - file.css
so I can create subfolders I can create 
files in those folders again I can comma  
separate these to create multiples really 
really handy to have all this working  
so this is in the preview behind a feature flag 
so you saw how I went into Tools > Options under  
Preview Features and enabled this feature so I 
can't recommend this highly enough I love this  
thing I use the extension and for years and 
I'm very happy that this is now in the box
So ,now that we have a CSS file open 
let's write some CSS. Let's do background  
let's do blue and let's do set 
index you know three four something  
all right so I'm going to show you an extension 
here called Shifter it allows me to flip between  
values in the editor really really easily let 
me demonstrate so I have a keyboard shortcut  
here Ctrl+Alt and then either the Up Arrow 
or Down Arrow and so if I'm on a number here  
like the z-index and hit up Ctrl+Alt+Up it 
increments the number like this if it was a
I say 0.08 here you see it will know to keep those 
values depending on the decimals and all this sort  
of stuff so really really handy if you just need 
to like increment by one or something like that  
but we can do more it doesn't have 
to be just numbers it could also  
be colors so here's the color blue so 
if I do Ctrl+Alt+Up I get Royal Blue,  
Dodger Blue you see here it gets lighter and 
lighter the color gets lighter and lighter  
and lighter and then it gets darker if I go down 
Dark Blue and so on so forth so I can flip through  
these very easily I can do the same if if we 
have a let's see here let's grab a color here  
with the color picker that color right there 
so if I have a hex value like this I can do  
the same and it understands what hex is and it 
knows it's a color in this case and so it will  
make the color darker or lighter as I either 
go up or down with the keyboard shortcuts
so I'm just going to write some invalid 
CSS here we can do other things like  
switch between true and 
false or you know yes and no  
or on off and so on and so forth right so so every 
time we can toggle between kind of known values  
shifter comes in and makes that super 
easy for us Ctrl+Alt+Up and down
so let me pin the upper window here let me build 
our project now notice what's going on down here  
in the output window I'm 
getting a very nice colorized  
output here because I'm using an 
extension that colorizes everything  
which is really nice something is green or gray 
means like it's fine there's no no problem but  
let's introduce a syntax error let's forget all 
right let's delete this semicolon and run again  
so now yeah we get an error in the error list 
but we also see that our output is now red  
because there was an error so it makes 
the output window really really easy to  
kind of just glance over or skim and 
you can see if you have anything red  
or anything orange if it's like a warning and 
that's just really really helpful so there's  
a bunch of these extensions out there that you 
can use the one I use is called VSColorOutput,  
VSColorOutput so go check that out 
really really handy thing to have
and the last extension I want to show you  
is compile again is one called 
Solution Colors so you may have  
the issue where you have multiple instances of 
Visual Studio open and how can you tell them  
apart they all look the same what if it's the same 
repo you have open in both but different branches  
now they look almost identical the solution 
names are the same all the all the files in  
Solution Explorer are the same how do you tell the 
difference between open instances of Visual Studio  
well what we can do with Solution Color 
is that we can right click the solution  
and set a color so I can give it any color I 
want or I can enable auto mode so auto mode  
basically takes the solution path and the branch 
name and other things and makes like a unique  
color that it will always map to that same color 
so if if I now open another Visual Studio here
we can see here it will apply a color as the 
solution is low to see this one turns blue  
you can see the blue color up here and the other 
one got the magenta color or pink right up there  
now I can go in here and go to options 
and make it a little bit more visible  
I can go and say instead of just colorizing 
up here the up there and it also puts a line  
at the bottom of the screen you know maybe I 
want a little bit extra maybe I want it on the  
let's hear let's look at the borders instead 
of just the bottom what if I wanted at the top  
as well so I'm gonna go ahead and do that 
and so now I have a thing here at the top  
this is very very cool because 
now I can very very easily see  
that this is the you know I have a 
magenta one I have a blue one and so on  
and I can even tell by hovering down in the 
taskbar those colors are also present here  
under each of the thumbnails in the
Windows task bar
and if I don't like magenta I don't 
have to have the even though we have  
auto mode is on I can always say no 
no I want you know give me a burgundy  
and I can keep that color and all all other 
solutions will still have the automatic one  
except for the ones that I manually said hey no 
no I want to specify the exact color for this  
particular solution and of course I can also hit 
the custom one and then select any color you know  
RGB color that I can find here so or that that 
exists rather so you can be really really specific  
here and it stores it um in the .vs folder at the 
solution root so it's not something you want to  
check into source control you can but it's not by 
default so this is just a personal setting to you  
having you having put colors on yours does not 
change the colors that your team members might  
have chosen for theirs or if they don't want 
any colors that doesn't make any difference  
either because they're kind of 
just local to you your machine
so this is called Solution Colors - Solution 
Colors so throughout this whole demo you  
probably didn't notice because there's no way 
to tell that I've been working inside a VM  
but not just any VM or virtual machine I've been 
working inside a Dev Box a Microsoft Dev Box and  
just you can tell there's really no way to tell 
this is just Visual Studio running you can run  
with any other app that I have installed that 
I need to have installed to make my uh make me  
able to work on the project I'm working on right 
so it's it's just another VM but it's hosted in  
the cloud and it's super powerful so if I go to 
devbox.microsoft.com this is where I have access  
to my Dev Boxes and this is where my it department 
has given me the opportunity to create new  
Dev Boxes that I can connect to so I have two here 
I got Legacy and I got Podcast those are two and  
they're pretty powerful uh eight core 32 gigs of 
RAM and a terabyte of SSD very fast SSD drives  
so depending on your workload you may want 
to have a super-fast powerful machine or  
if you wanna if you have a lighter 
workload you can go sort of smaller  
and it's very easy to create a new one so anyone 
can just come in here say hey I want to start  
on a new project I want a clean machine and you 
just set it up very very easily from this website  
so it's a very very cool technology it makes sure 
that your Windows is always up to date and the  
latest patches it's kind of a managed thing 
your IT department can manage all these Dev  
Boxes the way they can also manage your own you 
know physical workstation or laptops um to always  
keep them secure compliant up to date connect 
them back to your network have all those things
um so that you won't even notice that you're on 
a VM and the first time I tried this I was I I  
will admit I was a little bit skeptical 
but I signed in for the first time and  
OneDrive started synchronizing my files so all of 
a sudden I had all my files everything was there  
all the images and all these different things 
that I have on my Desktop and you know in the  
My Documents and whatnot it was all there and the 
image came pre-installed with Visual Studio and a  
bunch of other tools that I needed so I could just 
get to work immediately and it really didn't feel  
like it was like a a VM that was hosted in the 
cloud or anything like that it felt just like  
another one of my machines and um I'm very excited 
for this I have I have a specific specific use  
case uh which is you know Visual Studio sometimes 
can use a lot of uh resources when you compile  
all the time and run debug and all that sort 
of stuff it takes a lot of resources we want  
it to take a lot of resources right we wanted to 
compile as fast as possible we don't want to sit  
and wait so we wanted to use be able to use all 
the resources that we've got now the problem with  
that is that it for me I have a laptop and it kind 
of drains the battery so I can't use Visual Studio  
on battery on my laptop for very long but with 
Dev Box I can I can go all day long because I  
don't do any of that heavy lifting locally on 
my laptop it all takes place in the cloud with  
much beefier hardware than what I've got in my 
laptop so I get a much faster experience and I  
get battery that lasts all day it's perfect so is 
it public preview you can go ahead and try it out  
um I encourage her to do that I think it would 
be fantastic and um there's a whole admin story  
for your it admin you may want to uh talk to 
them about it as well because there's a whole  
opportunity for them to make this secure and 
compliant and all this sort of stuff making sure  
that you don't spin anything up uh that they don't 
think you should and um it's so it's a win-win  
it's a win for the developer and it's a win for it 
you really get that flexibility that productivity  
that and get all the hardware you need when you 
need it so um go check out Dev Box - Microsoft 
Dev Box and that was it for this uh 
brief video of me going through some  
of my favorite features in Visual Studio 2022 
new features are added all the time so make  
sure you go check it out uh install the latest 
version and try it out for yourself thank you

Create customized instances of Visual Studio

I do a lot of different type of
development
sometimes I build websites other times I
build visual studio extensions and other
times yet I build Windows apps and I use
different extensions I do I use
different window layouts and depending
on which of these type of applications I
build so would be kind of cool if there
was a way that I could customize visual
studio for each of these different
scenarios or application types that I
built well what if I said that there was
a way to do that and it's a feature
called rude suffix it allows us to start
a visual studio in a way that it uses
its own copy of its internal registry if
I don't synchronize settings it can have
its own theme make it as its own habits
on Windows layout and all these
different things that sets it apart from
the regular instance of visual studio so
let's take a look at how we do that so
here I have a visual studio it's sort of
my general purpose thing this is what I
use this is my typical layout for any
type of tab that I built now let's say I
want to create something for when I
build visuals to do extensions that I
want for that particular version of
visual studio I want different types of
extensions installed so let's go to the
developer command prompt and type dev
end and then slash root suffix space and
then any name I can think of ext4
extension that's something I can
remember so let's execute that and it
stars visual studio up and you can see
I've already used this root suffix
before and so you can see it looks
different and if we look down at the
taskbar here we can see it is the same
version of Visual Studio right there
they're side-by-side but they have
different window layout and they have
two
front toolbars visible and also if we
look at the extensions that are
installed we can see here here's one set
of extensions for that I have
specifically for extension development
and if we go over to the other one we
can see that it is a different set of
extensions that are here for this
particular instance so it's the same
version of visual studio but using the
root suffix switch command line switch I
can separate them out just remember if
you want to if you want to keep theming
and other things separate from each of
these instances disable the
synchronization of settings otherwise
once you're signed into Visual Studio it
will synchronize settings across all
your different route suffixes and so on
so that is one very easy way to
differentiate the different workloads
and have Visual Studio customized for
each of them thanks for watching

Create .NET Core Projects with the Command Line

>> Did you know that the command
line is so powerful that you can
actually create.NET Core
projects within it?
Learn more on this episode
of Visual Studio Toolbox.
[MUSIC].
>> Hey everyone. Welcome
to Visual Studio Toolbox.
I'm your host, Leslie
Richardson coming to you
from my very professional
childhood bedroom studio.
Today, I am joined by Sayed Hashimi,
who is a Senior PM on the
ASP.NET team. Welcome, Sayed.
>> Hello. How's it going?
Definitely happy to be here.
Been on Visual Studio Toolbox
bunch of times in the past.
I always love coming out here to
show the latest and greatest.
Thanks very much for having me.
>> Yeah, welcome back.
Today, we are going to be talking
about creating.NET Core projects
on the command line, right?
>> Yeah, that's right.
What we're planning on doing is
basically creating
a series of videos.
The range of topics
will be we'll first
start out with how do you
create projects using.NET New.
Then we'll move on to using
community created templates from
both.NET New and Visual Studio.
Then we'll move on to then
start showing how to actually
create templates and how to
customize this for Visual Studio.
This is really just the first
video in that video series.
Just like what you mentioned,
in this video we'll be
focusing on using.NET New and
understanding the basics before
we get started on creating
our own templates here. Yeah.
>> Exciting. Why the command line?
What's the perk or why
should I make a.NET Core project
within the command line?
>> Yeah, sure. I think
that's a great question.
If we were to rewind
the clock like five,
six years back, before
there was.NET Core.
there was.NET Framework.
In that world everybody was
creating and building and developing
inside Visual Studio itself,
and I mean Visual Studio on Windows.
But now, with.NET Core,
we live in a different world.
If you're creating a project template
and if you want to
have the broad reach,
you need to surface that in
a way that can meet users
where they're at, right?
Today, users that will develop
with Visual Studio 2019
or maybe with Visual Studio
Code or Visual Studio for Mac,
there's also third party editors
out there like JetBrains Rider.
You can also customize
any editors like Sublime
and Notepad++ to also do
development with.NET Core.
The way that we've architected this
is we have what's called
the template engine.
You can think about
that as being like
the foundation that
everything would sit on.
We've got the template engine.
Then sitting directly on top of
that would be.NET New command
line and also, Visual Studio
and Visual Studio for Mac.
The idea is we can
create templates using
the template engine and
then we can surface
that in all the relevant locations.
If you create a template
with template engine,
you can get that to appear
in the.NET New command line.
It can also show up in
Visual Studio 2019,
Visual Studio for Mac.
Also, I believe Rider's got
that extensibility as well
where it will show these
community created templates.
To answer the question is
really you just need to meet
the users where they're at.
The people developing.NET
Core applications,
they're not only in
Visual Studio anymore,
they're in various different places.
Then also, I think one another
benefit is creating a template with
the template engine is very easy in
comparison to the
alternative technologies
that are available out there.
That's why I would say that.
You get the broadest reach.
Then it's also easier
to create and maintain
your templates if you author
them with the template engine.
>> Great. Yeah. I personally
enjoy using the command line and
I always forget that
you can actually create
a project in the command
line to begin with.
Can you show us how it works?
>> That's right. Yeah. Let's let's
go check out the Terminal here.
Let me get my Terminal
app opened up here.
I got a helicopter flying in the
background Sorry guys about that.
First, let's just explore .NET
New..NET New is delivered
with the .NET SDK.
Let's just go ahead and execute.NET
New and see what we get out of this.
If you run .NET New,
it'll go ahead and show you the
various different templates
that are available to be used.
Here we can see I've got a
mix of different things.
Most of these are built in templates,
but we can also see I've got
some community and custom
templates installed here as well.
At the bottom, there's
also some examples here,
so let's take a look at that.
If I were to do .NET New,
and then we would
give it the name for
the template that we
want to create here.
That's what we see
here in short name.
There's various
different options here.
Let's go in and explore
the MVC option here.
If I was to do.NET New MVC,
I could also get help that's
specific for this
particular template here.
You can do a.NET New,
template name, -h to get the
template's specific help.
You can see we've got
a bunch of different
parameters here as well.
The help will basically spit
out the different parameters
that you've got here.
Then we can go from there.
There's also some
common parameters here.
Where are we at? Those are here.
Some of these that we'll be
taking a look at is output.
Then the install we'll be
looking at in the next video.
There's also a name value here.
We'll be using name and output
here during this video.
Let's go and create a directory here.
I'll say demo one.
Let's go and go into that.
If I just wanted to
create an MVC project,
I can just do .NET New
MVC and then that'll
go ahead and create a project right
in this particular folder here.
Yes. It creates the
project and then it will
call NuGet to restore them.
Let's take a look at
the contents here.
You can see I created an MVC project
and it's named demo1.csproj.
It got this name from the
name of the folder here.
If you don't specify a name,
then the folder name
will be used by default.
That's the idea here.
Let's also take a look at
this demo project real quick,
or actually, sorry about that,
let's take a look at the program.cs.
One thing that I want
to point out to you.
Excuse me. The project
name was demo1.
We can see that when I
created this project,
the name space was customized
for that project name.
Now it's created demo1 here.
>> Nice.
>> Yeah. We'll talk a lot more
about how these replacements work and
all that stuff in our
additional videos here.
>> Yeah. That's exactly
what I'd expect if I
were creating a template
via Visual Studio.
>> Yeah, that's right.
The mechanism that's
used here is the
same with dotnet new as
well as with Visual Studio.
There's another way that
I could do that as well.
Let me pick a different
template here,
so let's say webapp,
that's the name of another
template that we have.
Instead of just going into
the directory itself,
you can specify the directory
that it should be created at,
and then that will also be
the name of the project.
I can say, dotnet new
webapp MyCoolWeb.
Let's go ahead and create that.
Now, that will create it into a
folder that's called MyCoolWeb.
Let's just take a look at the
startup.cs for this one, I guess.
We'll see that the namespace for
this one has also been
set to MyCoolWeb.
Now, we've got a project
that builds and runs.
I can verify that by
doing dotnet build.
Then we could also run
this project with dotnet run or
we can go ahead and load this up
into Visual Studio or
whatever editor or IDE
that users prefer here.
That was one way of doing it too.
We also mentioned that we would
show the name option there.
Let me go into this
new folder, demo2.
If I say dotnet new webapi,
and then if I give it a name,
I can say MyWebApi.
Now, that should create
it in this folder,
but with the name MyWebApi,
or in the folder called MyWebApi,
and then the name would be MyWebApi.
If I was to inspect the program or
the startup or the weather forecast,
we would see that that
namespace has been
declared appropriately as well.
Let's take another look through
the help real quick
and see if there's
any additional options here
that we haven't talked about.
One was dotnet new list.
Let's go ahead and take a
look at that real quick.
dotnet new -l. For dotnet new- l,
this would just list
out all the templates
that have been installed here.
Like I mentioned, I do
have some custom templates
installed here so if you
see something different,
then that means that
I've just installed
something additional that you
might not have on your box.
>> Yeah, I don't recall
seeing sayed tool on mine.
>> Yeah, that's right. Let
me explain this output here.
Here, we've got the
name of the template.
This is just a user-friendly name.
Here's the short name.
That was the name that
I was using before,
we saw MVC, webapp, and webapi.
Those are here, MVC webapp,
and webapi is right there.
Here, we can also see
the language options.
Let's say if I was an
F# or VB developer,
I can take a look at this
language column to tell me,
what templates are available for
that particular language as well.
Then the tags are just categories.
If I was interested in a console
app, I could do console.
Let's do this, dotnet new -l -h.
What help is available for list here?
We can see that I can
filter by language,
and we can also filter by type here.
dotnet new -l -lang F#.
This should display
only the F# templates,
and then similarly for VB.
I think we can also do
something similar for the tags,
I believe, or the
type here, basically.
If I was to say, --type Console.
That one looks like it did enter.
Oh, sorry about that, my
bad. This is different.
One thing that I forgot
to mention here was on
the list of templates
that were output here,
there's a variety of
different things.
The vast majority of these
are project templates,
but we do have a few item
templates here like gitignore,
globaljson, so on and so forth.
That's where the type
filter comes in.
If I was to list the project,
I can view dotnet new
-l --type Project.
This will just show me all
the project templates.
If I wanted to see only the item
templates to replace
the type of item there,
you go back and see how
can we filter on the tag.
That might not actually be possible
here to actually filter on
the tags here but in Visual Studio,
these tags will appear
and you can actually
filter in Visual Studio there.
>> That is pretty sweet. I had
no idea you could get all
of the same functionality
that we would if we were to open
Visual Studio for the first
time just in the command line.
>> Yeah, that's right.
Then the one thing that I
forgot to mention here was
everything that I showed here
was with built-in templates.
But you would get the
same exact functionality
with custom templates as well.
If I were to do dotnet
new sayedweb -h,
I would get the template
specific help for that custom
template that I've created here.
You get the exact same experience,
whether it's a built-in
template created by
Microsoft or if it's a template
that you created yourself,
or if a third-party
company created it,
you'd get the same
exact experience here.
It's not like we're special casing
the Microsoft templates here.
We got the same exact experience
all across the board.
>> That's really cool.
Makes you feel more
official with the
templates that you create.
>> Yeah, definitely.
That was some feedback
that we have received a lot
over the course of the
last several years
was the template authors,
they want their templates to
appear in a first-class way.
So when we create a dotnet new,
we made sure to fulfill that promise,
and we're also trying to do the
same thing in Visual Studio,
and Visual Studio for Mac as well.
>> That is exciting stuff.
>> Yeah. I think that's
really about it here.
We talked about how
can we use .NET new
and how can we use the
help system to explore,
how to learn more about the command,
and also, some basics here.
I think that's really
it for this video.
In the next videos that follow,
we'll start seeing how can we install
community templates and then use
those in dotnet new as
well as Visual Studio.
>> That is some good
stuff, I can't wait.
>> Great.
>> Just to close out,
you mentioned that you need the .NET
SDK for the command
line functionality.
Where can users go to make
sure they have that installed?
>> Usually, I just go to GitHub,
actually, to get that.
But I think the easiest way is
to just do .NET Core download,
and that'll take them to
the right place here.
So just dotnet.Microsoft.com to
get the latest download of.NET Core.
>> Can't wait.
>> Everything that I'm showing
here applies to both .NET Core
3.1 as well as .NET Core 5.
>> Sweet. That is very exciting.
>> Thank you very much.
>> Thank you. Tune in next time
when we talk more about
the awesomeness you
can do with .NET
templates and projects.
Until then, happy coding.
[MUSIC]

Cortana Analytics Building a recommendations model in 5 minutes!

hello everyone my name is Luis Cabrera
and I work in the azure machine learning
organization but today we're going to
cook ourselves our recommendations model
one of the missions of Cortana analytics
is to in a sense democratize machine
learning we want to make sure machine
learning is available to everyone not
just to data scientists but also to
developers we want to make sure that
everyone has the capabilities to harness
the power of machine learning one way in
which were doing that is by providing to
you what we call machine learning api's
this machine learning api's are
completed services that you can find
today in the Cortana analytics gallery
these are already baked they use machine
learning capabilities but you do not
need to be a data scientist in order to
use them
today we're going to be talking about
one specific API called the
recommendations API let me start with a
story when I was a kid and I wanted to
watch a cook a cooking show in my native
country of Guatemala there were only two
channels that I could watch at any time
so my probability of getting the best
channel at any time was about fifty
percent and that was great but today my
children you know if you have a service
like xbox you really have over a hundred
thousand streaming options to prick from
which makes it very very hard to find
the content that you need so actually
for the Xbox we built recommendations
engine and in order desire to
democratize or to bring to the world
this capabilities we put these
capabilities together in the
recommendations API so let's get cooking
what you aren't going to need to create
a recommendations model is some catalog
data these are like the the items that
you want to sell for instance or that
you want to recommend you will need some
usage data which represent the previous
transactions that you have seen in your
application or you or your retail site
for instance so you mix these two pieces
together I will show you what these
files look like you you mix them in this
beautiful recommendations builder you
let it bake for a few minutes and then
you are ready to serve in your favorite
website or mobile application okay so
let's get cooking here so first of all I
am going to gallery dot Cortana
analytics com where I can see several
machine learning related resources for
you including machine learning AP ice so
if i click on machine learning api's it
will show me a catalog of different API
study we have available for you for
instance we have faced api's text
analytics computer business API etc but
today we're interested in the
recommendations API so I'm going to
select that one where you can now you
can see a description of the service
links to documentation and and so forth
you will notice that you can also sign
up for the service I have already signed
up so I am NOT going to do it right now
but I have to tell you that you actually
are able to sign up for ten thousand
three transactions per month enough for
you to be able to play with the service
and once you have signed up for the
service you can use the recommendations
UI which is in beta right now and i
actually have already opened the service
which is right here once you are in the
in the recommendations you I you can
create new projects let me create a new
project i will call it connect and this
project is going to be my container
where i can add the usage the catalogue
files and where i can later train my
model so it just created the the model
and step-by-step it asks me to add a
catalog file so i actually have a
catalog file that with transactions from
from the microsoft store actually so i
am going to use my catalog from the
microsoft store as you can see it was
able to upload the catalog now the
question that you may have is what does
that catalog actually look like let me
show you so that catalog has a very
simple format it shows you that there is
a items the identifier for each of the
items in the next row it will give you a
description of the items and then a
description of what type of item is in
my catalog so in this case these are all
items from the microsoft store for
instance so you know i want to be able
to recommend to a customer when they are
buying one product what other type of
product will make sense for them to to
purchase as well it will allow them to
discover those items faster as well so i
need information on metadata about my
catalog and then i also need information
about each of the transactions
in in column a here I have the actual
identifier for users and in in column B
here i have the identifier for
particular products so for instance in
in the first row here I know that person
with id3 BFF DC blah blah blah but item
QR 2000 11 which may be a piece of
software or a piece of hardware for
instance so the system is able to take
the the catalog and then the usage files
and I will just add a usage file here
and you can see that it's starting to
upload the usage file as well so so once
it has both of these pieces of
information it can crunch the
information to create a recommendations
model for you I should point out that
usage files should be less than 200
megabytes in size and if you have more
than 200 megabytes of information you
are allowed to upload several files okay
so once once you have the catalog and
usage file you can actually create a new
build the the first file uploaded and I
am in the process of uploading a second
first once the files have uploaded to
the system you can create a new build
and you can pick a type of build we have
two types of builds recommendations and
frequently bought together we also have
a ranking bill but that's an advanced
feature that you can check in the
documentation for it now so let's say
that we want a recommendations build and
then all I will have to do here is is
click build and then this is going to
take about 30 minutes
okay so after the 30 minutes we are able
to see our build and we can actually
score it so in this case I have to tell
you that I do that images and you don't
see how i am adding the images but when
you select an item you will be able to
see the recommendations for that item so
in this case we have Mike Wazowski the
Infinity figure and you can see the the
recommendations for that item right here
are all that infinity figures which
makes sense you know if a child by its
design and they may want to buy the
other ones as well so if someone on the
other hand were to buy a game like
Assassin's Creed which is a more mature
game we will expect to get
recommendations that are a little bit
more mature right so sage Anarchy Reigns
men in black fuse which makes sense
right these are other games for xbox 360
which people purchase when they when
they purchase the assassins creed game
so in this case you can see how as I
pass one item to the recommendations
engine it is able to return to me all
their items now this is all great and
you already have a model by now but I
have to tell you that if you go to to
the gallery you are also able to
download the coals to do exactly what we
did in that you I it's actually pretty
simple and I'll walk you through it this
is this is actually the exact code that
you download in the sample so all you
need to do is just like with it in the
UI you need to create a model which is
what we're doing there on the only
create model call then you need to
import a catalog and a usage file which
which are the selected lines right there
once you have imported those lines you
want to trigger a build which is done in
the in the next line
so you want to build a model you pass at
the model ID and then the rest of the
code really is in a tight loop just
waiting for that bill to be completed
once the build is completed you you need
to update the model to use that build ID
or that build as the default build this
will allow you in the future to have
several bills and then select which one
is the one that that your model should
be returning recommendations from so it
was actually very simple and you notice
how we were able to use the UI to create
a recommendation sending but you can
also automate it in code as well I
should point out that you can retrain
the model as you get new usage data as
well I should point out that there is
other related content that you may be
interested in we actually gave a
presentation on intelligent retail
scenarios at the Cortana analytics
workshop and it's on channel 9 so this
is the link and you can find me at Lewis
Scott microsoft com and that's my
twitter tag as well
thank you so much and it has been a
pleasure spending some time cooking with
you

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]