Showing posts with label toolbox. Show all posts
Showing posts with label toolbox. Show all posts

Wednesday, February 4, 2026

Committing code changes (2 of 5) Getting started with GitHub

on this episode of Visual Studio toolbox
we're continuing our mini series on
getting started with GitHub we're going
to see what happens when you actually
write code
[Music]
hi welcome to visual studio toolbox I'm
your host Robert Greene and this is
episode 2 in our five part miniseries on
getting started with GitHub in the
previous episode we looked at how to
create a project in visual studio and
then we created a GitHub repository with
that code and in this episode we're
going to start writing some code and see
how we work with GitHub
so I created a simple console
application we have a simple line of
code here let's make a change to it so
I'm going to change the greeting to
hello Visual Studio toolbox
now get is watching locally and I can
see that we have a change so if I come
down here to the lower right and I look
at this little pencil in the status bar
it says one telling me I have one change
I click that and I go to the get changes
window where I can see all of the
changes I've made and I can see that
program.cs has been modified well from
here I can undo the changes if I want I
can also stage these or stash them which
means I'm not ready to commit now but
I'll commit them later on but in this
case I think I'm ready to go so I'm
going to enter a message which is
required when I do a commit I have to
enter a message which is a good thing so
I'll just say changed greeting
and then I have some choices I can
commit all commit them to my local
repository which does not send them to
GitHub I might do that if I want to uh
if I'm done working for the day and I
want to make sure that I've kind of
backed up that code committed it to the
repository locally in my machine and
then when I'm ready to send it up to
GitHub I'll do a push so I'm going to do
this right now this is one of my
favorite features you have to save your
files before you commit I almost never
remember to so like Visual Studio warns
me so I'll save this and commit it and
what that's going to do is copy these
changes up to the master branch in
GitHub so successfully pushed so not
presumably we can pop over to GitHub
and look in the code and look in program
and there's the change I made very cool
now what we can also do in GitHub is
click on this changed greeting and see
what the changes were oh I changed it
from world to visual studio toolbox very
nice
now if I come back into Visual Studio I
know I have this change here what I can
do is again go to our Branch history and
see that I changed the greeting so again
Robert is me locally Robert Green are
any changes I make on GitHub
representing another developer or me on
a different machine and then I change
this locally and if I double click on
this I can see the changes so this is
the code that was this is the code that
is I can switch around from side by side
mode to inline mode whichever one works
best for you
okay
so now
I'm not the only one working on this
application turns out
so
maybe the other developer also decides
to change the greeting and I'm going to
do this in GitHub just to keep it simple
typically you'd probably do this in
Visual Studio or Visual Studio code but
rather than have multiple visual Studios
floating around I'm just going to make
all my changes in GitHub
so I'm going to change this to visual
studio developers I mean commit the
changes
commit message defaults to update
program name and extended description
I'll type changed greeting and I'll
commit this to the master branch
okay so another developer is made a
change
now back in Visual Studio
I'm told hey somebody changed your code
now I've got a couple choices I can do a
pull which will bring down those changes
in overwrote what I wrote but maybe I
want to see what the changes are ahead
of time so I can do a Fetch and what a
fetch will do is bring down from GitHub
the latest version of the master branch
and store it in my repository history
but not overwrite my version
so now I can see what the differences
are so if I click here I see I have one
incoming
and I can see that
program.cs was updated by somebody on
the server I double click on that and I
can see
the code that I have Visual Studio
toolbox and the code it was changed to
visual studio developers and I'll decide
okay that's fine I'll take that so now I
can do a git pull and copy down the
remote version to my local version
and now if I go look at my program.cs
I've got the latest version so this is
how I can keep my local version of the
repository in sync with the remote
version up in GitHub which will be sort
of our official version and then if I
come into the history and do a refresh
here I see that I changed the greeting
locally somebody else changed it on the
server I did a poll to bring everything
down and now my version of the code
locally is in sync with the version of
the code remotely that's basically how
we're going to have multiple people
changing code and everybody then pushes
it up into the remote repository which
is the official version and then by
polling we can keep our local copy in
sync
so what we've seen in this episode is
what happens when we start making
changes to code so we made a change we
pushed it up to GitHub somebody else
made a change they pushed it up to
GitHub so we saw you can have multiple
developers or you working on multiple
machines or multiple versions of Visual
Studio it all works how we can keep our
local repository in sync with the remote
repository which is essentially the
official version of the code
if you're watching on YouTube and you
like this please like us share with your
friends and come back for episode three
in our mini series we're going to look
at working with branches and see what
pull requests are used for
we'll see you next time on Visual Studio
toolbox
foreign
[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

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]

Database DevOps with Redgate Data Tools

