>> Infrastructure as Code is something
you've probably heard a lot about.
But how does it relate to Azure SQL database?
Check it out in this episode of Data Exposed.
[MUSIC]
>> Hi, I'm Anna Hoffman,
and welcome to this episode of Data Exposed MBP Edition.
Today, I'm joined by Hamish Watson.
Thanks for being here today.
>> Thank you, Anna. It's really good to be part of this.
>> Awesome. Before we kick it off,
I wanted to take a moment to let you
tell us a little bit more about yourself and what you do.
>> Yeah, sure thing. I'm Hamish Watson.
I live in New Zealand,
and I'm a Data Platform MVP.
Basically, for me, one of
the cool things about being a Data Platform MVP
is it has the wide platform in there.
For me, in both my career,
I run my own company that is dedicated to data, Azure, and DevOps.
All those things need a platform to run.
I've been in IT for a long time,
but over the course of that time,
both my career has changed,
but also the way that I use databases has changed.
I've gone from being an Administrator to more of an Engineer,
and of course, using DevOps somewhere I need
to make stuff go and make life better.
>> Awesome, great.
Today, we're going to be talking about
Infrastructure as Code and Azure.
I really like your title,
a match made in the Cloud.
Can you tell us a little bit about what
that means and what you want to show us today?
>> Yeah. Sure. It goes
to what I was talking about before, about the platform.
For me, years ago,
I realized that clicking next,
next, next wasn't the greatest thing,
because I don't really concentrate that well,
and also, it's not scalable.
I can't click next, next a thousand times.
Over the course of my career,
I realized that there were better ways of provisioning things.
I used to talk to Developers around the state, coded,
and then they taught me a whole heap of stuff,
and I deployed stuff for them,
and I realized that there were better wise of doing it,
and so I go on board with Infrastructure as Code early on.
I use PowerShell to do a whole heap of stuff that
normally I would either do myself or other people would do.
The other side of this is a program standardization.
Having a script that not only I know
will provision the same thing every time,
but more importantly, I can collaborate,
I can sure use it,
share the script with you,
or doing appropriately, I'll have it
in source control, and you can grab it.
Then as time went on,
automation became way, way easier.
I can still share it with you,
we get the machines to run it,
and again, we've got something that's consistent, is standardized.
We can taste it and we can parameterize it.
Today, I want Azure SQL Database of this size,
well, feed in a new perimeter,
and that's now this size or this.
You can change all the things, but again,
having it in source control and envisioned is brilliant.
For me, we're the next level when I
started provisioning resources in Azure.
Of course, the first time I'd provision something,
I used the UI because you've got to
understand some of the things here.
But basically, my philosophy is try it once in the UI
and then look at how you
can automate it and provision it with a colleague.
>> Awesome, great. Well, I'm inspired. Let's take a look.
>> All right. Well, I've got
a couple of things I'm going to dim light for us today,
which hopefully will help people.
Yeah, let's jump into it.
Here we are in the Azure portal.
I'm going to show you one of the things that
really changed how I do stuff.
I, early on, started using the Azure Cloud Shell.
One of the things I love about the Azure Cloud Shell is
basically my toolkit anywhere in the world.
I can swap computers, I can be anywhere.
I can even use my phone,
which I had done.
But I can use Azure Cloud Shell
to basically write code, and it's really awesome.
If you use Visual Studio Code,
you'll be used to writing different code in there.
The Azure Cloud Shell has a cut down version of it.
What we're going to do today is I'm going to use
Terraform to spin up some of my resources.
I'm just going to initialize Terraform.
What this is going to do is we are going
to create some resources and visual it today.
So I've initialized it.
I'm just going to run a plan,
which will probably tell me that I
haven't written the base code in the Word,
but that's okay for today.
What we're going to do is while this spins up,
we're going to create a SQL server up in Azure and we're
going to do some follow rows and I would probably
want to come back and reconfigure this, but that's okay.
We're going to create a database,
and this is all going to be in a resource group.
We've done our plan, we didn't get any errors, which is awesome.
Now, I'm going to apply it and I'm going to do what I approve.
This is quite important because if I did not do what I approve,
it's going to ask me a question.
I didn't want to deploy this.
Normally, you have to type in use,
but I'm just going to leave it to automatically do it,
so I'll do the auto-approve.
This will take a way while to deploy.
While that's deploying, how about we look at
some other ways that we can deploy up into Azure.
Here we have another way.
I'm going to use ARM Templates,
which is Azure Resource Manager templates.
If you've deployed anything in Azure,
you would have used the Azure Resource Manager.
You have clicked "Create Database",
"Create", "Save It", Create",
whatever logic gives, you name it.
That's the beauty of the platform.
I had an ARM Template that I have created and I'm
going to deploy this using Azure Power Shell on my machine.
What we'll do, again,
this will take a way while,
so we'll link those bubble away,
and we'll now come back and have a look.
Oh, this is brilliant.
We have the database created via Azure CLI.
Why don't we quickly just good back into
the portal and have a look and say, "What we have deployed."
Let's close down Azure Cloud Shell.
We have a new resource group here,
this is pretty cool.
You'll notice we have a couple of databases.
We have our SQL server,
the hosts, our different databases.
You'll see here, my Terraform script created a Terraform database,
and my Azure CLI Script created a database.
Again, there's a couple of
different ways that we can create things.
Very same, we're going to have another database in here,
but the ARM Template has deployed.
Why is this important?
Well, the main thing about being able to script
all these resources is we can now fold that into a CI/CD pipeline.
It means that when we are deploying our code,
our apps, whatever, instead of having someone do it,
we'll just spin up things as we want,
and the best part is we'll
destroy or delete them when we finish with them.
Spin them up, doing what we need to,
and then just remove them,
because this is the magic of using infrastructure as code.
It's declarative, all my things should be inferior.
I don't really care about the state of them,
I'm just going to spin them up when I want,
when I'm done, they're gone.
This changes the way we look at resources.
There's that saying, treat them as cattle rather than pigs.
I still care about my database,
but it may be a lot shorter lived.
I may only have it up for
a couple of minutes and then get rid of it,
and I will deploy my database from source control.
All the things that I need to
configure and manage it are coming from source control.
What I'm hoping today is that my very simple scripts,
I appreciate that they are a one line,
I should have some exception handling,
but I'm hoping that it gives you a way to
go out and then try things out in Azure,
because the best part is try them,
spin it up, and then delete it.
That way you're saving any cost that you might incur.
Why don't we quickly click "Refresh",
and there it is, that is fantastic.
We now have three databases that we've used,
three different ways of creating them, and you know what?
I could still use the portal.
I can still add a database in there if I made it too.
>> Awesome. Thanks, Hamish.
This has been really interesting.
You showed me some things I haven't even seen before,
you showed us how to deploy Azure SQL database with Terraform,
with Visual Studio Code,
using the Azure CLI,
and also using ARM Templates.
I think it's great advice that you're telling our viewers,
it's just, "Go out,
try this, get started,
and then it's really going to open up a world of opportunities."
I really just want to thank you
for being on the show today, Hamish,
and we're actually going to do a follow-up video to this where
we'll dive a little bit deeper into a slightly different scenario.
If you liked this video,
please like this video,
subscribe to our channel,
and let us know what you're doing with Infrastructure as Code.
See you next time on Data Exposed.
[MUSIC]