>> Learn about new Azure SQL binding capabilities
for Azure functions this week on Data Exposed.
[MUSIC]
Hi, I'm Anna Hoffman,
and welcome to this episode of Data Exposed.
Today I'm joined by Drew,
Program Manager on the Azure Data team.
Drew thanks so much for joining us today.
>> Hey Anna, thanks for having me.
I'm super excited to be here.
Start off this new year
talking about Azure Functions, and Azure SQL.
>> Always a pleasure to have you on.
You talked about a lot of interesting topics on our show.
But today like you said, we're going to be talking about
Azure Functions, and bindings for Azure SQL.
I just have to start us off at the beginning and ask,
what are Azure functions?
What are Azure SQL bindings?
How do they work together?
>> Azure Functions is
a serverless platform that allows developers to bring
code to Azure, and
run that so they don't have to worry
about managing the infrastructure.
We know, and love Azure SQL as this world-class database
that has all these scalability options
as well as a serverless tier.
When you put that together with something like Azure Functions,
you have a lot of really exciting possibilities.
However, when you're developing and working with databases,
a lot of times you'll have to find a driver, or
a library to work with to connect your code to a database.
That's where the power of
these Azure SQL bindings for Azure functions come in.
It's simplifies out a lot of that code to
allow you to focus on the inners of your Azure function.
>> Cool, at first understanding it makes sense.
I'm always down to hear things getting more
simple, and easier for me to get to work.
How do these Azure SQL bindings actually work?
>> The Azure SQL bindings takes
a connection string, and a little bit of
information around the query
that you want to run against your database,
whether it's selecting data into the function,
or taking data out of
the function, and putting it into the database.
Those two pieces of information
that configuration is all you need to
work with that binding, and then
connect to your Azure SQL database to a function.
>> Awesome cool things. Yeah, go ahead.
>> I do have a demo that we can
walk through, and then we take a look at
those two different input, and output bindings.
The example that I brought in today to bring
some of this to light is a quick web API.
You can use functions for different scenarios.
But, one of the most foundational ones is working with web APIs.
I just want to write an API that
gets items rose out of a database.
When I put together that input binding,
this snippet of code,
that's your database configuration for the function.
This is it. You're worrying about the query.
You're telling it, hey,
I just want to give it a text command.
Then this is where my connection string setting is.
This is the custom code, and within
VS Code there are tools to help put this together.
We can pop over into VS code,
where I have an Azure function project, and
a function that uses this input binding.
We have a function that runs when it gets a web request,
and the input binding that takes
data from the database, and inputs it to the function.
That's why it's called the input binding,
is it inputs into the function.
It runs this query against
an item table and then it's going to return those items back.
When I run a get request, I get it back.
>> Nice.
>> We can do more things with this.
We can find out how many items were there.
We can work with it within the function.
If you have more business logic, have at it.
But if you want to run a query against a database, you can do so.
The table is empty at the moment,
so it's not going to be super-exciting when
I run this GET request.
It's empty, that's okay.
I mentioned input, and output bindings.
The output bindings allow us to add new items.
We're going to output data from the function into the database.
Fortunately, those bindings are just as easy to
use as the input bindings.
You tell it the table where it needs to go,
and the connection string that it's going to use.
In that case, I have another HttpTrigger.
This is another API that we send a post request to,
that's what causes the function to run.
Then I actually have two output bindings on this.
The first one is going to that item table.
Then the second one, because you can do
more than one binding on a function,
is going to be logging some information about the request,
just saying, "Hey, I've made a request."
Now, you can take in data from
either the body of the request, or the query string.
You can connect this to other options.
But, at the end of the day what we want to see is,
let's get some data into that item table.
Let's try out this function.
I'm just going to add something about pears being an oblong fruit.
When I send that request,
it says 200 okay.
Let's see our database.
Do we have pears?
Yes, we have pairs,
so we added data to the database.
>> Nice. It seems like just a good example of both sides.
Like you showed how we can go use
the input findings as well as the output findings.
>> It's super exciting because now when I run
that GET request, we see pears.
>> There you go, full circle.
Awesome, cool. Hey, couple questions.
I noticed that you showed it to us in C Sharp.
Are there plans, or does this exist for other languages?
>> Functions are available broadly for Python, JavaScript, Java,
PowerShell, there's a bunch of
languages supported by Azure functions,
and these bindings are being ported
over to other languages as well.
With the addition of C Sharp right now out of the gate,
like we saw today, we're working on Python, and
JavaScript up next and just go down the path.
We're committed to bringing this across all
of the languages that are first-class citizens on functions.
>> Got you that's awesome.
You mentioned that these Azure SQL bindings.
What does that include as far as Azure SQL go?
Does it also include SQL Server?
>> The name Azure SQL,
is used broadly in this sense,
when you configure the binding,
you're giving it a connection string.
That is I'm going to say the limitation.
Your Azure SQL Database managed instance,
SQL Server on an Azure VM, SQL Server,
anywhere with connectivity to your Azure function can use this.
I'm going to pop into
my app settings where this connection string is stored.
In this case, it's connecting
to developer instance on my local machine.
As long as you can get this connection string
with connectivity to an Azure function, you're good to go.
>> That's pretty cool, that's awesome.
I see a lot of use cases for this.
I myself who worked with functions and Azure SQL,
I'm going to see the benefits of how
this really simplifies that process.
For DBAs or data professionals
who maybe haven't worked with Azure functions as much,
are there particular scenarios you see folks using Azure SQL,
especially these new bindings and Azure functions together?
>> Yeah, so as a developer,
I get super excited about Azure functions
because you can connect them just so many things.
But that excitement is not limited just to developers.
Data analysts and DBAs both have a lot
of potential capabilities with these functions
because when you run
an input binding and then
we've got System.Data.CommandType.Text here.
This can also be a stored procedure.
Let's say you have a start procedure that cleans up
some data and you want to run a function on a schedule,
you can do that and you're,
setting up data cleaning or you're running
a stored procedure that
manages some database or server maintenance.
There's a lot of different options
of basically enter database connectivity or
connecting into data pipelines and really doing
more rich object manipulation along the way.
>> Definitely, I see a lot of options here,
especially since, for example,
you can run Azure functions on a timer trigger type of thing,
so maybe that would relate to any scheduling you might be
doing in another way on prem or somewhere else.
>> For sure.
>> Awesome. As folks get started with this,
do you have any tips and tricks or advice for people who are just
getting started with Azure Functions
and these new Azure SQL bindings.
>> Yeah. I always recommend that people
start with pick one example that you want to take a look at.
The example that we walk through today
is introductory input and output binding.
But we did build out a bigger example for a to-do backend app.
That link will be in the description for the video.
That allows you to add items to a to-do list,
remove items from a to-do list,
get all of them.
There's a lot of different interconnectivity.
Dreaming up what you can work on and either going from an example
or starting small is certainly a recommendation.
The SQL Server extension for
VS Code has an additional command to help
you configure the input and output bindings.
If you get lost in the docs,
hop into the tool and say add
SQL binding and see if it can help you put it together.
>> Cool, that's awesome Drew.
Thanks so much for coming on the show today.
I learned a lot about Azure SQL bindings and some of
the benefits that I think our viewers probably did as well.
To our viewers, if you like this video,
go ahead and give it a like, leave us a comment,
and let us know what you think of
Azure SQL bindings and we hope to see
you next time on Data Exposed.
[MUSIC]