hi welcome Visual Studio toolbox I'm
your host Robert Greene and joining me
today from bill that the beautiful
Washington State Convention Center is
Steve Jones from red gate thank you and
today special guest co-host mr. Scott
Klein renko's remember we are going to
be talking about data today and
specifically database DevOps yes red
gate provides some database DevOps
tools inside Visual Studio Enterprise so
we're going to talk about those you're
going to do some demos yes but we're
going to start off by explaining this
concept of database DevOps
all right we talked about DevOps all the
time continuous integration continuous
deployment pipelines fast cadence you
know lots of quick releases and we
talked about it from code but apparently
it applies to databases as well no we
don't you know ready to spend a lot of
time in the last five six seven years
evolving our tools to try to support
more rapid database development you know
as much as we've studied the DevOps
movement that continuous delivery stuff
the things that Mountain Martin Fowler
talked about they always leave the
database out because the database is a
challenge the database has to maintain
state from time to time to time right
unlike code where we could just replace
a DLL or an XE in the database I can't
just drop those tables I mean my life
would be easy if I could write life
would be great but you can't just invent
a new engine to dry it out a B testing
did people actually want a person class
in this application well some do some
don't so we'll we'll cut that out it's
easy in code right it's been yeah for
developers but for the database people
it's more difficult and I think that's
led to the hesitation from database
people to move faster but certainly all
the application developers you've got to
move fast you've got to deploy code I've
got to deploy enhancements and then
often means I need a place to store some
of that data so Red Gate is working to
try to get the database to move just as
fast as the application so give us an
example a real-world example of what
that might look like how is it database
changing so here's a great example we
all know security is a big deal right
never seen data breaches every week
we've got all these problems all the
time
there are plenty of customers that are
starting to do things like implement
encryption into their system so I want
to implement always encrypted on to a
database platform so over you know
PayPal whatever ecommerce I'm doing so
I've got to field that story and perhaps
credit card numbers or emails or
something else and I want to implement
that quickly well it takes time it's
difficult to do encryption so one of the
things I might do is I might add a new
column that will support that encryption
so I will do encrypted data there but my
application has to run 24/7 right so
what I do is I build a view on top of
this table that contains the old column
that's still there and I put a case
statement in there some type of switch
that says if I have encrypted data we'll
send that back and the client will deal
with the encryption and always encrypted
but if I haven't got encryption because
one of my applications isn't there let's
send the old column back that isn't
encrypted okay so in a 24/7 environment
I can evolve my database quickly using a
devops process keep it running at the
same time meet the new requirements that
I have for security for anything else
cool so it's not like you're inventing
entirely new tables changing the basic
structure but it's more incremental
changes to support incremental
functionality your needs exactly you
know in the database DBAs have been
hesitant to make changes because I've
been a DBA in my career and we're
responsible for stability and
availability and performance and so we
get nervous about changes not that and
you don't write good code but every once
in a while it's a little freaky so we
get hesitant which means we try to delay
deployments we try to stack things
together get lots of changes right which
increases my risk yeah and it means I've
got to make a bunch of changes at once
and that's the opposite what we want to
do in DevOps right you developers we
want to deploy often I want to be able
to make a new branch write some code do
a pull request have somebody prove it
deploy that next week or deploy that
tomorrow and we want the database to
follow along and so I've done that a lot
of my career and Red Gate has really
spent a lot of time to try to help do
that as well mm-hmm could we back up
just a second because you and I were
asking about this I'm like if DevOps is
understood I think primarily by
developers right right but if I'm a
sequel person you know what is this very
very simple what is
and what does that mean to me for no
good because I really how many how many
sequel people really understand what is
what it means yeah what about
I mean DevOps is kind of amorphous like
the cloud there isn't necessarily this
definite definition what it is it's
adhering to these principles that I
followed for most of my career when I've
done Six Sigma or ISO Tiger software I
want to learn and I want to become
better every time I want to keep my risk
to a minimum and I want to adapt process
around what I do all right a lot of what
we do in DevOps when we do continuous
integration continuous delivery we do
instrumentation telemetry is we're
adding process but we're doing in a very
lightweight non intrusive way so we're
trying to do a database as well so that
you can make your changes you can deploy
them out in smaller increments and have
them work with less risk now there's no
magic right there's no magic to making
database changes all we're doing with
DevOps is we're really automating the
things you would normally do yep in
trying to wrap them in a process so
they're reliable and repeatable because
ultimately we as humans we're not
reliable repeatable we're very creative
we get paid to solve problems and
compose solutions but we have to do the
same thing over and over and over again
okay we're bad and what we're trying to
do with DevOps is try to implement some
process that makes it repeatable and
reliable yeah cool all right yeah we see
some things happen absolutely demo time
demo time so I've got Visual Studio
Enterprise on my machine and in the box
Red Gate is shifting is shipping a ready
roll core product and ready roll is one
way of performing database development
and we built it as a project that's a
first-class project just like the
database projects that are in SSD T and
so when you implement this it's very
similar to that project now ready roll
works in what's called the migrations
based development framework where we
track every changes so if I look over
here I've got all these migration
scripts and each one of these is just a
different set of data scripts that I
would run in development as a developer
database developer or a full-stack
developer I would just kind of make some
of these changes and what ready roll is
doing is kind of tracking them as we go
along and so that when we deploy them we
execute them the same way mm-hmm now
it's just it's it's kind of
philosophically different from SSD T or
some of the other Red Gate products and
that those work in a state based world
where we can
the state of the database the state of
the development at and we come up with
the script yeah right so this is kind of
tracking one by one yeah let's spend a
little bit more time on that because
there are the sequel server database
tools yeah the Redgate tools which ship
in the box because although you do they
don't just install by default but you
can go to the individual components and
get out the work there they are
so talk to us a little bit more about
this state versus migration approach in
the state but I complementary or they
you don't know the other they're kind of
opposite you know Redgate got started
with sequel compare which is a schema
comparison that tool that is very
similar to what's an SSD to and in the
state based world we make a bunch of
changes just like I might do in c-sharp
or Java or something else and then I
take those changes and I compare those
changes with what my production database
looks okay and then I develop a script
kind of in real time a dynamic script so
kind of like with things we would do an
application program it's kind of like
run time versus design time okay so in
the state based world you do that and
that's fine and it works great for so
many people people use read gates to
compare to do that they use SSD to do
that and it's great the problem is
there's a domain of problems that you
can't solve with the state-based
comparison so if I rename something how
do I know I renamed it is it a drop-in
ad or a rename I'd if I add a not know
column there's data manipulation
involved I can't solve that problem so
there's a class of problems that
state-based comparison doesn't solve
right in SSD T people use pre post
scripts to get around them with red gate
OU's will use one called migration
scripts to get around it but it's just
one way of development again in my past
I've worked in Oracle db2 world and a
lot of those larger systems older
systems have worked in migrations world
where they go every script you write
every change you make the database we
track that so when I go to upgrade I run
script one and then two and then three
and then four and then 56 or 57 to 58
and it's a bulletproof way of doing
deployment but it can be cumbersome and
time consuming because the other thing
is if I add a column to a table drop a
comment table add a different column all
three of those things run in production
on my development database with ten rows
data who care
my production database with the billion
Reza data slightly problematic yeah so
neither one is perfect they both have
pros and cons they're just different
ways of working at the world and
throughout my career I've been working a
sequencer for 25 years now what I find
is that people fundamentally fall into
one of two camps either like state-based
like SS PT and sequel compare or they
liked migrations like ready roll or
liquid-based Flyway DB DB up various
frameworks antenna is this a kind of a
thought shift as we you know you've been
talking about database compare you know
schema compare an SSD teen things like
that I is this a shift and how I think
about working with databases now from a
you know because because we have all
these people like yep no schema compare
I know SSD T but now we're you know
ready roll and I'm like how do we get
people you know start thinking down
those I think just philosophically you
decide you I'm going to develop one way
or the other
okay it's kind of like saying you know
do i mix functional programming an
object-oriented I don't I kind of choose
one or the other and I have either some
philosophical leaning or I have some
requirement that says we should go one
way the other in the database world it's
the same thing it's just neither one is
better than the other one they both have
pros and cons they both have workaround
yep and but it is one more of a best
practice type of thing no I mean there's
advantage so one of the things we love
when I've worked in like Oracle
financials with large ERP systems is
that when I do migrations based of LMA I
can take any birds in the database and
upgrade it to any other version because
I have all the scripts obviously all
right so if I have clients at version 2
and version 3 and version 4 I can give
them the same set of scripts and get to
version 5 and that's easy in the SSD tea
world I need custom scripts for every
version right ok so there's pros and
cons the other side is I'm tracking all
these scraps right ok
some developers hate this correct and
some some don't like the state based
thing because they're not confident that
will actually develop all the changes
employed right so it it's not really a
shift it's an option so ready roles are
giving us an option for people that
prefer this it's how we actually think
about things you got actually okay all
right so let me make a couple changes so
we were in Visual Studio ready roll is a
part of Visual Studio it ships in the
box
for enterprise there's various things
you might want to do some people like to
work in Visual Studio so no it doesn't
like that let's see if it'll work this
time
let's forget let's do it this way
because I'm a code guy so I don't mind
writing code so let's create a new table
we'll call it channel 9 and I'm here
with Robert
he's an inn in Scott he's a would make
you a masquerade of Archer yeah but back
to your max all right so I can I have a
reliable type if I can run it very kind
of on a path and you're just fly deeper
yes so you're there I can't anyway I'm
getting from this you know I've got this
I've got this table here that's got a
feeds in it let's add a new feed so it
feeds into one of the things we also
subdivisions to enterprises is single
prompt core which is our intellisense
version and it's pretty good so we'll
add another feed in there and then
because we know some people like to work
in management studio we can always work
in management studio as well so I can
pick up changes here so let's pick
something in my development database
here and let's pick some stored
procedure in here and let's just pick
this one so here's a stored procedure
and here's one of the other things about
sequel code that makes it life difficult
is this code is fundamentally different
from the code I used to build a sore
procedure right because I would actually
have to have a create here to build the
stored procedure but instead I need an
alter mm-hmm right when I build a class
in c-sharp when I say you know public
void class yeah that code always looks
like that I mean yeah right whether I
add or subtract the code fundamentally
the same in here it's different but in
this case let's change something let's
actually do a best practice and we'll
just pick up some of these columns and
rather than the select star we'll do
this and I'll execute this so I've made
a bunch of changes here now so in ready
roll one of the things we do is we've
added a pane here and what this does is
allows me to kind of
for any of the changes that I've made
and once I've done them you'll see it's
detected number of changes and when I
import these it's actually going to add
them to the project and so what we'll
actually get I'll refresh it to make
sure everything is added we've added
some different scripts here so those
migrations are records it's a record of
changes that you have made in the
database that are ultimately going to
need to be propagated or published or
whatever look exactly - so this script
a17 here is my insert right we've added
that in there and my script 16 is that
well either table I think was somewhere
else maybe it's in here stole but I've
added these scripts in here and so they
exist as part of my project they're
under source control so exactly and so
we're trying to do is treat this exactly
like our code so in this case I've
actually just got new code here that
I've added right so I can like anything
else I can add it so added channel them
and I can do what I want to do just like
I might do in Visual Studio is I've got
my board here and visuals media where
I'm tracking work so I can I can use
this pound syntax to actually add commit
and push my changes so part of what
we're trying to do is ready roll is
implement the database just like we did
any other code and actually track this
stuff and I think that's that sort of
answers the question that we asked at
the beginning what does it mean to be
database DevOps is it just as you make
changes to an application in code and
you want to be able to manage those
efficiently you make changes to the
database right I want to treat that the
same ways right so we want to add those
in there and so one of the things I've
also done here is that we're actually
running a build in the background so
I've actually got a Visual Studio agent
running on its machine it's actually
running a build right now so just like
we would do with our c-sharp code or
vb.net code when we submit it in we want
visual studio team services to actually
be running and if I look here I should
see my build just succeeded I think
and I've got all the information in here
that looks at like what I would expect
I've got test coverage running and you
can zoom ibly break the build because
you made database changes that are that
are violating some rule or didn't quite
work out or something right I mean one
of the things we want to do with DevOps
is we're trying to pull all of our code
together and determine very quickly if
we've made a mistake right because
that's a risk issue so here I can pull
this in I can run my build and if I look
at the definition this is just a visual
studio build task there's nothing
special about what this is right
I could I could have this building
c-sharp as well if I was doing it and
then I run tests in this case I'm using
the Microsoft test framework to actually
run tests like a what does the building
test actually do didn't like take those
scripts to a like a sample database and
run those and say yep that's exactly
what the old will actually rerun those
scripts against a temporary database and
determine if they're valid sequel all my
object reference I resolve all the
things like that the test is just a test
like you would run for anything else
right there's the written T sequel but
but I set up a test and I say you know
check this value run this query see if
the results match right and go from
there
and so once I do that I just output an
artifact and just like any other code
I've done that okay in this case I've
actually I'm committing out to a release
process as well so we're doing
continuous delivery so one of the things
that we want to do here and I want to
say my build it succeeded a minute ago
so I should see up here a release to
integration that just ran and so if I
were to actually go back over here and
let's change the integration database
and let's say I've got that feed that we
just added and I didn't change that in
this database or I didn't do anything
else and as a matter of fact let me go
further let's pop over here to QA and
let's look at QA now if that doesn't
exist yet but let's make it exist so
here I have the ability I have these
downstream releases as well and Scott
will let you Scott watch me so I'm not
going to use the keyboard as well all
right we'll put the keyboard away and
the creative release
and I'm going to say release this and so
without using the keyboard at all we're
going to see this database change deploy
to another database right look ma no
hands nothing out of my videos if in a
second this will be run yeah and as a
matter of fact let's come over here
we'll execute this
I think it's deploying right now and we
should see that data changed actually in
here and we would see the other change
as well if we wanted to go through that
right click we're in the process there
it is so here we are in the QA database
right you saw me I didn't touch the
keyboard a topaz at all and we've
deployed this in the same way that we do
all our code and again when I look at
this release definition this looks like
I would deploy a asp.net web app to
Azure or a mobile application anything
else in this case I've got multiple
environments that I'm deploying to I've
got these tasks that I put in here in
these case these are tasks from red
gates that allow you to do that and just
deploy all my code what's the what's the
set up time for if I wanted to set
everything you showed what's the setup
time that would take me to you know
properly set up a DevOps environment
properly so that would benefit yep so to
set up the entire environment
technically from the technical
standpoint we could do it in less than
an hour as a matter of fact I do talks
all the time where we'll take we'll go
from scratch and we'll import a database
into a project and we'll set up C I will
commit it to version control setup CD
and we'll do it the cultural changes are
hard to write because everybody has to
get used to understand so I'll discuss
from the technical standpoint I think
the the other aspect you know the now
getting me to use this process is the
not the hour it's right it's every month
because we don't realize I think
sometimes all the little steps that we
make as humans when we're trying to
deploy code okay and we see this when
I'm trying to deploy to Azure if we take
the sample apps and I deploy asp.net
j''r now I can use yeoman or something
and be done in ten minutes right but in
terms of getting all my code out there
and realizing well I really need to make
sure that I've setup firewalling and
that I'm actually deploying this extra
bit of code that's side to my project
and I've got to config that all those
little
changes are what take time but that's
part of DevOps because we're learning as
we go and so we start to make those
changes right right so where would
somebody go to learn more about database
DevOps so we do a lot of work at Red
Gate I run sequel server central we do
some work there where we're publishing
information and then I'm working on a
course for MS learning right now and
hopefully we'll be done in June on my
travel schedule but at open EDX
Microsoft com
Microsoft is publishing a huge series on
DevOps and AD and all sorts of languages
platforms different things and we hope
in June have a database DevOps course
out there that will give you more
information about how you can work with
state-based with migration based with
open source platforms or sequel server
with whatever you want okay so the the
tooling that ships in Visual Studio
Enterprise is it a trial is it a no it's
a harder version it's a real deal
yeah it's an untimed version what we
have there is a Visual Studio Enterprise
contains ready role core and sequel
prompt core and sequel source 3 red gate
products ok the sequel prompt and the
ready role cores have a few less
features than we have in our full
product and but you can upgrade out
there they're not trials they're full
versions that will allow you to do this
deployment and development you know as
much as you want so can't visual studio
enterprise and then what is sequel
search so sequel search is just a full
search product that lets you go
throughout your database and find
objects in a more intuitive and flexible
way than what ships in management studio
ok all right I'll be honest how many
people know that these products are in
because I had no idea sounds to connect
so if you were paying attention
thanks for calling that out Robert well
it's amazing visuals did you have 2017
that there's all these different
workloads and you don't realize
sometimes that you know if you don't get
that mobile workload you don't get
xamarin in there and if yeah the data
workload you don't get ready roll and
and there's various workloads so you
should definitely look at the visual
studio installer and look at all the
different workloads that route 58 vision
mm 15 and 17 just 17 just say okay
that's dozens that's why because I
haven't looked in 17 yet and 15 okay so
17 only said Isis has changed okay I
feel redeemed now yeah one last thing I
just wanted to talk to you about briefly
one of the things that developers always
want to do is we we want more data we
want to work on real data right because
it helps us do an application and often
if we just use the ten rows of data that
I feel like typing that day yeah I don't
get a good feel for whether my
application works with the data is in
production or its scale or anything else
so red gates been working on a product
that we just released called sequel
clone that allows me to make copies of
full-size databases and use very little
space so if I jump over to my screen
real quick one of the things we'll see
is I've got a production database here
and it's got three hundred Meg's so it's
not big but you know for my laptop
that's decent size but I built these
clones and these are real copies of that
300 Meg but each one is only using 48
megabytes of disk space and that 48
megabytes is fairly constant even if
this was a terabyte database yeah and
and I have the ability to quickly create
a clone so on this machine I can create
a clone and I'll say we'll call this
Scott because Scott's my friend and I'm
going to create that 300 megabyte mark
here in an eye out five six seven
seconds I've got a copy database and if
I look it over here in my management
studio we've got the Scott database how
big how big was it 40 Meg's so I've got
all my rows actually let's take that top
out of there I try not to break things
too often but so I've got thousand rows
in here yeah and if we look at this
Scott it is a full-blown database full
database so if I look at the properties
database this says it's 270 Meg and 60
Meg okay but on disk this has only taken
48 Meg of space Wow Wow
so I could we can do right now at the
two terabytes because we're using VHD
files but very soon we'll have up to the
64 terabytes VHDX files but we can make
copies of those databases with you know
roughly 50 70 Meg on your laptop and
allow you to get access to that full
size database and then what are you
impressing that how you getting there
know is that the secret sauce you can't
there's definitely a secret sauce it's a
little bit magic and unicorn dust on
there but really what we do is we take a
point in time snapshot of our database
and then we have a central copy of that
and we're all reading from ok and so
it's a similar data virtualization
technology company - ok but Redgate has
brought it to the sequel server platform
at a very low cost and it allows you to
give every developer copies of the real
database and if I don't like this
database I can delete it in seconds and
I can create a new one now if I've
updated the data and I want to do
something else I can do a new one in
about where we say 7 seconds and we'll
call this one Robert and I'll build
another database on seconds and then I
can just go ahead and work with that and
be ready to go that is very cool cool
well thanks so much for coming on thank
you very much for having me so we've
seen a good overview of what I need a
base DevOps is I've learned a lot this
tool that you can that shipping
Enterprise go to go back into the
Installer and go into the individual
components tab and find them there there
they are playing around with it and
learn yeah that's your homework
assignment everybody yeah give it a try
yep thanks hope you enjoyed that and we
will see you next time on visual studio
toolbox

