>> Azure provides a CLI
to interact with most of Azure's artifacts.
Anna is here today to show us how
to work with the CLI to interact with Azure SQL,
today on Data Exposed.
[MUSIC]
>> Hi, and welcome to another episode of Data Exposed.
I'm your host Jeroen, and today I'm joined by Anna to
talk about Azure CLI for Azure SQL. So welcome back.
>> Thanks. Thanks for having me.
>> We're going to talk about the CLI, right?
>> Yeah. We're going to talk about
the Azure CLI and how it relates to Azure SQL.
I thought maybe we'd start with
something different, like the Cloud Shell.
Have you seen the Cloud Shell?
>> I have not seen the Cloud Shell. So what is it?
>> So let's take a look. So here I'm in
the Azure portal and you'll see this terminal down here.
I got to that by clicking this button that says "Cloud Shell".
Now once I do that,
I'm actually going to maximize this.
I can maximize this,
I can do things like switch between Bash or PowerShell.
The nice thing is the Azure CLI
as well as the Azure PowerShell module,
they're already installed here, so I don't have to
worry about keeping that up-to-date.
>> I can just pick either of the two?
>> Yeah, you can just pick
whatever you feel more comfortable with.
>> Cool.
>> You know, sometimes our Linux and Mac
users prefer to use something like Bash,
whereas other people prefer to use PowerShell.
We're going to support you however
you want to interact with the Azure CLI.
>> So by just saying that, you also
mean that the CLI is in cross platform,
so I can run it on Windows, Linux, Mac?
>> Yeah. For sure.
>> Cool, okay.
>> So like once we're in here,
you might be wondering how does this relate to SQL though?
>> Yeah. I mean, we're here
talking about Azure SQL. So what can I do?
>> So once I get set up,
the first thing I might want to do is set the subscription.
I don't know about you guys, but I have quite a few subscriptions.
>> Yeah, don't we all.
>> First I can go ahead and just use
a simple command like az accounts set.
Now once I set my subscription,
I can do things set my default resource group and server.
So here I'm setting
my default resource group and then
setting my default logical server.
So this is a logical server for Azure SQL database,
not your standard SQL Server 2019 or something.
So I can do that.
When those are configured,
I can then start to look at things.
Just like at a very high level,
I might want to look at that logical server
and see some information about it.
So I can do that. I can figure out what subscription it in,
what region, how the status of it is doing.
>> You're basically just using the AZ commands.
So AZ and then for example,
SQL Server, and then show me the details from them.
>> Yeah.
>> Okay.
>> So what you'll see is they're pretty straightforward.
So this next one that I'm going to run is az sql db show,
and then the name of the database.
So what that's going to bring back is
information about that database.
So sku and the tier,
as well as if it's online
and some other information that I can get.
So I'm just walking through the show capabilities here,
but there are a lot of other capabilities.
So for example, I could show for an MI,
I could show all the databases or information about an MI or
all the information about
a specific managed database in a managed instance.
>> Right.
>> So there's a lot of things that I can do here just
from a show perspective.
>> Right, and then of course you can fully
change settings on the database using this commands as well?
>> Yeah. So you can actually use these commands and this would
be quite a day for us to go through all these commands.
>> Let's not do that here.
>> But you can actually go through
and see for your data warehouses, your Database,
Elastic Pool, Servers, Failover-groups,
even things like firewall rules can be managed from here.
So there's a lot of things that you can do with
this Azure CLI capability.
>> It's not even limited only to SQL, right?
>> No, not limited to SQL.
I mean, preferably we'd like you to interact the SQL
with it but there are lots of other things
in Azure that you can do with Azure CLI.
>> Yeah. I mean, some scenarios of SQL you
might also need to interact with storage first.
>> Exactly.
>> So that we can get like access to
their backup you made or whatever, right?
>> Totally.
>> It's good to know that you can do both of
them using the same type of commands, right?
>> Yeah.
>> So now I know I can run this in Linux,
Windows, Mac, I can run it in the portal, is there anywhere else?
>> There is. I'm glad you asked.
So if I flip over to Azure Data Studio,
you might be familiar with notebooks.
I can actually interact with
the Azure CLI using a PowerShell Notebook.
So here, I just have
the same commands that I can run from the Azure Cloud Shell.
I can run from a terminal,
or I can run from right here in a notebook and save those results.
>> I'm looking forward to learn more
about this PowerShell Notebook,
but let's just save that for another day maybe.
>> We should, yes.
>> Okay, cool. So this is good.
Thanks for sharing and thank you for watching.
Please like and subscribe,
leave a comment and I hope to see you next time.
[MUSIC]