Today we're going to look into Azure Functions
versus the Agents with something they call Durable
Agent Framework.
Agents in Azure Functions is of course always
possible by just an HTTP trigger, but this
should make it more simple.
And I say should, because I ran in,
while recording this, I ran into a bug
with the latest NuGet package that totally didn't
work, and I spent a lot of time.
But once that was resolved by the team,
then it actually was fairly simple to get
running.
So let me show you.
So, in order to do this, I have
a Durable Agent Framework here, and a Hello
AI, because I think we will make more
videos on this, because there's more than just
what I'm going to show today about making
them work together and get stages back and
so on.
But for now, we're just going to make
a little world.
In order to do this, we need several
NuGet packages.
We, of course, need the normal two for
Azure OpenAI and OpenAI for Agent Framework.
We're also going to need the hosting one
for Azure Functions from the Agent Framework, and
then we need these Durable Tasks thingies.
I'm unsure if this is needed, but sometimes
when I don't include it, it breaks down,
so I've included them for the sake.
And here there is newer versions than these
two, but because they are the buggy ones,
I'm down to 1.9, which works.
1.10 should also work, but 1.11
is now unlisted as a NuGet package and
are broken.
Of course, they will fix it going forward.
But if you put these in and you
go to your host and add this extensions
Durable Task, then you should be good to
go.
So what we can do is we can
build our normal Azure Function setup here, and
then we can do our normal agents as
here, but then we add this extra one
that comes from the Microsoft Agent hosting Azure
Functions part, meaning this
NuGet package, which in turn uses these.
So this one just simply says, hey, add
an agent, and that's my agent I put
up here, which is just built like normal.
And then we don't really need to do
any more.
We can have normal functions as well, but
we don't really need them because this will
just, on the fly, like the MCP server
that also exists for Azure Functions, just spin
up some more endpoints on your Azure Function.
So if you run it, you will see
that we both get it as MCP and
we get it as the normal function, but
here we have the new thing, which is
the agent.
So the agents just have a URL like
an Azure Function has, and it's always post.
So I've chosen to go to Insomnia.
You could do Postman as well, and you
can go in and simply write that URL,
and then in a body, say message, and
the message.
So if you do that, it will come
back to you and tell you the answer.
So a normal request response is possible, and
we could easily have done this with a
HTTP trigger as well.
But what helps a bit in them being
doable is that in the headers back we
get here, we get actually a thread, which
is the conversation thread we are working on.
And what we can then do is we
can go in and do a follow-up
by putting in thread underscore ID equals the
thread.
And if we do that, it will actually
â€“ I must have done it wrong here.
Let me try again.
Okay.
So we get a thread.
We try a follow-up.
Yeah, my mistake was I had a space
here.
Try it again.
And now we see that it could take
the follow-up question of how tall was
he, meaning Mohammed Gandhi.
So that is actually everything there is to
it.
I, again, spent a lot of time because
I went to the newest NuGet package.
So if we go here, there was a
NuGet package.
It's been unlisted.
Also, if you have some problems running the
Escher functions, that's because it's dependent on a
Docker image for the storage emulator, and I
put up a console command line that you
need to run in order to have the
Escher right for storage.
But that's more an Escher function thing than
the AI thing because the new thing is
just make an agent, make this simple call,
and it's ready to go.
You don't need to make your own request
response or anything.
That is taken care of for you.
So we're done.
Thank you.
See you in the next one.