Database DevOps with Redgate ReadyRoll

hi welcome Visual Studio toolbox I'm
your host Robert Greene and joining me
today is Steve Jones from red gate hi
Steve is here to talk about database
DevOps that's right and we we chatted it
build I we did a show it build and we
covered some of this stuff then but
we're gonna do it in a bit of a more
deep dive and get a little bit more into
the meat behind it okay ah right yeah
absolutely
so we're gonna talk about two things
we're gonna talk about two different
ways of doing the database DevOps first
that we're going to cover today is
migrations and then the second one is
database compare right data compare have
you ever done migrations when you've
developed yes yep do you like migrations
do I like migrations it's a to doing
stuff gets done so I like I like stuff
that works but I don't have a passion
one way or another for it let's go that
way yeah I find a lot of people don't
either do it don't like migrations I
I've done a lot of migrations more in
the Oracle and db2 world where you know
large ERP systems often just track all
the scripts there hundreds of developers
right and then we run them all in order
and it always works but it can be really
slow sometimes okay so some people don't
like migrations but I prefer it you know
and I work for regular software we we
support both ways of doing database
development well so whatever works for
you that's fine and maybe you'll pick
one or the other after this but at least
I'll learn how they both work right the
exact wording it said at the end of
these two parts all right all right
migrations first so migrations first
let's back up a step okay we dive in
what are we doing so I'm a database
person I've been a sequel server a
person for most of my career I've
actually been working sequel server for
26 years now so more than half my life
has been spent working with databases
right so it's kind of amazing that
throughout that time I've developed
software in a number of different ways
as a DBA and developer and so I've tried
to work through these different ways of
efficiently getting database changes to
action making sure that I'm not
interrupting an application I'm not
causing downtime unnecessarily
certainly I'm not causing any data
integrity issues or losing anything
along the way right so you know you make
code changes all the time but you're
saying that how often do people make
database changes not as much as code
changes obviously not as much as code
changes right the database because we
have to maintain that state of our data
mmm like unlike an application right I
can drop a class I can add a method I
can make these changes and I kind of
just replace different versions of right
maxi's dll's assemblies resources
whatever it is I can do that with some
of my code in the database world my
views my procedures things like that but
my tables I have to keep around so I'm
always kind of evolving them okay and
because I have to do that especially as
my database grows larger I want to be
careful how often I make those changes
okay renaming a table is disruptive
because unlike renaming something in
Visual Studio the compiler can find all
the references or the IDE can find all
the references and do that for database
I am xions coming from various
places and I don't know what's happening
right so I think it depends on a lot of
times the maturity of your application
if you're starting out you may make more
database changes than later yeah right
okay as I grow I get a lot of technical
debt kind of in my database world
because of all those connections to
other applications reports ETL systems
all right so I'm hesitant to make this
changes okay now there are people that
do a lot of additive changes where they
just add things to the tables they add
systems to the objects to the database
so that they don't hopefully don't
disrupt those applications all right and
they can continue to add features and
functionality throughout the lifetime of
their application ok so one of the
things that you know I've been doing
really for most of my life is a lot of
things we call DevOps when I trying to
have lightweight processes that work
that helped me make changes in an
efficient manner without causing
problems and at last 3 or 4 years all of
a sudden we have a name we call it
Devil's we DevOps all the things now I
think that's Donovan Brown might say
yeah so so maybe I show you some things
here I work for red gate software and we
have ready role as included in Visual
Studio Enterprise yeah so that's part of
what's there and I have a little ready
role toolbar here that comes up and
that's a pain in Visual Studio and my
project in ready role is just like any
other project so if I were to create a
new project here and since we don't want
to run through everything ready role
appears just like my database project
would for SSD T or for a c-sharp or any
other type of application we have in
Visual Studio in this case the ready
role project builds off of a database
project which is slow to come up but you
can see that there's database projects
like we would do and for SSD teeth for
Daniel's or I've got ready role projects
here and the difference is the database
project works as tracking all the
changes and then it does a comparison
with sequel package and you'll deploy
those changes mm-hmm I kind of package
everything I'm a backpack and ready roll
we have what we call migrations
so in this existing projects I've made a
bunch of changes over time you can see
I've got all these scripts and each one
of these is just a change that I made to
my database as I was performing
development so in this case I'm altering
the table obviously I can't you wrote
the scripts and then saved them in the
project right yep I actually have a
couple ways of doing it I can import
those changes if I've made this in
management studio or another developer
made changes so I can
ensure that I'm capturing all the
changes or I could write the script
directly okay so ready roll what it does
is it takes the burden off of you of
trying to manually grab every script
make sure you've caught all the changes
giving it a name saving it off right
okay so I can do that so over time I
just collect these different changes
that could be DDL changes they could be
DML changes there's just a series of
things that I'm doing to my database I'm
creating objects I'm altering objects
whatever is appropriate for my
application so in this case this is a
common pattern that in the SSD T world
or in a state-based comparison world is
difficult to handle I've got to add a
notnot column I'm gonna I've got data in
my table right so I can't add it not no
column right I have to add a no column
update some data and then add a not null
right
so that's a complex change they still
haven't changed that that way forever
right yeah I mean there are ways around
there I could add a default I could do
some things but for a lot of systems
I've worked with a lot of developers
this is a problematic item because I
don't want to default value what I need
to do is populate that appropriately
with some value that matters for that
room okay so ready roll makes these
types of changes much more robust and
resilient so where's the migration ID
come from there so let me show you how
this is done will create a migration
script now so if I want to create a new
script I could certainly just right
click and add like anything else mm-hmm
I could certainly add a stored procedure
or a table or anything that I want to do
so when I do my development is the
migration ID that gets created when you
create the script that gets created a
great degree okay so it gives me a
unique way of identifying this script
and tracking whether it's been deployed
in the environment okay no so we do that
so let me create a little procedure here
that I want to do and I'll just give me
something that I can run okay and I can
certainly run this if I want I have a
variety of options like I would in any
other database development that I'm
doing that I can just mark my code run
it test it to everything that need to do
here yep this has been executed on a
local instance it actually exists there
so I can run any my application against
it I have all the ability to do the work
that I do normally as a database
developer mm-hm and then you know
periodically what I want to do is I want
to make sure that I've deployed
everything in my project so I can click
here and it'll do a build in Visual
Studio like anything else so I know that
popped quickly up there but I actually
have conflict and something failed
already an object name get 10 yeah yeah
okay cool so it thinks it's still there
I don't think that's the case let's just
check I'm more comfortable you gonna
believe Who am I gonna believe it does
exist
I think cuz I ran it and then I said it
was deployed let's deploy it again into
a build because I'm a developer I'm
human I make mistakes right things
happen as I'm going let's see it
deployed it succeeded everything
at all so I can kind of see what's going
on in my project as I'm performing
development because I have the code in
scripts I could certainly check the
database against this
I've got everything like I would
normally have this migration ID is is
how the framework will actually check if
this script has been run okay so inside
of my database we actually track that so
if I pop over here and let's just check
it from here there's migration log and
we can see here that this contains all
of the migrations that have been run so
there's this good that we have there's a
checksum make sure that the script I
think Iran is the correct script right I
haven't edited or changed it and I have
the file name and then various other
metadata that lets me know what's going
on so this ensures that my scripts in
essence will only run once so I can't do
something like add data in a script and
then worry about it being added again
right duplicate data recreating tables
that kind of thing so so far as I go
through database development it's
similar to what I might do in c-sharp or
any other language right right that I'm
just kind of working with my project and
make your changes and like any other
change this kind of appears as part of
my team Explorer right I've hooked up to
version control which is one of those
things that I find so many database
developers don't do right they don't
track their DDF right you've deployed
this to the database already my
development database all right so I'm
working with an in development database
and I've got this change out there
mm-hmm
okay and I and I can certainly make
other changes and let me show you
something else cuz do you find there's a
lot of developers that like to work in
managed studio still because it's a
comfortable way of working and it's
quick so let me add a piece of data here
to this table and if I look at what's in
here I've got some data in there so I
just add in row number five so one of
the things ready roll also allows to do
is track reference data or static data
that I might want to include as I deploy
this further mm-hmm so here's here's a
value that I want to include well once
I've done that and ready roll what I
want appear like to do is check if I as
anybody made any changes
Visual Studio certainly I could have
just done run a query on Visual Studio
as well that did that same insert we can
see here that I've actually detected
there's a data change here and in fact
this one row that was inserted so I can
add this as another script and this will
come in as another migration script
this is script 32 it's got a different
migration ID which you'll have to trust
me that's the case we won't compare the
height but Randy Rahal has built me an
insert statement it could build me an
update statement it could build me a
delete statement whatever would be
appropriate here and again that's here
inside of the change team explorers
whoo-hoo so all of this is my local
development as the database developer my
laptop my workstation I'm doing my thing
right so are you committing this to
version control as a way of keeping
track of the history because these you
changed the database right it's a little
bit different than writing code it's a
little bit isn't it it's a little
different right because certainly
anything I do to a table or to data has
to is kind of this evolutionary change
of thing that I'm moving from one state
to the next constantly I'm tracking it
in version control a because I make
mistakes sometimes I have to go
backwards okay just the way the world
sometimes I will misinterpret
requirement the business person will
tell me the wrong requirement and we
will write code and realize it doesn't
work we can roll back the database
changes well we can certainly find out
what we changed I can go back I can
certainly go to version control and grab
those changes
rolling back database changes is not
always easy yeah cause it's not like the
data's in source control the history the
data it's not go back to a snapshot
right now for stored procedures and
functions of use I can just grab that
previous cousin right cuz those are just
code those are just yes okay for tables
I haven't come across a tool yet Norway
I think would I trust my job to a tool
to roll back my date right change
exactly right because if that if there's
been data added to the table I need to
decide what to do with that day
right if I've dropped a column which is
a very dangerous thing I need to have
prepared for that advance because
nothing is rolling bringing me that
table change back right right okay so
those are different but as much as
possible I'm trying to treat all my
database code like application code mhm
okay and part of this is that I want to
use this code to move forward to do CI
and do CDJ like I would do with an
application okay so let me commit this
you'll see this out there actually
before I commit this let's just go look
I've got a project out here in visual
studio team services which i think is
fantastic by the way
mm-hm I think you're right it is this is
maybe the best developer tool I've seen
Microsoft ever build
now the visual studio team service is
just amazing really is and I use it all
the time so I've got you know a board
like I would have for anything else and
I can track all my database work yeah
and I've got my codes here as well and
I've got my project so I've got my main
database project my test project because
I want to test things you know in
various items and if I flipped down in
here and look at my migrations and my
last change was this morning right a
little while ago we were checking things
out let's go ahead and commit this
change so we'll say channel 9 Robert
I'll call it one let's commit and push
that so once I do that this will
actually push up into the Microsoft the
first time I looked closely at that
drop-down and saw that commit and push
you could do all the ones instead of
committing and then going and finding
push this that might be like the one
thing I wish existed instead of a
drop-down it would just give me the
option to remember that would that be
even better right yeah but if I let's
refresh this so that I see what's out
there
I should see we just pushed out two
changes okay so it tracked to new
scripts yep and now I have a history of
what's going on because in a migrations
world I'm tracking all these scripts
over time so that's an interesting best
practice you've got two changes in one
comment so given that you're all the
rest of your comments are pretty
descript
give would you then typically just
commit one script at a time it depends
on the work that I'm doing at that you
know III that's kind of a devil of a
developer philosophical question right
do I include multiple changes into one
commit mm-hmm I would have that option
just like I do with anything in Visual
Studio I could pair and choose what
commits in this case if I was if that
data change was associated with the
stored procedure change I would probably
commit them together with the work item
in a better description of Christ right
not a great comment but if they were
separate items as is the case sometimes
in database world mm-hmm I would make
two separate commits okay and and that's
one that's one of those things that
comes along with you being a developer
learning how to commit in batches or
singly as appropriate yeah that takes
your experience there okay so we can
make our changes here and commit them
but we want to go farther right because
this is a great safety net in version
control but it's not helping me build
software faster mm-hmm it's not help me
build software better right so I want to
make sure that I'm actually building
things as well and the build system
visual studio team services fantastic as
well I mean I've watched people build
all kinds of stuff here mmm that from
from Java to Python to c-sharp to
database everything right it's just
amazing and we can see here we've
actually just built a new building so
when you created that build was there a
built-in template that you got to select
or did you have to build it from scratch
I actually built it from scratch now
those of you haven't used Visual Studio
Team Services give it a try
but it's a very simple project yeah just
like you would do for c-sharp I'm doing
a visual studio build and this is just
the standard Visual Studio build tasks
so okay so you named that my name right
so I can I can change the name right and
right here in the display okay this is
the standard Visual Studio build task
okay so if there were if I was doing
c-sharp in the same solution right let's
not restart now that's not to go
so if I were doing a c-sharp project in
the same solution I could build it here
I could have two Visual Studio builds
this intended each project separately
whatever is appropriate for my system
but you know I'm doing the same solution
build you know I've specified the name
I've got the MS build arguments just
like I would normally have okay
ready roll wants to build against
another database a target database where
I'm going to deploy to so I give it a
parameter station where am I going to
deploy so here's a question so when you
wrote the script you deployed it so you
already changed the database correct now
you've got a continuous integration
build what is that doing so what it's
doing is is going through and
re-evaluating the entire script to make
sure that everything's correct it's
looking against a downstream environment
that I would want to send it to you to
evaluate which of these changes maybe
you just changed the like a development
database yes confirm that it all works
and now you're using the CI process to
update the production database or
further downstream database I'm doing a
downstream data so I never I always like
to work in multiple environments in
these days with containers of
virtualization and VMs I always try to
have at least three environments if not
more so in this case I've actually got
five so one of the things I want to do
is I'll make my changes but you want to
be able to see my changes right or we
want to see all of our code together
just like we would in a c-sharp project
and web app so in this build what I'm
actually doing is I'm building and I'm
running my tests mm-hmm so I'm seeing
I've got the Microsoft unit testing
project as part of this so I'm running
tests in there against my database so
i'm doing sequel server unit test and
I'm doing my artifacts and if I pop back
to the summary of what's going on and
we'll look at that there were actually
results of that build that just ran and
we'll find it you know it took a few
seconds my test ran successfully I could
see you know the commits that are going
against it any warnings anything that
I've got going on in this case because
it looked at that next environment over
here on the right I see which
migrations weren't applied to my next
database yeah okay so that gives me an
integration place and in a matter of
fact you can see that there it knows
which stored procedure was changed there
right so it's kind of read through some
of the metadata I could see what's going
on and as a further step out of this
build I'm actually trigger to release as
well and where do you specify what
database it's going to is that part of
the build definition that is part of the
build definition so when I pop over here
that is a parameter visual studio like I
would add any other parameter and you'll
see here that I've said this build
integration database that's where I'm
gonna talk I next got it so that's
giving me kind of intermediate
environment nicely and if I pop over to
my visual studio let's sorry my
management studio let's grab this query
right here let's copy this and this is
my integration database okay okay so we
didn't touch this database you know I've
got a different coloring on it but my
row number five has been added
and my stored procedure here should run
cool right so cool right now as I've
done the process that I would normally
do a c-sharp and that I take my code
like everybody else's code put it
together generate an artifact and we can
then see if that is what we actually
want so you your continuous integration
there is actually a deployment as well
it is to another environment because in
the database world I I kind of need a
place to go look at that right so I've
actually moved this from one environment
to the neck so let me zoom in slightly
here I started right here in this
development area so this is where I made
the change and this is environment two
right here we just sent that change
okay and what I want to do then is of
course I've got QA yeah I've got this
staging and I've got production as well
okay so I want to kind of make sure my
code flows obviously testing at each
point in time run an application against
it having other developers QA people etc
look at what's going on right leading
businesspeople
I want to make sure that my code is
being deployed so let me grab let's
grab all this code real quick and let me
just look at my Qi environment all right
so if I run this now that stored
procedure doesn't exist
yep right neither does that Rover
because your bill definition only sent
it to the first database yeah my build
definition then actually kicked off this
release process as part of continuous
delivery so this release process says
once I built if I built successfully
mm-hmm and if I passed my tests whatever
is appropriate for myself what I'm going
to do is I'm going to do supply this
package out to a database and in this
case I'm sending it to my integration
environment oh so the build doesn't
actually do the deploying no no in this
case oh okay let me pop to the older
this new editors gotten slightly odd for
me but when I look at this build process
I'm sorry this release process this is
set as the option where they moved go
back to the first here click on one
phase one task that's where it is yeah
yeah so here I'm actually having this
kick off as per once the build a
successful okay it triggers this release
okay yeah so just like I want to do is I
want to have kind of an organized
process that makes sense
mm-hmm outside of the path in and the
parameters we could set this up in a
couple of minutes okay we would have to
go through the path you make sure we
haven't made anything incorrect there
but I have the ability to do that but
I've also got other release processes in
place in this case I've got a downstream
process as well which will push it to
those other environments okay so I have
the ability to make releases in a
consistent reliable fashion in a way
that as a DBA various times my career
have struggled with because as somebody
sends me a script I have to look at it
have to hope all the objects are
included mm-hmm
I have to hope that I've actually
remembered to correct connect to the
correct server right send it down there
right all the minutiae that just slows
down development right it just becomes
complexity just like deploying an
asp.net website or c-sharp too thick
client you know there I have to make
sure I go through all the process
correctly I have to remember that I need
to copy to these folders to these
servers mm-hmm right those things are
just they're kind of tedious things that
we don't want in general to do so having
this stuff happen automatically in a
lightweight process like visual studio
team services makes it really easy to
move this changes forward yep and see
what works and so this release is
created it's probably run by now because
usually they run fairly quickly and if I
come back over here and let's rerun this
code actually works this nice I've moved
it to QA yeah we could certainly repeat
that a forward to the other environments
as well right so cool trying to build
some of that DevOps process in here's
that I I make the process a definition
that is always handled in the same way
so we execute the same manner and then
if I find issues or if they find new
requirements I can slowly modify that
but I'm not dependent on a human to do
right and it gives you the ability to
not necessarily be the only one making
changes to the database just like in
coding you're not the only one coding
right right but things about the
continuous integration is I make changes
on my machine I run my tests everything
works you make changes on your machine
run your tests everything works marry
the code together the stuff doesn't work
anymore exactly right the CI will do
that I check in my code you check in
your code all the unit tests run we're
told immediately you can apply the same
process here I make changes the database
works on my machine you make changes
works on your machine and then you marry
them together and it all then goes
downstream and hopefully works right but
if hold of course and if it doesn't then
in process breaks but we now you know
why right so I've got a cool visual
studio team services gives me all
instrumentation to say what was deploy
what's included
so I don't have to dig through the
entire database I know in this case
there's two files that broke so if my
code doesn't work with your code yeah we
know which files I committed to go look
at and this isn't that hard to learn how
to do it's pretty easy to set up it is
pretty easy to set up yeah even even if
the UI changes it is I mean visual
studio team service I was amazed how
easy it is to actually do a build after
working in something like Jenkins which
works great but it's not the easiest
thing we work with yeah so visual stereo
team services and all the extensions
have made this a smooth process very
cool all right all right we learned
something you like migrations and
database development now I love it yeah
right well I love the fact that that you
can that DevOps and see ICD continuous
integration continuous deployment
pipelines are for databases too it's not
just for code right and you can just as
easily set one up for your database
stuff as you can for your code I love
that yeah yeah and I think that's one of
those things that will really help
improve the quality of our database
applications yeah oh absolutely cool so
that's part 1 part 1 part 2 part 2 we'll
do this again but we'll do it
innocent in a comparison method where
we're not going to try to track every
change right figure it out later
okay cool we'll see you next time on
visual studio toolbox
[Music]